This quick tutorial teaches you how to shutdown Ubuntu or any other distributions from the Linux command line.
There are two ways to shutdown Ubuntu Linux.
- Using the menu (for desktop users)
- Using terminal (for both desktop and server users)
I’ll discuss both methods in this tutorial.
If you use Ubuntu desktop, you would have no problems in finding the shutdown and the restart option located in the top right corner. If you do, you can extend the next section to see what it looks like.
Shutdown/Restart Ubuntu via GUI (Click to expand)
It may depend on the desktop environment but usually, you’ll see the option in the top right corner:
If you click on the power-off button, it will give you three options: Cancel, Restart and Power Off. You can choose the one you want.
This article is specifically focused on Ubuntu server editions. You are probably stuck in a terminal and wonder how to shutdown or restart the system from the command line.
The good thing is that you can easily shutdown or restart Ubuntu from the terminal. And these shutdown commands are not Ubuntu specific, you can use the same command on any Linux distribution.
Restart or Shutdown Ubuntu Linux in Terminal
There are multiple commands you can use to shutdown Linux from the terminal. I would recommend the shutdown command. It’s easy to remember and easy to use.
Let’s see how can you use this shutdown command for shutting down or restarting your system.
Shutdown Ubuntu Linux immediately
If you use shutdown command without any arguments, it will shutdown your system in one minute. You can change the behavior and shutdown Ubuntu immediately using:
Schedule a shutdown in Ubuntu Linux
You can schedule a shutdown in various ways.
For example, to schedule a shutdown at 03:30 PM, you can use the command in following fashion:
sudo shutdown 15:30
You don’t always have to specify the absolute time. You can provide a relative time as well.
For example, to schedule a shutdown 20 minutes from now, you can use shutdown command like this:
sudo shutdown +20
Restart Ubuntu Linux immediately
Restarting Ubuntu can also be done with the wonderful shutdown command in Linux. You just have to use the -r option to specify that it’s a reboot request.
By default, if you just use shutdown -r, it will reboot your system after one minute. You can immediately restart Ubuntu like this:
sudo shutdown -r now
Schedule a restart in Ubuntu Linux
You can also schedule a restart in the same way you scheduled a shutdown.
To schedule a restart at 3:30 PM, you can use:
sudo shutdown -r 15:30
To schedule a restart 20 minutes from now, you can use:
sudo shutdown -r +20
Cancel a schedule shutdown or reboot
If you have scheduled a shutdown or a restart and later you realized that you don’t need it, you can cancel it easily. You just have to use the -c option with shutdown command:
sudo shutdown -c
I hope these quick tips helps you to shutdown and restart Ubuntu and other Linux distributions from the command line. Any questions or suggestions are always welcomed.