Linux logout other user

Linux Logout user / Logoff User Commands

I am a new Linux sysadmin. I am using Linux on HP server. How do I logout users from my systems? How can I forcefully logoff any user using bash shell on Linux?

A root user can logout and kill any user session forcefully using the following commands:

a) pkill command – Kill processes by name.

b) kill command – terminate or signal a process.

c) logout command – Logout of a login shell. This command can be used by normal users to end their own session.

logout command syntax and example

If you are logged in as nixcraft user and just wanted to exit a login shell type the following command or hit CTRL+D:
$ logout
You will be logout of a login shell session or secure shell session.

Task: Linux logout all other users

If you would like to logout other users, you must login as root user. Next you need to use the pkill command.

pkill command syntax

Warning : Do not kill root user or other system level user process. The following example, will kill all process on your server. Do not run the pkill for root user:
pkill -KILL -u root

To see list of logged in user type who or w command:
# who
# w
To logout a user called raj, enter:
# pkill -KILL -u raj
$ sudo pkill -KILL -u raj

See also
  • For more information read our previous “Linux kill and logout users” tutorial.
  • Man pages: pgrep(1)

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


How To Logoff User Forcibly in Linux?

We have some servers to manage. There are some user access to our server. We want to them log off or kill their processes by terminating. How can be achieve this?

List Logged On Users

We can logout other users forcibly like below. Keep in mind we need to be root to complete this command. First we will list currently logged in users with the who command. We can use w command alternatively to list users.

List Logged On Users

Logout From GUI or Desktop Environment

Different desktop environments provides GUI menus in order to logout from current session. In this example we will logout the user ismail from and XFCE desktop environment session. From right corner by clicking the user name we will list some menu which provides actions like Lock Screen , Suspend , Shutdown and Log Out . We can use Log Out button in order to logout from current user session.

Logout From GUI or Desktop Environment

logout Command

We can logout from current Linux user from terminal with the logout command.

logout Command

Logout Current User

We will use pkill command. This command will kill all processes owned by the given user with the -u option. In this example we know that the user ismail is logged in. We will log out the user ismail . We will also provide the -KILL option which will kill all processes related with the user ismail . Keep in mind that this will suddenly stop all this user related processes. This

  • User -utest2 is logout
  • pkill is the command which will send signals to the provided user processes
  • -KILL is the kill signal to the specified user processes.
Читайте также:  Postgresql plpgsql if else


Ubuntu Documentation

When you have finished using your computer, you can turn it off, suspend it (to save power), or leave it powered on and log out.

Log out or switch users

To let other users use your computer, you can either log out, or leave yourself logged in and just switch users. If you switch users, all of your applications will continue running, and everything will be where you left it when you log back in.

To Log Out or Switch User , click the system menu on the right side of the top bar, expand Power Off / Log Out , and select the correct option.

The Log Out and Switch User entries only appear in the menu if you have more than one user account on your system.

Lock the screen

If you’re leaving your computer for a short time, you should lock your screen to prevent other people from accessing your files or running applications. When you return, you will see the lock screen . Enter your password to log back in. If you don’t lock your screen, it will lock automatically after a certain amount of time.

To lock your screen, click the system menu on the right side of the top bar and select Lock from the menu.

When your screen is locked, other users can log in to their own accounts by clicking Log in as another user at the bottom right of the login screen. You can switch back to your desktop when they are finished.

See Also

  • Automatically lock your screen — Prevent other people from using your desktop when you go away from your computer.
  • The screen locks itself too quickly — Change how long to wait before locking the screen in the Screen Lock settings.


To save power, suspend your computer when you are not using it. If you use a laptop, the system, by default, suspends your computer automatically when you close the lid. This saves your state to your computer’s memory and powers off most of the computer’s functions. A very small amount of power is still used during suspend.

To suspend your computer manually, click the system menu on the right side of the top bar, expand Power Off / Log Out , and select Suspend .

See Also

  • Set up automatic suspend — Configure your computer to suspend automatically.
  • Use less power and improve battery life — Tips to reduce the power consumption of your computer.
  • What happens when I suspend my computer? — Suspend sends your computer to sleep so it uses less power.

Power off or restart

If you want to power off your computer entirely, or do a full restart, click the system menu on the right side of the top bar, expand Power Off / Log Out , and select either Restart… or Power Off… .

If there are other users logged in, you may not be allowed to power off or restart the computer because this will end their sessions. If you are an administrative user, you may be asked for your password to power off.

You may want to power off your computer if you wish to move it and do not have a battery, if your battery is low or does not hold charge well. A powered off computer also uses less energy than one which is suspended.


How to log out from Ubuntu terminal

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.

Читайте также:  Кабель для принтера canon pixma mp230

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.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.


Methods to log out of CentOS 8 ?

When you use a terminal or if you log in to a Linux system via SSH, you open a shell session. If you want to logout from your session, you simply exit the shell.

This is why the exit command is equivalent to log out command in Linux.

Also, When multiple users are using your system, you need to logout from one user account and login back in with another user.

At that time, switching the user option is not a good choice because by doing this current session running in the background.

Читайте также:  Linux если есть два ip

Therefore, when you logout a user, it will quit the current user’s session, and running processing will also close on your system.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform CentOS related Installation tasks.

In this context, we shall look into different methods to logout of the CentOS 8 system.

How to log out of CentOS 8 Linux System ?

We can use the following different ways you can log out of the CentOS 8 system:

i. Logout using the command line.

ii. Logout session using the CentOS system menu.

iii. Logout using the Activities application search.

iv. Logout using the keyboard shortcut.

Note that this also applies to other Linux distributions like Ubuntu, Debian, and Linux Mint.

Now we will look into these methods in more details.

1. How to Logout via the Command line on CentOS 8 ?

Here, you can logout of the current user session using the command line.

i. To implement this, launch terminal from the system ‘ Activities ‘ located on the top left corner in CentOS 8.

ii. Click on it and then from the sidebar open the terminal application by clicking on the terminal icon.

iii. Now, use the below-given command in order to logout from the current user’s account on the CentOS 8 system:

iv. A dialog will show on the desktop where you can Click on the ‘ Logout ‘ if you want to quit the current user session otherwise, close it to remain logged in with this user account.

2. How to Logout session using the CentOS 8 system menu ?

i. Here you can click on the arrow sign in order to open the more drop menu options.

The list of options will display in the top right corner.

ii. Click on the current login user name.

iii. Now, click on the logout to close the current user session.

iv. Then, click on the ‘ Logout ‘ option in order to quit the current session.

3. How to Logout using the Activities application search on CentOS 8 ?

To implement this, follow the process given below:

i. Click on the ‘ Activities ‘ and type the ‘Log Out’ keyword in the search bar.

As a result, you will see the logout icon under the search bar.

ii. Click on it in order to logout from the CentOS 8 environment.

4. How to Logout using the keyboard Shortcuts in CentOS 8 ?

i. To logout using the keyboard, first, you will search for the shortcut keys.

ii. So, type keyboard shortcuts in the search bar and click on the highlighted displayed ‘ keyboard ‘ option.

iii. Scroll your mouse pointer and you will see the logout shortcut keys in the list.

iv. Click on the ‘ Ctrl+Alt+Delete ‘ in order to logout from the current user’s account.

Also you can also change the keyboard shortcut by clicking on the displayed option to set Shortcut.

Here, Press the ‘ Esc ‘ key to cancel the dialog and if you want to set this shortcut then, press the ‘ Backspace ‘ key.

[Need urgent assistance to install Missing packages on your Linux Server? We are available to help you today . ]


This article will guide you on different methods to log out of the #CentOS 8 #Linux system. Therefore, If you want to close the current user session then, Logging out of the system is the best choice.

The main difference between these tools is that kill terminates processes based on Process ID number (PID), while the killall and pkill commands terminate running processes based on their names and other attributes.

To exit CentOS 7:

i. Simply use ‘Ctrl-C’ to kill terminal commands in linux.

ii. Ctrl-D should be used to terminate nl correctly.

iii. Ctrl-C is just a general way to kill #applications.


Поделиться с друзьями