• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

runlevel Command Examples in Linux

by admin

The output of the runlevel command will indicate your previous and current runlevel separated by a single space. If there was no previous runlevel ‘N’ will be used as a placeholder.

For example:

# runlevel
N 5

The output above indicates that the current runlevel is 5 and there was no previous runlevel.

Below is the list of what each runlevel values are defined as:

  • 0 — Halt
  • 1 — Single-user mode
  • 2 — Not used (user-definable)
  • 3 — Full multi-user mode
  • 4 — Not used (user-definable)
  • 5 — Full multi-user mode (with an X-based login screen)
  • 6 — Reboot

runlevel Command Examples

1. To see the current runlevel:

# runlevel 

2. To suppress the output:

# runlevel -q
# runlevel --quiet 

3. To run in verbose mode:

# runlevel -v
# runlevel --verbose 

4. To get the version info:

# runlevel --version 

5. To get the help:

# runlevel --help 

FAQ on runlevel

Is there a standard runlevel that most people run after installation?

It depends on the requirement of the user, most of the times servers runs on runlevel 3 and desktop’s on runlevel 5. Runlevel 5 is ideal for a desktop workstation. And runlevel 3 is ideal for production.

Does running runlevel 5 consume a lot more resources than runlevel 3?

The only difference in runlevel 3 and runlevel 5 is that runlevel 5 includes X11 (GUI) service along with all other services like firewall, nfs, rpc ntpd etc.

Is there a way to shutdown X once you are done?

You can eaither logout the user under system menu, of you can go back to the console (CTRL+ALT+F1..7) and press CTRL+x to terminate the X session.

Over all, is there any benefit to running one runlevel over another?

To have one runlevel over other is beneficial in the way to implement GUI related application and have testing in the same environment without much load on server. for example Change your monitor or video card and you can run the the tools to adjust without having to try to stop the boot sequence and test it fully and if any problems just kill the GUI and try again, if some combination does cause the X server to lockup, you can kill X without having to reboot the system.

Conclusion

The /etc/inittab file defines the default runlevel for a system. The processes that start for specific runlevels are defined in subdirectories of the /etc/rc.d directory. You can view the current runlevel at any time using the runlevel command:

$ runlevel
N 5

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to disable ssh for non-root users (allowing ssh only for root user)
  2. How to configure resource groups for MySQL Server running on Linux
  3. How to configure the logging of failed login attempts for vsftpd
  4. Basic “ls” Command examples in Linux
  5. lvcreate/lvremove Failed with Error “Can’t remove merging snapshot logical volume”
  6. How to Re-Balance BTRFS to Free Disk Space
  7. How to set “max_report_luns” and “max_luns” on CentOS/RHEL 7 to scan more than 16,383 LUNs
  8. mkswap Command Examples in Linux
  9. watch command examples to run a command repeatedly or monitor dynamically changeable files (like /proc/*)
  10. Linux “shutdown”, “poweroff”, “halt”, “reboot” Commands

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright