Selection between logging off and switching users option depends upon your requirements. But if you want to hand over the control of your Ubuntu system to another user, log out of the current session and permit another user to log in. Logging out disallows the other users to access your system without verifying their credentials. Another security aspect that the log-out option covers is that it protects the access of current users and forbids the authorized actions on the current login session. It also ensures that after the login session, the user’s access and credentials are safe.
In Ubuntu, you can log out from your current session using Ubuntu User Interface (UI), the Application’s search bar, and a Keyboard shortcut. Using the Ubuntu terminal to log out of your system is another straightforward method. This post will demonstrate how to log out from the Ubuntu terminal. So let’s start!
How to log out from Ubuntu terminal
To follow the procedure of logging out using the terminal, firstly, open up your Ubuntu terminal by pressing “CTRL+ALT+T”.You can utilize the “gnome-session-quit” command for terminating your current GNOME session. Here is the syntax of the “gnome-session-quit” command:
The “gnome-session-quit” command provides support to the following option:
- –logout: This option is used to confirm the log-out by displaying a prompt. That’s how things work by default in the “gnome-session-quit” command.
- –power-off: This option is used to prompt the user for verifying system reboot.
- –reboot: This option requests the current user to confirm the system reboot through a prompt.
- –force: This option is utilized to ignore any inhibitors.
- –no-prompt: If you add the “–no-prompt” option in the “gnome-session-quit” command, the current session will end without any user interaction.
In our case, we only have to log out from the current session. From your current session, you will be logged out by executing below-given command in the terminal:
As we have not added any options in the “gnome-session-quit”, this command will display a prompt before log out. Log out from the system while prompting the user is the default behavior of this command:
Here, confirm the log out by clicking the “Log Out” button; otherwise, you will be logged out from your system automatically in 60 seconds:
To log out from your Ubuntu current session, without any user interaction, write out the below-given command in your terminal:
After execution, you will be redirected to the following window:
Select the one you want to switch from the available list of system users and then enter the password. You are all ready to use your system!
To allow any other user to use your Ubuntu system, either you can switch users or log out from the current session. The process of logging out of your system maintains every security related to the current user’s access. In Ubuntu, you can log out from your current session using Ubuntu UI, Keyboard Shortcut, Application’s search bar, and terminal. This article showed you how to log out from the Ubuntu terminal using the “gnome-session-quit” command.