I know of the killall5, system V kill command.
Is there something similar where I can send a SIGSTOP to all user processes, a Host OS and guest OS included?
Possibly killall -SIGSTOP??
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
If you really want to do this, the following, executed by root, will send the
STOP signal to everything:
kill -STOP -1
This will screw with you system immensely though, so don't do that.
-1 as the process ID (from the
kill() C library spec in SUSv4):
If pid is -1, sig shall be sent to all processes (excluding an unspecified set of system processes) for which the process has permission to send that signal.
Executed by a user, this will do the same for all processes owned by that user, including the current shell. So don't do that either.
To stop all processes of a particular user, while not being that user (i.e. you are root):
pkill -STOP -u otheruser
If you execute this with
sudo while logged in as
otheruser it will still screw you over, so don't do that either.
The only reason I can see for sending
STOP to all processes of a user is when that user is a daemon user which is running a very limited number of things.
Also, remember to send
pkill (see pgrep) is a command-line utility initially written for use with the Solaris 7 operating system. It has since been reimplemented for Linux and some BSDs.
As with the kill and killall commands, pkill is used to send signals to processes. The pkill command allows the use of extended regular expression patterns and other matching criteria.
To signal all the processes of a given user , use:
pkill -signal <signalname> -u <userid> //(by default it will send SIGTERM)
You can use pgrep with this as a test before you run it to see the process name and pid of what will be signaled:
pgrep -u <userid> -l
You can use any signal (see
kill -l) with pkill. see
Info from man page
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match.
For example, pgrep -u root sshd
will only list the processes called sshd AND owned by root. On the other hand,
pgrep -u root,daemon
will list the processes owned by root OR daemon.
pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.
Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.)
The pattern is normally only matched against the process name. When -f is set, the full command line is used.
Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's or pkill's own process group.
Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used.
List the process name as well as the process ID. (pgrep only.)
Select only the newest (most recently started) of the matching processes.
Select only the oldest (least recently started) of the matching processes.
Only match processes whose parent process ID is listed.
Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's or pkill's own session ID.
Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix.
Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used.
Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used.
Negates the matching.
Only match processes whose name (or command line if -f is specified) exactly match the pattern.
Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.)
kill allows the special value
-1 for the PID parameter, meaning "all
processes (excluding an unspecified set of system processes) for which
the process has permission to send that signal", so this should be
similar to what a call to
killall5 would have done if given the
number for the STOP signal:
kill -SIGSTOP -1