73

I When I logged into the machine as root and typed who to see which users are logged in, I found somebody else too logged in as root

devuser   pts/0        2011-11-18 09:55 (xxx.xxx.xxx.xxx)
root      pts/1        2011-11-18 09:56 (xxx.xxx.xxx.xxx)
testuser  pts/2        2011-11-18 14:54 (xxx.xxx.xxx.xxx)
root      pts/3        2011-11-18 14:55 (xxx.xxx.xxx.xxx)

How can I force a root user at pts/3 to logout?

3 Answers3

67

You terminate a session by killing its parent process, called the session leader. Find out which process it is with:

ps -dN|grep pts/3
Gareth
  • 19,080
Fabel
  • 1,238
  • 9
  • 17
44

To kill and logout a user, you can send KILL signal. Type the following command:

# skill -KILL -u vivek

Check these links for more information:

0

Improving a bit Fabel's answer above:

\# *for pid in $(for ptsn in $(w | grep **user_name** | grep pts | awk '{print $2}'); do ps -dN | grep "$ptsn " | awk '{print $1}' ; done); do kill -9 $pid; done*
Pricey
  • 4,710