How to kill user processes from the same user?

2

1

I opened a VNC server and my VNC session is suddenly dead. I have lot of xterms open. When I ssh to the machine. and type

users

I see a bunch of users – my user accounts, like:

userA UserA UserA UserA UserA UserA UserA

I know I can use

pkill -u usersname 

Since I can only log in as userA, every time I run pkill-u UserA, it will just kill my current session. but other userAs are still there

What can I do?

Grey

Posted 2012-06-09T21:25:01.713

Reputation: 143

2What is the actual question? – Renan – 2012-06-09T21:26:06.140

2@Renan I assume he wants to kill those extra user sessions. – slhck – 2012-06-09T21:27:55.983

exactly. other sessions are not killed, but my current session is killed – Grey – 2012-06-09T21:28:51.863

@slhck That's what I assumed, too. But he edited the question for clarification. – Renan – 2012-06-09T21:28:53.173

Answers

1

A useful tools is slay: sudo slay username If you don't run slay as root, you will end up killing off all of your processes however, rather than the specified user.

See also: https://unix.stackexchange.com/questions/18043/how-do-i-kill-all-a-users-processes-using-their-uid

glallen

Posted 2012-06-09T21:25:01.713

Reputation: 1 886

0

It seems like pkill -u someusername attempts to kill all processes from someusername.

What I think happens if you try to do this, is that you kill the processes from your own session succesfully, and fail to kill the other processes because you are not permitted to do so.

Though untested, I believe this should do the trick:

sudo pkill -u usersname 

Dennis Jaheruddin

Posted 2012-06-09T21:25:01.713

Reputation: 378

0

Get all of userA's PIDs other than that of your current shell with:

/bin/ls -u userA | egrep -v "^ +$$"

(Note the double quotes in the egrep command.) Then kill just those PIDs. Your shell should remain.

Fran

Posted 2012-06-09T21:25:01.713

Reputation: 4 774

0

Running

/bin/ls -u redmage 

Just gave me:

/bin/ls: cannot access redmage: No such file or directory

However,

who -u

Told me who is logged in, and printed the associated pid, EG:

redmage  tty4         2012-06-09 22:05 00:01         695
bluemage  pts/1        2012-06-09 18:28   .          3466 (:0.0)

Then just kill -9; No more CPU time!

kill -9 695

RedMage

Posted 2012-06-09T21:25:01.713

Reputation: 101