101.3 Change runlevels and shutdown or reboot system

Key Knowledge Areas

  • Set the default runlevel.
  • Change between run levels including single user mode.
  • Shutdown and reboot from the command line.
  • Alert users before switching runlevels or other major system event.
  • Properly terminate processes.
  • Knowledge of basic features of systemd and Upstart

Terms and Utilities

  • /etc/inittab
  • shutdown
  • init
  • /etc/init.d
  • telinit

Runlevel

RunlevelDescription
0Halt the system
1,S,sSingle-User mode
2Multi-User - default at Debian systems, on Red Hat this is multi-user without NFS and X
3Multi-User - default at Red Hat systems (everything except X), not used at Debian
4Unused
5Multi-User - on Red Hat that's like runlevel 3, but with X
6Reboot the system

Switch to Single-User mode (1)

To boot directly into runlevel 1 either append 1 or single as the last parameter to your GRUB bootloader. These parameters will be passed to the init subsystem.

Alternatively, runlevel can be changed with the init command: init 1 will change to runlevel 1.

The default runlevel at boot time is looked up in /etc/inittab:

# The default runlevel.
id:2:initdefault:

To determine the runlevel you're currently using run the runlevel command.

Shutdown

To bring down your system in a controled way, use the shutdown command.

# reboot now
shutdown -r now
 
# fast reboot without filesystem checks on next boot
shutdown -rf now
 
# halt the system within 10 minutes with a warning message
shutdown -h +10 Going down in 10 minutes!
 
# reboot at midnight
shutdown -r 23:59
lpic/101.3.txt · Last modified: 2014-07 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready