This article discusses the various login, logout and shutdown commands available in Linux which can be accessed from the command line.
We assume you know how to log into your Linux account. To log out using GNOME or KDE, choose Logout from the main menu. To log out from a remote shell, just close the shell (type exit or logout ).
Never simply turn off the power to a Linux system: it needs a more graceful shutdown. To perform a shutdown from GNOME or KDE, use the main menu. To perform a shutdown from a shell, run the shutdown or systemctl command as the superuser, as follows.
shutdown [options] time [message]
The shutdown command halts or reboots a Linux system; only the superuser may run it. Here’s a command to halt the system in 10 minutes, broadcasting the message “scheduled maintenance” to all users logged in:
sudo shutdown -h +10 "scheduled maintenance"
time may be a number of minutes preceded by a plus sign, like +10; an absolute time in hours and minutes, like 16:25; or the word now to mean immediately.
With no options, shutdown puts the system into single-user mode, a special maintenance mode in which only one person is logged in (at the system console), and all nonessential services are off. To exit single-user mode, either perform another shutdown to halt or reboot, or type ^D to bring up the system in normal, multiuser mode.
-rReboot the system.
-hHalt the system.
-kKidding: don’t really perform a shutdown, just broadcast warning messages to all users as if the system were going down.
-cCancel a shutdown in progress (omit the time argument).
-fOn reboot, skip the usual filesystem check performed by the fsck program.
-FOn reboot, require the usual filesystem check.
systemctl [options] command [arguments]
In some Linux distros, the shutdown command is a symbolic link to systemctl, a multipurpose command for starting and stopping services, including the entire host. systemctl is part of a service manager called systemd ; a full treatment is beyond the scope of this book, but we’ll cover a few basic uses. (See man systemd for more details.)
sudo systemctl poweroff Shut down the system. sudo systemctl reboot Reboot the system. sudo systemctl suspend Suspend the system.
This article has presented the most common Linux login, logout and shutdown commands and options that can be accessed at the command line.