A shutdown is a best and secure way to bring a system down. You can shut down a system immediately or you can also set a time delay after which the system will shutdown. This is a secure way as the shutdown command notifies all the processes and users before bringing the system down. And no new user login is allowed after the shutdown is command is initiated.
The other advantage that you get is that only the root user can execute the shutdown command. So to bring down the system only the root user account will be required. This prevents others from accessing and bringing down the system.
So let’s see how you can bring down the system with the shutdown command. As well as how you can set a time delay to shut down the system, for example, a 15-minute time delay to shutdown the system.
How to use the shutdown command
Before using the shutdown command let’s see the basics about it.
shutdown options time message
Option: Here it stands for options like halt, power-off, or reboot. So according to what actually you want to do with your system you can choose to put in place of option.
Time: Here time stands for a time delay after which you want to shut down or restart the system. You can also put a specific time at which in a 24-hour format at which the system will restart or shutdown.
Message: Here message stands for a message that is sent to all the users before shutting down.
Now first let’s see what options can we use while using shutdown command.
Options you can use in the shutdown command
- -a: Control access to the shutdown command using the control access file /etc/shutdown.allow.
- -k: Send’s warning to all the users of the shutdown, as if it was a real shutdown. But it just sends a warning and the system does not get shut down.
- -r: Reboot the system after shutdown.
- -h: Halt the system.
- -P: Instructs the system to shut down and then halt.
- -H: To drop the system into the boot monitor if the system supports it.
- -f: Skip fsck after reboot.
- -F: Force fsck after reboot.
- -c: It cancels a pending shutdown.
These are some of the options that you can use while using shutdown command.
Now if you want to delay shutdown by a certain fixed time or even if you want to shutdown the system at a specific time then you can use this.
To use the time delay you can use +m, here m stands for minutes that system should wait. Or the delay after which the system needs to shutdown. This +m needs to be in the place of time in the above shutdown command. If you use the word now or +0 the system will shut down immediately.
The other thing that you can do is specify a specific time at which the system should shut down. You can do this by specifying hh:mm in place of time in the above shutdown command. Here hh stands for hours in 24-hour format( 0 to 23) and mm stands for minutes.
Here messages can be used to inform other users. For example to inform about why the system is being shutdown.
How to shutdown after a 15 minute time delay?
Now suppose you want to shut down your Linux system or server after 15 minutes. Then here is the example of how to do it.
This command will shutdown the system after 15 minutes from the execution of this command.
So guys I hope this article helps you understand how you can use the shutdown command to shut down your system. And if you want to set a time delay then just enter the minute’s number after + sign in shutdown command.