How to Reboot or Shutdown From Terminal in Linux

In all examples, we need to be root or use the command with sudo.

 

Reboot

🚀 ~ reboot

or

🚀 ~ poweroff --reboot

Note: In some systems, the reboot flag may not be available to use with poweroff command.

The reboot command can also be used with -f flag which stands for force option.

🚀 ~ reboot -f

Important! When using the -f flag in reboot command, the machine will reboot immediately without properly closing the system. Be careful with it.

 

Delayed Reboot

🚀 ~ shutdown -r <time_in_minutes>

For example, shutdown -r 1 will reboot our system after 1 minute. The -r flag stands for reboot option.

This command can also be used with -f flag which stands for skip fsck option.

🚀 ~ shutdown -r -f <time_in_minutes>

or

🚀 ~ shutdown -rf <time_in_minutes>

Important! When using the -f flag in shutdown -r command, the system will reboot without doing any filesystem check. Be careful with it. It’s safer to use the -F flag ( uppercase ) which stands for force fsck option, and forces the system to do filesystem check before closing it. Like this:

🚀 ~ shutdown -r -F <time_in_minutes>

or

🚀 ~ shutdown -rF <time_in_minutes>

If we want to reboot with 0 delay, then we can do:

🚀 ~ shutdown -rF 0

or

🚀 ~ shutdown -rF now

 

Shutdown

🚀 ~ poweroff

This command can also be used with -f flag which stands for force option.

🚀 ~ poweroff -f

Important! When using the -f flag in poweroff command, the machine will shutdown immediately without properly closing the system. Be careful with it.

🚀 ~ shutdown # We already know this command and some of its arguments, right? 🙂

If no argument specified, then the system will shut down after 1 minute. We can do shutdown now or shutdown 0 if we don’t want any delays.

 

Delayed Shutdown

To achieve this, we can again use the shutdown command as we did for reboot, this time without -r argument:

🚀 ~ shutdown <time_in_minutes>

or

🚀 ~ shutdown -P <time_in_minutes>

In the last example the -P flag stands for poweroff option which is the default when using the shutdown command.

Important! Now, in some systems ( like mxlinux, for example ) we’ll also need to specify -h flag for it to work, like this:

🚀 ~ shutdown -hP <time_in_minutes>

The -h flag is equivalent to --poweroff option.

 


How to cancel the delayed shutdown

When using the shutdown command to delay either shutdown or reboot, we can cancel the operation by typing

🚀 ~ shutdown -c

The -c flag here stands for cancel option. In some systems, instead of scheduling a delayed shutdown in the backyard, the system freezes the terminal interaction. In that situation, we can simply hit Ctrl+C and the process will be cancelled.

 

Bonus 🍭🎈

I used the phrase Be careful with it too many times in this article. If you feel stressed, then “relax” by listening some good music: 🎶

Pink Floyd - One Of These Days - YouTube