How to Log Out of Ubuntu using the Terminal

This quick guide will show you how to log out of the Ubuntu operating system using the GUI or terminal.

Ubuntu Log Out using Terminal

Logging out of your system helps ensure that whoever next interacts with it must enter a password to utilize it.

This is especially useful when using your Ubuntu system in a public setting where someone will have easy access to your system.

It is possible to log out of your system using either the Ubuntu desktop interface or by just using the terminal.

Using the Terminal to Log Out of Ubuntu

Over the following two sections, we will show you how to log out of Ubuntu using the terminal. These steps differ slightly depending on whether you use the terminal from the desktop or a remote session.

By the end of these two sections, you will see how simple it is to log out of Ubuntu while using the terminal.

From the Desktop Interface

The command you use to log out from Ubuntu while using the desktop interface differs from what you would use with a terminal/remote session.

In the case of the desktop interface, we will need to utilize the “gnome-session-quit” command, as shown below.

Of course, to run any of these commands, you will need to open the terminal on Ubuntu. One of the easiest ways to open the terminal is to press CTRL + ALT + T.

1. To log out of Ubuntu, you will want to use the following command within the terminal.

By using the “--no-prompt” option, you will be immediately logged out of the system without being prompted.

gnome-session-quit --no-prompt

2. Alternatively, if you want to be prompted before logging out of Ubuntu, you can use the following command instead.

The only difference between this and the previous command is that we don’t utilize the “--no-prompt” option.

gnome-session-quit

3. When running the command without the “--no-prompt” option, you will be greeted with the following prompt on the screen before logging out. You will be automatically logged out if you don’t press anything after 60 seconds.

To log out of your system immediately, click the “Log Out” button.

Logging out of UBuntu using Terminal

Logging Out from a Terminal or Remote Session on Ubuntu

If you are using a terminal session or remotely connecting using SSH, logging out of Ubuntu requires a different command.

1. To log out when using the terminal (Such as Ubuntu Server) or an SSH connection, you will want to use the following command within the terminal.

logout

How to Log Out of Ubuntu from the Desktop Interface

This section will quickly show you how to log out of Ubuntu through the desktop interface. These steps might differ slightly depending on what version of Ubuntu you are currently running.

1. First, we need to bring up the system menu by clicking in the top-right hand of the screen.

Open system dropdown menu

2. In the drop-down menu, that appears you must clickPower Off / Log Out” (1.) to bring up additional options.

To begin the log out process on Ubuntu, click the “Log Out” button (2.).

Select Log Out option

3. You will now see a prompt asking you to confirm logging out. . You can click the “Log Out” button to log out immediately.

However, if you don’t do anything, you will automatically be logged out after 60 seconds have passed.

Click Log Out

Conclusion

At this point in the guide, you should hopefully have a good idea of how to log out of Ubuntu.

We showed steps for using the terminal or the desktop interface that comes with Ubuntu.

Please leave a comment below if you need assistance logging out of your system.

If you found this tutorial helpful, be sure to check out our many other Ubuntu guides. We also have plenty of general Linux tutorials that are worth exploring.

Leave a Reply

Your email address will not be published. Required fields are marked *