Linux Logout user / Logoff User Commands

www‮tual.‬turi.com
Linux Logout user / Logoff User Commands

To log out a user from a Linux system, you can use the exit command or the logout command. These commands terminate the current user's session and log the user out of the system.

For example, to log out the current user, you can use the following command:

$ exit

Or:

$ logout

If you are logged in to the system remotely using a remote login client such as ssh, the exit or logout command will terminate the connection and log you out of the system.

Note that the exit and logout commands only work for the current user's session. They do not log out other users who may be logged in to the system.

To log out other users, you will need to use other tools such as the pkill command, the killall command, or the kill command.

For example, to log out all users who are logged in as the john user, you can use the following command:

$ pkill -u john

This will terminate all processes owned by the john user, effectively logging the user out of the system.

Alternatively, you can use the killall command to kill all processes with a specific name, or the kill command to kill a specific process.

For example, to log out all users who are logged in using the ssh command, you can use the following command:

$ killall ssh

This will terminate all ssh processes, effectively logging out all users who are logged in using ssh.

Note that these commands should be used with caution, as they can potentially disrupt other processes or cause unexpected behavior on the system. It is generally recommended to use these commands only as a last resort, and to prefer more targeted approaches such as the exit or logout commands whenever possible.

Created Time:2017-10-30 10:17:36  Author:lautturi