Pkill

From DikapediaV2
Revision as of 18:30, 17 October 2024 by Ardika Sulistija (talk | contribs) (Created page with "pkill – Kill user session and forcefully logout of the system. Use the who command to see list of logged in users as follows: # w OR # who Sample outputs: root pts/0 Jul 29 13:53 (10.1.6.120) nixcraft pts/1 Jul 29 12:30 (10.1.6.121) sailee pts/2 Jul 29 12:33 (10.1.6.121) To force and logout nixcraft and sailee user, enter: # pkill -KILL -u nixcraft # pkill -KILL -u sailee Alternatively, just try bash and friends kung-fu and save t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

pkill – Kill user session and forcefully logout of the system.

Use the who command to see list of logged in users as follows:

# w

OR

# who

Sample outputs:

root     pts/0        Jul 29 13:53 (10.1.6.120)
nixcraft pts/1        Jul 29 12:30 (10.1.6.121)
sailee   pts/2        Jul 29 12:33 (10.1.6.121)

To force and logout nixcraft and sailee user, enter:

# pkill -KILL -u nixcraft
# pkill -KILL -u sailee

Alternatively, just try bash and friends kung-fu and save time:

### warning must be run as root or via sudo ###
who | awk '!/root/{ cmd="/sbin/pkill -KILL -u " $1; system(cmd)}'

OR

### warning must be run as root or via sudo ###
### Safe version :) ###
who | awk '$1 !~ /root/{ cmd="/sbin/pkill -KILL -u " $1; system(cmd)}'