Ubuntu Linux’s latest LTS version is 20.04, however, the commands to shutdown Ubuntu will work on all Linux versions. It doesn’t matter you are on Desktop or Server.
Indeed if we are using the Graphical user interface of Ubuntu Linux then we have GUI shortcuts to Power off, sleep, log out, or shut down the system. However, what about if we want to do the same using the command terminal. Yes, we can do all this from CLI as well.
From the command line we cannot only shut down our system but can schedule it along with other things on ubuntu, and all that we are going to show here.
Commands to Shutdown Ubuntu Linux via Terminal
Open command terminal or if you are using a server with CLI interface then you are already there. On GUI Desktop of Ubuntu, the shortcut to open the command terminal is Ctrl+Alt+T
Command to power off Ubuntu
If you want to shut down your system immediately, then simply type:
shutdown -h now
In case you want to power off your Linux system automatically but after some time then we can set that specific period of time in order to schedule the shutdown process.
shutdown -h time-in-number
For example to shut down the system after 2 minutes, then the command will be:
shutdown -h 2
If you want to use any specific clock time for example 9:20 am, then we can do that as well, for that we use:
shutdown –h 9:20
To cancel the Shutdown process
If you have executed the shutdown command and before that, you want to stop it. Then use
All Shutdown command parameters
Options: --help Show this help -H --halt Halt the machine -P --poweroff Power-off the machine -r --reboot Reboot the machine -h Equivalent to --poweroff, overridden by --halt -k Don't halt/power-off/reboot, just send warnings --no-wall Don't send wall message before halt/power-off/reboot -c Cancel a pending shutdown
To restart or reboot the PC running on Linux via Command terminal:
So, these are the common commands to shut down the Ubuntu and other Linux systems using command terminal or simply schedule the same along with restart.