How to Check and Display Runlevel on Unix or Linux System

In Unix or Linux servers, understanding and checking runlevels is a crucial skill for any webmaster or system administrator. A runlevel is a software configuration of the system that allows only a selected group of processes to exist. These processes are spawned by the init command/process, and each runlevel’s processes are defined in the /etc/inittab file.

Typically, runlevels 0, 1, and 6 are reserved for specific purposes:

  • 0 – Halt
  • 1 – Single mode
  • 6 – Reboot

On the other hand, runlevels 2, 3, 4, and 5 are used for the following:

  • 2 – Multi-User Mode
  • 3 – Multi-User Mode with Networking
  • 4 – Not used/User-definable
  • 5 – Start the system normally with appropriate display manager (with GUI)

Checking and Displaying Runlevel Using the “who” Command

The “who” command is a simple and effective way to check and display the current runlevel. Here’s how you can use it:

[root@centos62 ~]# who -r
run-level 3 2012-07-07 09:58

This command will display the current runlevel, in this case, runlevel 3.

See also  How to Add Linux Swap Space on CentOS 6 VPS

Checking and Displaying Current and Previous System Runlevel Using the “runlevel” Command

The “runlevel” command is another useful tool for checking and displaying the current and previous system runlevel. Here’s how to use it:

[root@centos62 ~]# runlevel
N 3

This command will display the previous runlevel (N for none if the system has not changed runlevel since boot) and the current runlevel.

Commands Mentioned

  • who -r – Checks and displays the current runlevel
  • runlevel – Checks and displays the current and previous system runlevel

Conclusion

Understanding and checking runlevels in Unix or Linux systems is a fundamental skill for any webmaster or system administrator. By using the “who -r” and “runlevel” commands, you can easily check the current and previous runlevels.

See also  How to Install Lighttpd With PHP5 (PHP-FPM) and MySQL on CentOS 6.5

Remember, each runlevel has a specific purpose and allows only a selected group of processes to exist.

FAQs

  1. What is a runlevel in Unix or Linux systems?

    A runlevel is a software configuration of the system that allows only a selected group of processes to exist. These processes are spawned by the init command/process, and each runlevel’s processes are defined in the /etc/inittab file.

  2. What are the purposes of runlevels 0, 1, and 6?

    In Unix or Linux systems, runlevels 0, 1, and 6 are reserved for specific purposes. Runlevel 0 is used to halt the system, runlevel 1 is for single-user mode, and runlevel 6 is for rebooting the system.

  3. What are the uses of runlevels 2, 3, 4, and 5?

    Runlevels 2, 3, 4, and 5 in Unix or Linux systems are used for different modes. Runlevel 2 is for multi-user mode, runlevel 3 is for multi-user mode with networking, runlevel 4 is not used and is user-definable, and runlevel 5 is used to start the system normally with an appropriate display manager (with GUI).

  4. How can I check the current runlevel using the “who” command?

    You can check the current runlevel by using the “who -r” command in the terminal. This command will display the current runlevel.

  5. How can I check the current and previous runlevels using the “runlevel” command?

    You can check the current and previous runlevels by using the “runlevel” command in the terminal. This command will display the previous runlevel (N for none if the system has not changed runlevel since boot) and the current runlevel.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *