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 Fedora Games Live USB drive in Linux

One of the best Fedora spins that has been for a while and also being well maintained is the Fedora Games. The Fedora Games spin is a great showcase of the best games available in the Fedora operating system.
switch to linux
Do you love Windows or Linux? Being on a Linux website, it's not hard to take a guess, but what are the strong reasons to switch to Linux? Linux is a 100% free OS. Is that reason alone enough? Let's find out! Never have there been more compelling reasons to make the switch. Here are just five great reasons for users to create that magical move from the wayward world of Windows to the lauded land of Linux.
Best video editors for linux
This article is for all the Linux users out there who are looking for video editors to create their own professional videos, which can range from short documentaries to even movies.
Linux Lite 4.8 desktop tour video
Linux Lite eases Windows 7 users transition to Linux much more comfortable by offering simple software like Team Viewer, VLC, Firefox, TimeShift backup utility, and a full Microsoft Office compatible office suite in LibreOffice.