A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/run-levels-linux/ below:

Run Levels in Linux - GeeksforGeeks

Run Levels in Linux

Last Updated : 08 Jun, 2023

A run level is a state of init and the whole system defines what system services are operating. Run levels are identified by numbers. Runlevel is a mode or state in which a Linux system operates. It has a crucial role in the management of the Linux System.

The important thing to note here is that there are differences in the runlevels according to the operating system. The standard LINUX kernel supports these seven different runlevels :

Runlevel Description 0 System halt i.e., the system can be safely powered off with no activity. 1 Single user mode. 2 Multiple user mode with no NFS (network file system). 3 Multiple user modes under the command line interface and not under the graphical user interface. 4 User-definable. 5 Multiple user mode under GUI (graphical user interface) and this is the standard runlevel for most of the LINUX-based systems. 6 Reboot which is used to restart the system. How to check Runlevel of our Linux system

We will discuss two easy ways to check runlevel in our linux system.

1) Using `runlevel` command

runlevel

This command will show what runlevel we are.

runlevel

2) Using `who` command

who -r
 

By default, most of the LINUX-based system boots to runlevel 3 or runlevel 5. In addition to the standard runlevels, users can modify the preset runlevels or even create new ones according to the requirement. Runlevels 2 and 4 are used for user-defined runlevels and runlevel 0 and 6 are used for halting and rebooting the system. Obviously, the start scripts for each run level will be different performing different tasks. These start scripts corresponding to each run level can be found in special files present under rc subdirectories. At /etc/rc.d directory there will be either a set of files named rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6, or a set of directories named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. For example, run level 1 will have its start script either in file /etc/rc.d/rc.1 or any files in the directory /etc/rc.d/rc1.d.

How to Change the Runlevel in Linux

init is the program responsible for altering the run level which can be called using the telinit command.

For example: To change the system to runlevel 3, you would use the following command:

sudo init 3

This command will stop all non-essential services and processes and start all essential services and processes required for a basic system operation, including networking services.

 For example: To change a runlevel from 3 to runlevel 5 which will actually allow the GUI to be started in multi-user mode the telinit command can be used as:

sudo telinit 5
To set the default runlevel for your Linux system 

Before in older version of Linux we used to modify the file "/etc/inittab" but in modern versions of Linux such as RHEL 9 and Ubuntu (starting from Ubuntu 15.04) use systemd as the init system instead of the traditional System V init. Therefore, the /etc/inittab file is no longer used.

Now we use `systemctl` command to ser default value of runlevel.

For Example: If we want to make our default runlevel 5 (Which is used as the graphical multi-user mode with networking), we can use the following command.

sudo systemctl set-default graphical.target

For Example: If we want to make our default runlevel  (Which is used as the multi-user mode without a graphical interface), we can use the following command.

sudo systemctl set-default multi-user. Target
Conclusion

In this article we have discussed ways to change or runlevel of our linux system. We have discussed two ways, runtime and Default changing. We have also discussed that Linux systems typically have seven runlevels, ranging from 0 to 6, and each runlevel corresponds to a specific set of services and processes that are started or stopped when the system enters that runlevel. Overall, by understanding this article anyone can effectively manage and maintain their Linux system.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4