How to Shutdown Ubuntu Server via Command Line
Here are various ways to shut down your Ubuntu system from the terminal.
Want to shut down your Ubuntu system from the command line?
Well, you can use the shutdown command:
sudo shutdown
Before you do that, you should keep a couple of things in mind because unlike rebooting Ubuntu, your system needs to be turned on explicitly after a shutdown.
- If you are using Ubuntu on a bare metal system (physical system), you need to have access to it to turn it on again. If you are doing it on a remote system, make sure that there is a way to turn on the machine.
- If you are using Ubuntu on a cloud server like Linode or DigitalOcean, then you can 'power on' the system from your account.
That might seem elementary, but it's good to have a note of it before you run the shutdown command.
But wait, you can't expect Linux to have a single solution. So let's have a look at some other ones.
1. Shutdown Ubuntu server with the shutdown command
While I've already shown the usage of the shutdown command at the beginning of this tutorial, it won't shut down the system immediately. It schedules a shutdown after one minute.
To shut down your system immediately, pair the shutdown
comment with now
:
sudo shutdown now
And it also allows you to schedule shutdown in Ubuntu. For example, let's schedule it to shutdown after 15 minutes:
sudo shutdown +15
2. Shutdown Ubuntu server using systemd
Using systemd is debatable but Ubuntu utilizes it by default so let's put it to work.
sudo systemctl poweroff
And it gets the instant effect!
3. Shutdown Ubuntu server using the init command
The init (initialization) is the parent of every process with a PID of 1. And when used at runlevel 0, it will shut down the system.
sudo init 0
4. Shutdown Ubuntu server using the poweroff command
A yet another way of shutting down your system from the terminal and that's what I generally use to shut down my servers!
sudo poweroff
Wrapping Up
The shutdown command is quite versatile. You can use it with -r
to restart your Ubuntu system instead of shutdown.
You can use it to prank your colleague. When used with the -k
option, it initiates a fake shutdown. And if you're curious, k stands for kidding!
This was a compilation of different ways to shut down the Ubuntu server and if you have any queries, let me know in the comments.
A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.