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

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
Kiran Kumar
Hi there! I'm Kiran Kumar, founder of I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities especially during Winter ;). When I'm not writing for FOSSLinux, I'm seen biking and hiking on scenic trails. Hope you enjoy using this website as much as I do writing for it. Feedback from readers is something that inspires me to do more, and spread Linux love!. If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful. Have a good day!


Please enter your comment!
Please enter your name here




How to create a bootable CentOS Live USB drive on Windows

create centOS Live USB drive
CentOS ISO downloads are available in two different variations - Minimal ISO and DVD ISO. So what are these? In this guide, you will know how to create a CentOS Live USB drive that can also be used to install CentOS.
best linux distros programmers
Linux distros have long been a favorite among programmers since the rise in popularity of the OS in the nineties. Programmers are technical by nature, and Linux distros appeal to that technical nature. Let's discuss why Linux is a great desktop OS for programmers and developers, and find out best distros suitable for them.
clean virus ubuntu live CD
In this tutorial, we are going to show you how to clean your Windows machine from infected viruses using an Ubuntu live USB or CD and the ClamAV antivirus. The ClamAV is a free, open-source antivirus that can be used on Ubuntu.
best video players for linux
Most Linux-based systems come with a built-in video player, but let's be honest, it most definitely won't be able to satisfy all of your requirements, due to the fact that default software is mostly made for basic purposes. In this article, we will review the 5 Best Video Players for Linux and thoroughly discuss their features as well as their pros and cons.