Yes, we can use the regular Power Off button on our Linux system to shut down it but what if you are using a command line system? Then how are you going to shut down it properly without pressing the hardware power-off button on the PC Cabinet?
Shutting the system properly is necessary to not only close the application process in the right way but to also avoid any data corruption problems. On the one side, it not only helps to reduce our electricity bills even the component from unnecessary usage.
This article is not discussing something out of the world but the last job which we performed with any desktop, mainly. With servers, the administrators would mainly avoid it once it starts serving millions of systems.
So, let’s start with the tutorial and know how to shut down a Linux system safely.
Shutdown commands in Linux with Examples
1st Command- Using ‘Shutdown’
The most common command we all use on our Linux such as RedHat, Ubuntu, Linux Mint, or Debian is “sudo shutdown”
It is the basic command, which we can start with:
However, as you run it, nothing will happen immediately. Instead, you will have a message. For example:
Shutdown scheduled for Wed 2022-12-28 18:36:51 IST, use 'shutdown -c' to cancel.
The message tells us that our system is scheduled to shut down after one minute. So, using this basic command our Linux will not turn odd immediately.
But wait, if you have changed your mind then you can stop this shutting down process by typing:
Turn Off Immediately
Well, if you don’t want to wait for 1 minute to Power off your Linux PC then the same command can be used again. But with a parameter – now.
Let’s see how to use that:
sudo shutdown now
Now, the system is not going to wait instead it will shut itself immediately.
The shutdown command in Linux with time
Well, this basic command can be combined with a specific time after which our Linux system will shut down automatically.
so, what we have to do:
sudo shutdown specify-the-time
Let’s say you want your Linux to wait for 10 minutes before shutting down. Then, the above command can be used as:
sudo shutdown 10
Furthermore, if your system is accessed by some other users as well. Then you can even display a message which will flash on the display before it turns off.
For that the syntax will be:
sudo shutdown time "message"
sudo shutdown 10 "if you want to cancel the process type shutdown -c"
You can further explore the Linux shutdown command with options. To see what are the available options use:
2nd Shutdown command with Example
If the previous command is not what you want then there is another one – “HALT“. It also works the same as the previous one.
Let’s know how to use it: You just need to type halt along with sudo. Whereas the -p option refers to Power off, If we don’t use this option then the command stops the CPU process at once instead of stopping them gracefully.
sudo halt -p
3rd one is Linux Power- Off
Although the above shutdown command examples are enough, want one more then here it is. Instead of using shutdown or halt, we can use more commands known as power0ff.
It is not only easy to remember but also to use. Let’s see how?
That’s it, your system will turn itself off immediately after running the above command.
What are shutdown and restart?
We Shutdown our computer when we want to turn it off completely and it will remain powered off until we turn it ON again. Whereas Restart means, the computer will shut down and turn ON itself immediately.
Difference between shutdown and power off in Linux?
Both shutdown and power-off commands in Linux result, in the same way, that is – Turn the system OFF. However, the power off shut our system down forcefully, whereas the shutdown command gracefully terminates all running processes and then turns out Linux system OFF.
Does shutdown need sudo?
No, we don’t require sudo rights to shut down our Linux system. Just with your current active user login to your system and run the given command. It will turn your system off immediately.