Linux/Unix utilizes run-levels to enable certain functionality from single user mode to GUI mode
these run-levels cater to different needs for system administrators and for troubleshooting
you can set a default run level to say boot to the CLI instead of the GUI. on servers, you generally would use run level 3 which is the multi-user mode which only gives you access to the GUI. But if you want to use the GUI you can raise your run level to run-level 5 which will enable the full GUI
see below for the chart of run levels that applies to Linux and Unix.
|0||Halt the system.|
|1||Single-user mode (for special administration).|
|2||Local Multiuser with Networking but without network service (like NFS)|
|3||Full Multiuser with Networking|
|5||Full Multiuser with Networking and X Windows(GUI)|
In systemd, the run levels are slightly different runlevels are targets and in order to enable a target, you will use the systemctl command to enable the target.
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).
Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).
Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).
Run level 5 is emulated by graphical.target (and runlevel5.target is a symbolic link to graphical.target).
Run level 6 is emulated by reboot.target (and runlevel6.target is a symbolic link to reboot.target).
Emergency is matched by emergency.target.
checking the current default run-level in systemd
- systemctl get-default
As you can see from the above chart you can issue a run-level i.e 0 which would halt aka shutdown the system this is obviously the lowest level the system can go. Then the higher the run level the more the functionality.
You can change the default run-level of your system you can change the following file.
/etc/init/rc-sysinit.conf -- Ubuntu ( Non Systemd)
you would for sure NOT want to change your default runlevel to 0 or 6 that would be bad and result in a system that either shutdown right away or reboots right away not very useful.
You can also add scripts that run at certain run levels if you go to
/etc/rc.d/ you will see folders such as
init.d/ rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ you can add scripts to these folders and the scripts will be called when that runlevel is initiated.
You can also change run-levels by running the following command in the terminal run-level 1,2,3 etc .
I hope this helps you understand runlevels if you have any questions please let me know!
Check out my youtube video with a demo of this in action!