In Linux, a runlevel is a predefined system state that determines which services and processes are running on the system. There are several different runlevels that are defined on a Linux system, each of which corresponds to a different set of services and processes.
To define the runlevels and determine which runlevel your system is currently in, you can use the systemctl
command with the get-default
option to view the default runlevel for your system:
$ systemctl get-default
This will print the default runlevel for your system, which is the runlevel that your system will boot into by default.
To determine which runlevel your system is currently in, you can use the runlevel
command:
$ runlevel
This will print the current runlevel and the previous runlevel. The current runlevel is the runlevel that your system is currently in, and the previous runlevel is the runlevel that your system was in before the current runlevel.
Here is a list of the common runlevels that are defined on a Linux system:
0
: Halt the system.1
: Single-user mode.2
: Multi-user mode, without networking.3
: Multi-user mode, with networking.4
: Unused.5
: Multi-user mode, with networking and a graphical user interface (GUI).6
: Reboot the system.Note that these are just a few examples of how to define the runlevels and determine which runlevel your system is currently in. The specific steps may vary depending on the distribution and version of Linux that you are using. You can refer to the documentation for your distribution for more information on how to manage runlevels on your system.