Home Terminal Tuts How to reboot, shutdown, log off PC from Terminal by command-line in Ubuntu and Linux Mint

How to reboot, shutdown, log off PC from Terminal by command-line in Ubuntu and Linux Mint

by Kiran Kumar
Published: Updated:
command line manage system state

Linux was all command-line when it began. Commands are input into Terminal, and this was the primary means of communicating with the OS to get things done. Eventually, the community desired to apply an easy-to-use user interface so that newbies to Linux won’t shy away from Linux.

That’s a good thing, but if you want to have some fun and get things done quickly, the terminal is the way to go.

In the new series of ‘Terminal Tuts’ for beginners of Linux, I will introduce you to new commands that will one day make you fall in love with commands!

Log off, Shutdown, and Restart PC Commands in Ubuntu, Linux Mint, and derivatives

Let’s start with a primary task such as how to log off, Shutdown, and Restart your PC from the Terminal by command-line way.

1. Log Off: 

Launch ‘Terminal’ and type following command:


This command will show a warning if any unsaved documents exist in the session and give you a chance to save them.

Alternatively, you can also use ‘force logout’ parameter which kills all the running programs and even unsaved documents without warning. Therefore use it cautiously!

gnome-session-save --force-logout 

Tip! As you see, the logout command is not straightforward and very hard to remember for beginners especially for those who never heard of the GNOME environment. Maybe merely a ‘logout’ command. It would make a perfect sense, but it is not a standard command. You can add custom alias using gedit command. I will Launch ‘Terminal’ and type this command:

gedit ~/.bash_aliases
alias logout="gnome-session-quit"

What you did is assigned a new alias logout which Ubuntu reads as gnome-session-quit and initiates logout command. Now you need to enter logout command to log off PC.


2. Shutdown

It is straightforward.


Note that this command doesn’t shut down the PC immediately. Instead, it ticks a timer and gives you one little time to save all things. If you need an immediate shutdown, use this command. Make sure to keep all documents before running this command.

sudo shutdown -P now

Few more Shutdown options:

shutdown +t "your message"

This command line shuts down the PC after the specified time ‘t’ in minutes and shows the message in quotes along with the standard shutdown dialog. Here is an example of the command:

shutdown +30 "Leave to pickup friend!"

3. Restart

There are two ways to restart your PC. Using any one the following commands:

sudo reboot
sudo shutdown -r

In the shutdown command above, notice the –rswitch at the end. It indicates that you want the computer to restart. sudo implies run the command as an administrator.

You also ask your computer to reboot after the time you mentioned. For example, in order to tell your computer to reboot in 30 minutes, use the command:

sudo shutdown -r +30

Want to reboot your computer at a specified time? You can do that too. For example, the below command will make your system to reboot at 3:00 PM.

sudo shutdown -r 15:00

4. Hibernate

Hibernate doesn’t work well in Linux. Most of the computer’s hardware is not capable of Hibernation. You can enter the pm-hibernate command and check. But if you are trying this out the first time, I advise you to save all the documents and close everything except your current browser and the Terminal. Because, if the Hibernate was not successful, all the session’s unsaved data will be lost.

sudo pm-hibernate


systemctl hibernate

After entering the above command, the system will turn off. Press the power button and turn on the system. After you log in, if you see all the session intact, it implies your system is capable of Hibernating.

5. Suspend / Sleep

If Hibernation was out of luck for you, the best option to use is Suspend or Sleep. During suspend most hardware are shutdown, and system state is saved in RAM instead of the hard disk in Hibernation mode. Therefore, the system still requires power in this state.

sudo pm-suspend


systemctl suspend

In order to put the computer to sleep after a certain amount of time, use the command:

echo 'pm-suspend' | at now + 15 minutes


echo 'systemctl suspend' | at now + 15 minutes

You may also like


Teguh Siswanto January 10, 2020 - 6:52 AM

thanks, it’s very useful

Stefan February 4, 2020 - 10:12 PM

Kali 2020.1 doesn’t shut down fully for me. Stays on “dragon” icon. I’ve tried multiple flash dries (I use USB boot). I cannot edit the grub files (“permission denied”) . Any suggestions?

Willarmand February 17, 2020 - 4:26 PM

Hello. Can I use sudo pm-hibernate at 15:00 or systemctl hibernate at 15:00? I mean to hibernate in specific time. Thank you.

Koushika Padmanaban June 20, 2020 - 2:34 AM

Thank you !

Anna December 11, 2020 - 1:20 AM

Hi, I was wondering if it is possible to reset a linux mint computer, and if yes, how to do it. I accidentally disabled wifi, and now my computer will not connect to any wifi networks. If there is a different way to fix that, please tell me. Thanks


Leave a Comment



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us


©2016-2023 FOSS LINUX



“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.