Hey, pal! Again I am here with my other article which focuses on showing you the power of the terminal. Today’s article focuses on how you can control the power functions of PC i.e. Power Off, Hibernate, suspend and restart. The commands are really easy and you can easily remember them and use them as you need.
There is no Terminal week or terminal special month going on if you are thinking so. Since the last month we focused more on the terminal, published many terminal related articles, many are waiting in line. This is natural because Terminal is an essential tool of Linux distros.
Let us start now.
Commands To Power Off/Shutdown
Here are the commands to shutdown. To turn off the PC, if it is Ubuntu or Debian based –
sudo poweroff or sudo shutdown -h now or sudo halt or sudo init 0 or systemctl poweroff
Use any one of them and system will power off. Remember sudo isn’t required until you are on lock screen or some kind of tricky situation. On any other distro –
shutdown -h now
Specify the time limit for shutdown like this one –
shutdown -h +60
In case you are wondering “h” represents halt. Also, you can sudo commands in case you want but they require admin privilege but the last command doesn’t require that. When you schedule time, it is in minutes which means 60 represents 60 min=1 hour.
Commands For Reboot
Here is how you can reboot your system from terminal –
sudo reboot or sudo init 6 or sudo shutdown -r now or systemctl reboot
You can use them on any Ubuntu/Debian based distro. Use only one at a time. Remember sudo isn’t required if you are logged in.
Or you can use this command on any kind of Linux based distro.
reboot or shutdown -r +60 ( Command to schedule restart) or shutdown -r
Even if you got this, “r” goes for a restart.
Commands to Suspend/Hibernate
Below is again the commands to either hibernate or so-called suspend. Interesting this is that if you have noticed that most commands are the same just some words or key changes, that’s all. You can easily remember all commands.
sudo pm-hibernate or sudo pm-suspend or systemctl suspend
Simple and elegant ways to do that. See most commands are also same here too.
Some of the discussions on Ubuntu forums helped me a lot to find that whether some of the commands work on not. Do check them out. They also contain some more methods (more complicated) too.
As you can see, the command line can do pretty much cool things. But personally, I will stick to my power key to just turn off my PC when needed. I am on Linux Mint. I can access what to do after pressing the power button, and also I am not always on a command line. But when I am, I always use –