July 10, 2022

RHEL 9.0 Administratively Log Out Users

# man w
...
NAME
       w - Show who is logged on and what they are doing.
...
# w
 14:08:39 up 3 min,  2 users,  load average: 0.03, 0.08, 0.03
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
student  pts/0     14:04    1:16   0.07s  0.05s sshd: student [priv]
root     pts/1     14:07    1.00s  0.04s  0.01s w
# man pgrep
...
NAME
       pgrep,  pkill, pidwait - look up, signal, or wait for processes based on name and other at‐
       tributes
...
# pgrep -l -u student
1725 systemd
1728 (sd-pam)
1735 sshd
1736 bash
# kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
 6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM

Use first SIGTERM, then try SIGINT; and only if both fail, to try again with SIGKILL.

# pkill -SIGKILL -u student

Verify that all users process are terminated with pgrep and w.

No comments: