LPIC 101.3 Change runlevels / boot targets and shutdown or reboot system

Weight: 3

Description: Candidates should be able to manage the SysVinit runlevel or systemd boot target of the system. This objective includes changing to single user mode, shutdown or rebooting the system. Candidates should be able to alert users before switching runlevels / boot targets and properly terminate processes. This objective also includes setting the default SysVinit runlevel or systemd boot target. It also includes awareness of Upstart as an alternative to SysVinit or systemd.

Key Knowledge Areas:

  • Set the default runlevel or boot target
  • Change between runlevels / boot targets including single user mode
  • Shutdown and reboot from the command line
  • Alert users before switching runlevels / boot targets or other major system events
  • Properly terminate processes

Terms and Utilities:

  • /etc/inittab
  • shutdown
  • init
  • /etc/init.d/
  • telinit
  • systemd
  • systemctl
  • /etc/systemd/
  • /usr/lib/systemd/
  • wall

System Runlevel

Determining the Default Runlevel

jalo@u1604:~$ runlevel  
N 5  
jalo@u1604:~$ systemctl get-default  

On systemd system use systemctl get-default to determine
what the default target is.

Change Runlevels

SysVinit System

Change system default runlevel in /etc/inittab: id:3:initdefault:
Change current runlevel by using command init 3

Systemd System

Change system default runlevel by specifying a given target
via a symlink:
ln -sf /usr/lib/systemd/system/graphical.target /etc/systemd/system/default.target

Change current runlevel by using command:
systemctl isolate runlevel5.target

isolate: Start the unit specified on the command line and its dependencies and stop all others. This is similar to changing the runlevel in a traditional init system. The isolate command will immediately stop processes that are not enabled in the new unit, possibly including the graphical environment or terminal you are currently using.

Shut Down and Reboot from the Command Line

shutdown brings the system down in a secure way. All logged-in users are notified that the system is going down, and login(1) is blocked.

shutdown -H now Will halt the machine(you need press the power button manually after this)
shutdown -h 20:00 Equivalent to poweroff, unless --halt is specified.
shutdown -P +30 "System going down in 30 minutes" Power-off the machine (the default).
shutdown -c Cancel scheduled shutdown operation

Terminating Processes

kill and killall

kill -9 PID This forcibly removes the processes from memory without even allowing them time to clean up memory and disk processes.
killall mozilla-bin

special use:
kill -HUP 2112 or kill -1 2112 send SIGHUP signal to process make it reload its configuration file