terminal tutorials - shutdown

Linux was all command-line when it began. Commands are input into Terminal and this was primary means of communicating with the OS to get things done. But, slowly GUI came in and high focus is now applied on developing a user-friendly desktop. Well, that’s a good thing, but if you want to have some fun and get things done quickly, terminal is the way to go.

terminal tutorials - shutdown

In the new series of ‘Terminal Tuts’ for beginners of Linux, I will introduce you to new commands which 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 basic 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 warning if any unsaved documents exists in the session and gives 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 straight forward and very hard to remember for beginners especially if never heard of the GNOME environment. How does just ‘logout’ command sound? That 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 just enter logout command to log off PC.


2. Shutdown

This is very simple and straight forward.


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

sudo shutdown -P now

Some 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 is two ways to restart your PC.

shutdown -r

4. Hibernate

sudo pm-hibernate

5. Suspend / Sleep

sudo pm-suspend


READ  How to record a screenshot by command line in Ubuntu
Previous articleCreate a bootable Bitdefender Antivirus Rescue USB drive in Ubuntu and Linux Mint
Next articleFacebook Messenger for Ubuntu, Linux Mint, and Fedora
Hi there! I'm Kiran Kumar, founder of FOSSLinux.com. 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!

Leave a Reply

Notify of