How to kill all processes of logged-in users as root in Linux

As root, you can use the pkill command to kill all processes for a specific user. To kill all processes for all logged-in users, you can combine pkill with the who command to get a list of logged-in users, like so:

for user in $(who | awk '{print $1}'); do pkill -KILL -u $user; done

This will loop through each logged-in user, use pkill to send a SIGKILL signal to all their processes, effectively terminating them. Note that this is a very aggressive way to terminate processes and should only be used if absolutely necessary, as it can cause data loss and other issues.

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to restrict direct root access in Linux

We can do it just in two steps. Step One: At first we will create new root user as follows (for...

How to extract .tar.gz files in Linux/UNIX OS

A tarball is a group of files that are bundled together using the tar command. Use the...

How to add welcome message when SSH start?

You need to change the contents of /etc/motd. Unfortunately, by default, /etc/motd is a link to...

How to change root password when SSH logged in

Run the following command: passwd Now type your new passwordOnce done, retype new passwordDone!...

How to install Pinguzo on any Linux/UNIX OS

Login to Pinguzo panel using Softaculous account or create an account of Pinguzo To add new...