Linux Shutdown Command: Power Off, Restart, and Schedule Maintenance
Learn how to properly shut down your Linux and disable ctrl-alt-del
The shutdown command is used to shut down or restart the system at specified times. During this procedure, it disables the login system to prevent new users from logging in and sends custom messages to the terminals of all connected users notifying that the system will be shut down.
The most frequently used options are:
- -r Reboots the system after the shutdown sequence is complete;
- -h Halts the system after the shutdown sequence is complete. Does not restart the machine;
- -k Sends the shutdown message but does not initiate the shutdown sequence;
- -f Performs a fast system boot without disk check;
- -F Forces a disk check when the system restarts.
To restart the system immediately:
# shutdown –r now
To restart the system at 06:00 AM and send a message to the terminals of users:
# shutdown –r 06:00 “Haverá troca de hardware”
The difference between changing the runlevel to 0 or 6 and the shutdown command is that the shutdown command is administratively better because it notifies users that there will be a system shutdown. When changing init, there is no type of warning.
Control-Alt-Delete
The "ca" line in the /etc/inittab file handles what happens when we press the control+alt+del key sequence:
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
And before taking any maintenance or restart action on the system, especially when dealing with a multi-user server, it is polite for the administrator to use the wall utility to send messages to logged-in users.
Watch this short lesson about shutdown:
Learn much more about Linux in our online course. You can enroll here with a 7-day free trial. If you already have an account, you can access it here.
Liked it? Share :-)
That was just one piece. The course teaches the whole path — from your first command to exam day.