If you are using an Ubuntu system with multiple users and one of the other users asks you to use the system, you have two options for giving the system to him. One is to switch users, and the other is to log out of your user session for the other person. The difference between the two is that when you switch users, your current session continues to run in the background and you can restore your applications to the same state when you log back in. However, when you log off, your current session is terminated and all running applications are stopped. So when you log back in, you will have to reopen all the applications you need. You can choose between switching users and logging off, whichever suits you at the time.
In this article, we will describe four ways using which a user can log out of his/her Ubuntu session:
- Using the UI
- Using the Keyboard shortcut
- Through the application launcher search bar
- Through the Ubuntu command line, the Terminal
We have run the commands and procedures mentioned in this article on a Ubuntu 20.04 LTS system.
Method 1: Log Out Using the UI
One of the simple ways to log out of your Ubuntu session is to use the menu accessible through the downward arrow located at the top right corner of your Ubuntu screen. This is the menu you will see when you click this arrow:
Click your username and you will be able to see the following two main sub-menu items: Log Out and Account Settings. Click on the Log Out option in order to log out of your current Ubuntu session. The following dialog will display if you do so:
This dialog lets you log out right then by clicking the Log Out button. Otherwise, the system automatically ends your session after 60 seconds unless you press the Cancel button.
Method 2: Log Out Using Keyboard Shortcut
Ubuntu comes with a set of default keyboard shortcuts that allow you to perform commonly used Ubuntu operations with keyboard shortcuts. Logging out, a very common operation is also assigned such a keyboard shortcut. When you press the key combination Ctrl+Alt+Del, the same logout dialog we described above is displayed.
You can see all of these keyboard shortcuts and even create your own using the System Preferences utility. Open the Preferences utility directly from the Keyboard view by typing the word “keyboard shortcuts” into the search bar of your application launcher as follows:
Click on the Keyboard search result and you will be able to see the following view:
Method 3: Log Out Using the Application Launcher Search
Another quick method to log out of your session is to use the very useful application launcher search bar. This bar can be accessed by hitting the Super/Windows key on your keyboard.
Enter the keyword “logout” in this search bar and you will see the Log Out utility in the search result as follows:
Click on the Log Out search result and you will be presented with the same Log Out dialog that we described above.
Method 4: Log Out Using the Terminal
For a Terminal-savvy person, the Ubuntu command line also provides a way to log out of your Ubuntu user session.
Open the Ubuntu command line, the Terminal, either through the application launcher search or the Ctrl+Alt+T shortcut.
Then enter the following command in order to end the current user’s login session:
When you run this command, a dialog appears that lets you log out right then by clicking the Log Out button. Otherwise, the system automatically ends your session after 60 seconds unless you press the Cancel button on this dialog.
If you want to directly log out without having to see this dialog, you can make use of the following command:
$ gnome-session-quit --no-prompt
So, these were some ways you can use to safely log out of your Ubuntu user session so that another user can use the system after you.