There are two main ways to log out of Ubuntu. The first and the most common is via the graphical user interface, and the second is via the terminal.

If you are running Ubuntu on a server, then you can only log out via the terminal. For the Ubuntu Desktop edition, you can use either the terminal or the GUI for logging out.

This guide will show you how to quickly and easily log out from your Ubuntu session via the terminal.

How to Log Out on Ubuntu Desktop

Depending on the desktop environment, there are several ways to log out on an Ubuntu desktop. If you are using GNOME, which is the default desktop in Ubuntu, run the following command to log out:

        gnome-session-quit
    

The system will display a prompt that looks similar to the one below. Click on the Log Out button to quickly end the session, otherwise, you'll be automatically logged out in 60 seconds.

ubuntu desktop logout prompt

To log out immediately without any prompts on the screen, type:

        gnome-session-quit --no-prompt
    

If you are using the KDE desktop environment, issue the following command to log out immediately:

        qdbus org.kde.ksmserver /KSMServer logout 0 0 1
    

Tip: You can also log out of Ubuntu using the keyboard shortcut Ctrl + Alt + Del and clicking Log Out on the prompt that appears.

Learn More: Ubuntu Desktop vs. Ubuntu Server: What’s the Difference?

Logging Out From a Remote Server

If you have logged in to a remote server via SSH or SFTP, you can easily log out or end the session by typing the following command:

        exit
    

The aforementioned command will end the remote connection and terminate your login session.

Related: Learn to Manage Remote Connections Via SSH

Explore Other Debian-Based Linux Distros

This guide has taken a look at how easy it is to log out of Ubuntu via the command line.

Ubuntu is no doubt one of the most popular Linux distros, but there are a lot of other great Debian-based distros that you may wish to explore.