Shell script example to stop execution of all processes with a certain UID? [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
How do I kill all a user's processes using their UID
5 answers
I'm new to scripting and I can't seem to find any examples on the internet for this particular task. I'd much appreciate a bit of help.
shell scripting uid
marked as duplicate by Romeo Ninov, ilkkachu, G-Man, Jeff Schaller, sourcejedi May 27 at 19:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
How do I kill all a user's processes using their UID
5 answers
I'm new to scripting and I can't seem to find any examples on the internet for this particular task. I'd much appreciate a bit of help.
shell scripting uid
marked as duplicate by Romeo Ninov, ilkkachu, G-Man, Jeff Schaller, sourcejedi May 27 at 19:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Tryfor i in $(pgrep -U $UID); do kill -9 $i; done
orpkill -U $UID
whichever seems suitable, replace $UID with the required UID or just assign it a value beforehand.
â Kunal Gupta
May 27 at 8:06
All solutions will require CAP_KILL (permission to kill any process), or to be root (root has this permission).
â ctrl-alt-delor
May 27 at 11:36
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How do I kill all a user's processes using their UID
5 answers
I'm new to scripting and I can't seem to find any examples on the internet for this particular task. I'd much appreciate a bit of help.
shell scripting uid
This question already has an answer here:
How do I kill all a user's processes using their UID
5 answers
I'm new to scripting and I can't seem to find any examples on the internet for this particular task. I'd much appreciate a bit of help.
This question already has an answer here:
How do I kill all a user's processes using their UID
5 answers
shell scripting uid
asked May 27 at 8:01
Amelie
1
1
marked as duplicate by Romeo Ninov, ilkkachu, G-Man, Jeff Schaller, sourcejedi May 27 at 19:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Romeo Ninov, ilkkachu, G-Man, Jeff Schaller, sourcejedi May 27 at 19:04
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Tryfor i in $(pgrep -U $UID); do kill -9 $i; done
orpkill -U $UID
whichever seems suitable, replace $UID with the required UID or just assign it a value beforehand.
â Kunal Gupta
May 27 at 8:06
All solutions will require CAP_KILL (permission to kill any process), or to be root (root has this permission).
â ctrl-alt-delor
May 27 at 11:36
add a comment |Â
Tryfor i in $(pgrep -U $UID); do kill -9 $i; done
orpkill -U $UID
whichever seems suitable, replace $UID with the required UID or just assign it a value beforehand.
â Kunal Gupta
May 27 at 8:06
All solutions will require CAP_KILL (permission to kill any process), or to be root (root has this permission).
â ctrl-alt-delor
May 27 at 11:36
Try
for i in $(pgrep -U $UID); do kill -9 $i; done
or pkill -U $UID
whichever seems suitable, replace $UID with the required UID or just assign it a value beforehand.â Kunal Gupta
May 27 at 8:06
Try
for i in $(pgrep -U $UID); do kill -9 $i; done
or pkill -U $UID
whichever seems suitable, replace $UID with the required UID or just assign it a value beforehand.â Kunal Gupta
May 27 at 8:06
All solutions will require CAP_KILL (permission to kill any process), or to be root (root has this permission).
â ctrl-alt-delor
May 27 at 11:36
All solutions will require CAP_KILL (permission to kill any process), or to be root (root has this permission).
â ctrl-alt-delor
May 27 at 11:36
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
2
down vote
You can do this either via:
for i in $(pgrep -U $UID_OF_ANOTHER_USER); do kill -9 $i; done
OR
pkill -U $UID_OF_ANOTHER_USER
You can use the first one to do something more other than just killing those processes, like listing all of them while killing.
1
As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing.
â ctrl-alt-delor
May 27 at 11:34
add a comment |Â
up vote
1
down vote
Here is a simple solution, that will work if you are root.
su $uid -c kill SIGSTOP -1
Explanation: become that user, and kill everything that you can.
All solutions will require CAP_KILL (permission to kill any process), or to be traditional root (root has this permission), and permission (capability to change its own uid), as used by this solution.
Note I sent sigstop, this will pause the process (as asked for âº). Chose the signal that you want. Use sigkill as last resort.
add a comment |Â
up vote
0
down vote
killall -u $user -STOP
This is safe if run as another user and (for other signals) if no parent process belongs to the affected user.
ctrl-alt-delor's solution is probably better (safer). This one has the advantage of giving you a real exit code, though. The other one probably does not as both su
and kill
get killed themselves.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
You can do this either via:
for i in $(pgrep -U $UID_OF_ANOTHER_USER); do kill -9 $i; done
OR
pkill -U $UID_OF_ANOTHER_USER
You can use the first one to do something more other than just killing those processes, like listing all of them while killing.
1
As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing.
â ctrl-alt-delor
May 27 at 11:34
add a comment |Â
up vote
2
down vote
You can do this either via:
for i in $(pgrep -U $UID_OF_ANOTHER_USER); do kill -9 $i; done
OR
pkill -U $UID_OF_ANOTHER_USER
You can use the first one to do something more other than just killing those processes, like listing all of them while killing.
1
As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing.
â ctrl-alt-delor
May 27 at 11:34
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can do this either via:
for i in $(pgrep -U $UID_OF_ANOTHER_USER); do kill -9 $i; done
OR
pkill -U $UID_OF_ANOTHER_USER
You can use the first one to do something more other than just killing those processes, like listing all of them while killing.
You can do this either via:
for i in $(pgrep -U $UID_OF_ANOTHER_USER); do kill -9 $i; done
OR
pkill -U $UID_OF_ANOTHER_USER
You can use the first one to do something more other than just killing those processes, like listing all of them while killing.
edited May 27 at 14:13
answered May 27 at 8:11
Kunal Gupta
1756
1756
1
As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing.
â ctrl-alt-delor
May 27 at 11:34
add a comment |Â
1
As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing.
â ctrl-alt-delor
May 27 at 11:34
1
1
As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing.
â ctrl-alt-delor
May 27 at 11:34
As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing.
â ctrl-alt-delor
May 27 at 11:34
add a comment |Â
up vote
1
down vote
Here is a simple solution, that will work if you are root.
su $uid -c kill SIGSTOP -1
Explanation: become that user, and kill everything that you can.
All solutions will require CAP_KILL (permission to kill any process), or to be traditional root (root has this permission), and permission (capability to change its own uid), as used by this solution.
Note I sent sigstop, this will pause the process (as asked for âº). Chose the signal that you want. Use sigkill as last resort.
add a comment |Â
up vote
1
down vote
Here is a simple solution, that will work if you are root.
su $uid -c kill SIGSTOP -1
Explanation: become that user, and kill everything that you can.
All solutions will require CAP_KILL (permission to kill any process), or to be traditional root (root has this permission), and permission (capability to change its own uid), as used by this solution.
Note I sent sigstop, this will pause the process (as asked for âº). Chose the signal that you want. Use sigkill as last resort.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Here is a simple solution, that will work if you are root.
su $uid -c kill SIGSTOP -1
Explanation: become that user, and kill everything that you can.
All solutions will require CAP_KILL (permission to kill any process), or to be traditional root (root has this permission), and permission (capability to change its own uid), as used by this solution.
Note I sent sigstop, this will pause the process (as asked for âº). Chose the signal that you want. Use sigkill as last resort.
Here is a simple solution, that will work if you are root.
su $uid -c kill SIGSTOP -1
Explanation: become that user, and kill everything that you can.
All solutions will require CAP_KILL (permission to kill any process), or to be traditional root (root has this permission), and permission (capability to change its own uid), as used by this solution.
Note I sent sigstop, this will pause the process (as asked for âº). Chose the signal that you want. Use sigkill as last resort.
edited May 27 at 11:36
answered May 27 at 11:31
ctrl-alt-delor
8,75831947
8,75831947
add a comment |Â
add a comment |Â
up vote
0
down vote
killall -u $user -STOP
This is safe if run as another user and (for other signals) if no parent process belongs to the affected user.
ctrl-alt-delor's solution is probably better (safer). This one has the advantage of giving you a real exit code, though. The other one probably does not as both su
and kill
get killed themselves.
add a comment |Â
up vote
0
down vote
killall -u $user -STOP
This is safe if run as another user and (for other signals) if no parent process belongs to the affected user.
ctrl-alt-delor's solution is probably better (safer). This one has the advantage of giving you a real exit code, though. The other one probably does not as both su
and kill
get killed themselves.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
killall -u $user -STOP
This is safe if run as another user and (for other signals) if no parent process belongs to the affected user.
ctrl-alt-delor's solution is probably better (safer). This one has the advantage of giving you a real exit code, though. The other one probably does not as both su
and kill
get killed themselves.
killall -u $user -STOP
This is safe if run as another user and (for other signals) if no parent process belongs to the affected user.
ctrl-alt-delor's solution is probably better (safer). This one has the advantage of giving you a real exit code, though. The other one probably does not as both su
and kill
get killed themselves.
answered May 27 at 13:37
Hauke Laging
53.1k1282130
53.1k1282130
add a comment |Â
add a comment |Â
Try
for i in $(pgrep -U $UID); do kill -9 $i; done
orpkill -U $UID
whichever seems suitable, replace $UID with the required UID or just assign it a value beforehand.â Kunal Gupta
May 27 at 8:06
All solutions will require CAP_KILL (permission to kill any process), or to be root (root has this permission).
â ctrl-alt-delor
May 27 at 11:36