How to restart Ubuntu or shutdown Ubuntu from terminal command line immediately. In this tutorial we will learn about the shutdown command in Linux with examples to turn off Ubuntu using terminal.
Command 1 – reboot
The reboot command can be used to halt, poweroff or reboot the machine. The different reboot command options which can be used in terminal are:
- –halt : Halt the machine, regardless of which one of the three commands is invoked.
- -p, –poweroff : Power-off the machine, regardless of which one of the three commands is invoked.
- –reboot : Reboot the machine, regardless of which one of the three commands is invoked.
- -f, –force : Force immediate halt, power-off, reboot. Do not contact the init system.
- –no-wall : Do not send wall message before halt, power-off, reboot.
Command 2 – shutdown
The shutdown command can be used to halt, poweroff or reboot the machine.
When the command is executed the first argument may be a time string (which is usually “now”). Optionally, this may be followed by a wall message. It is the message which is meant to be sent to all logged-in users before the system is shutdown.
The time string may either be in the format “hh:mm” for hour/minutes specifying the time to execute the shutdown at, specified in 24h clock format.
NOTE: When the time argument is used, 5 minutes before the system goes down the /run/nologin file is created to ensure that further logins shall not be allowed.
Following are the different shutdown command options that can be used in terminal:
- -H, –halt : Halt the machine.
- -P, –poweroff : Power-off the machine (the default).
- -r, –reboot : Reboot the machine.
- -c : Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that is not “+0” or “now”.
For example to shutdown after 10 minutes:
$ sudo shutdown -r 10
Command 2 – halt
The halt command can be used to halt, power-off or reboot the machine. On the UNIX based OS systems, the halt command has the following options:
- –halt : Halt the machine, regardless of which one of the three commands is invoked.
- -p, –poweroff : Power-off the machine, regardless of which one of the three commands is invoked.
- –reboot : Reboot the machine, regardless of which one of the three commands is invoked.
- -f, –force : Force immediate halt, power-off, reboot. Do not contact the init system.
- –no-wall : Do not send wall message before halt, power-off, reboot.
NOTE: Please be cautious before using any of the above given commands via Terminal.
You can also use sudo systemctl poweroff command to shutdown or power off an Ubuntu server desktop.
I hope you found this tutorial useful.