shutdown Command in Linux: How to Shutdown, Restart and Schedule
The shutdown command in Linux is used to shut down or restart the system at scheduled times. During this procedure, it disables the login system to prevent new users from logging in and sends customized messages to all connected users' terminals warning that the system will be shut down.
The most frequent options are:
- -r Restarts (reboots) the system after the shutdown sequence completes;
- -h Halts the system after the shutdown sequence completes. 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 users' terminals:
# shutdown –r 06:00 “Haverá troca de hardware”
The difference between changing the runlevel to 0 or 6 and the shutdown command is that shutdown is administratively better because it notifies users that there will be a system shutdown. With init change there is no type of warning.
Control-Alt-Del
The "ca" line in the /etc/inittab file handles what happens when we press the control+alt+del sequence:
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
And before taking any maintenance or system restart action, especially when dealing with a multi-user server, it is best practice for the administrator to use the wall utility to send messages to logged-in users.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.