Howto: Linux kill and logout users + getting information

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Howto: Linux kill and logout users + getting information

Postby viking60 » 21 Apr 2010, 13:41

There is a package called procps. It includes various useful (read as nifty) utilities. One of such utility is skill which is responsible to send a signal to users and process such as:

* Halt user terminal
* Kill user and logout
procps is most likely allredy installed on your distro so it's commands are ready to use.

How to halt/stop user called bill_gates:

su

Code: Select all

# skill -STOP -u bill_gates

How to resume already halted user called bill_gates:

Code: Select all

# skill -CONT -u bill_gates

Now over to the more likely alternatives:
How to kill and logout user called bill_gates:

Code: Select all

# skill -KILL -u bill_gates

And in case you get tired of all your users:
Kill and logout all users:

Code: Select all

# skill -KILL -v /dev/pts/*


That is just fine, but how do I know what users are logged inn to my system - you say?
procps has some nifty commands:
In a terminal -simply type:

Code: Select all

#w

and all the users will show

Here are some other commands from procps:

Code: Select all

# kill  : Send signal to a process aka kill process
# top : Display Linux tasks and other important stuff
# vmstat : Display virtual memory statistics
# free : Display free and used memory (RAM) statistics
# slabtop : Display kernel slab cache information in real time
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

Return to “Tips & Tricks”