How To Use Linux Shutdown, PowerOff and Reboot Command

The shutdown, poweroff and reboot commands are the most important power cycle commands in Linux. These commands are specifically used in a situation where you have to bring the server down for maintenance or reboot servers for a kernel upgrade or patches.

Here, we will see how to use the Linux shutdown and poweroff command to shutdown/power-off a system. Also, reboot command to restart the system.

Prerequisites

To be able to shutdown or reboot a system, you must be logged in as the root user or a user with sudo privileges.

Prefix sudo to execute these power cycle commands like sudo shutdown in Ubuntu or Debian or Fedora.

How to use shutdown command

The shutdown command in Linux safely brings the system down. When we initiate shutdown, all logged-in users are notified that the system is going down and no new logins are allowed, and then all the running process are stopped before the system finally halts.

The shutdown command is a simple command and is available in all Linux flavors like CentOS, Ubuntu, Debian or Fedora.

Syntax:

shutdown [OPTIONS...] [TIME] [MESSAGE...]

OptionsShutdown options like halt (-h), reboot (-r) or power-off (-P default)
TimeSpecifies when to perform shutdown (+m, hh:mm or now)
MessageBroadcast message to all logged in users.

Shutdown System

When no option used with shutdown command, it will power off the machine. The shutdown process starts after 1 minute (default interval).

shutdown
Shutdown System

Shutdown System Immediately

Use now in shutdown command to bring the system immediately.

shutdown now
The system will not send a broadcasting message to logged in users.

Schedule System Shutdown

You can schedule a server shut down by mentioning relative time hh:mm (24 hours format) or +m, where m is the minutes from now to process shutdown.

To shutdown a system after 2 minutes, use:

shutdown +2

To shutdown a system at 10:30 PM, use:

shutdown 22:30
Schedule System Shutdown

Send shutdown Broadcast Message

You can send a custom message to all logged in users as a notification. This option is often useful for scheduled maintenance.

shutdown +15 "The Server will be down for scheduled maintenance"
Send Shutdown Broadcast Message

Reboot system

Use the -r option with shutdown command to reboot the system.

shutdown -r

You can also schedule a system reboot like this.

shutdown -r +3

Cancel a scheduled shutdown

For any reason, you want to cancel the scheduled shutdown, use -c option.

shutdown -c
Cancel Scheduled Shutdown

How To use poweroff Command

The poweroff command is used to power-off the system.

Syntax:

poweroff [OPTIONS...]

Poweroff System

When used with no options, it will power-off the system immediately.

poweroff

Reboot system

Use –reboot option with reboot command will reboot the system instead of power-off the system

poweroff --reboot

Force poweroff system

The -f option with poweroff command will forcibly poweroff the system. The system will poweroff instantly just like unplugging the power source of the CPU.

poweroff -f

How To use Reboot Command

The reboot command is used to reboot the system.

Syntax:

reboot [OPTIONS...]

Reboot System

When used with no options, it will reboot the system immediately.

reboot

Power off system

Use -p option with reboot command will power off the system instead of rebooting the system

reboot -p

Force reboot system

The -f option with reboot command will forcibly reboot the system. The system will reset instantly just like pressing the reset button in the CPU.

reboot -f

Conclusion

I hope you now have a good understanding of how to use Linux shutdown, poweroff, and reboot command. Always run these commands with caution and ensure you are running it on the correct system.

linux basicspoweroffrebootshutdown
Comments (0)
Add Comment