Forcibly logging out a user on Linux maintains control over shared systems when sessions hang, permissions change, or access must be revoked immediately. Removing only the problematic login preserves availability for other users and avoids the disruption of stopping services or rebooting.
Utilities such as who, ps, and pkill correlate login names with active sessions and the processes backing them. Locating the interactive shell or session leader by process ID makes it possible to terminate a single login cleanly instead of disconnecting networking or restarting the host.
Forcible termination discards unsaved work and can interrupt database clients, editors, or file transfers mid-operation, so it suits only cases where a normal logout is impossible or unsafe. Commands that target all processes for an account affect every terminal and background job owned by that user, which is especially sensitive for shared accounts and production services on multi-user servers.
$ whoami user
$ who audituser pts/0 2026-01-10 12:15 (203.0.113.10) user pts/1 2026-01-10 12:15 (203.0.113.10)
The second column, such as pts/1, indicates the terminal attached to the login session.
Matching the username and pts value helps distinguish multiple logins for the same account.
$ ps -u audituser PID TTY TIME CMD ##### snipped ##### 3853 ? 00:00:00 sshd 3854 pts/0 00:00:00 sleep
$ sudo kill 3854
sleep is the interactive placeholder process in this example; stopping it cleanly ends the user’s terminal session.
$ sudo pkill -u audituser
Stopping all processes for an account also terminates background jobs and service-like tasks owned by that user, which can interrupt running workloads.
$ sudo pkill -9 -u audituser
Using SIGKILL bypasses cleanup and can leave temporary files or partially written data on disk.
$ who user pts/0 2026-01-10 12:15 (203.0.113.10)
Absence of the username in the who output confirms that all interactive sessions for that account have been closed.