Processes Flashcards
How do you list processes running on the system
ps
i.e ps -aux
How do you search for a process?
pgrep >pname<
pgrep -l >name< *show name aswell as PID
ps aux | grep >name
How do you search for processes belonging to a specific user?
pgrep -u
i.e pgrep -u cloud_user -l
How do you do an inverse search for a process?
pgrep -v
i.e pgrep -v -u user *all processes not owned by user
How do you kill a process using its name?
pkill >pname
How do you list all possible kill signals?
kill -l
What is the default kill signal of pkill and kill?
15 - SIGTERM
*instructs program to close
How would you kill a program that is not responding to a standard kill signal?
9 - SIGKILL
kill -9 >PID<
*forces program to close
What is kill -SIGHUP?
1 - SIGHUP
kill -1 >PID<
hang up connection to controlling processes within terminal, is issued when closing a terminal
What is kill -SIGINT?
2 - SIGINT
kill -2 >PID<
keyboard interrupt
What is kill -SIGQUIT?
3 - SIGQUIT
process sent by controlling terminal for it to quit
What is kill -SIGSTOP?
19 - SIGSTOP
kill -19 >PID<
stop a running process (pause)
What is kill -SIGTSTP
20 - SIGTSTP
kill -20 >PID<
request a process to stop (pause), can be ignored by process
What is kill -SIGCONT?
18 - SIGCONTINUE
kill -18 >PID<
resume a stopped process
How do you close a users terminal window?
pkill -t >tty<
*get tty (terminal) from w command
How would you kill a process for another user only?
pkill -u >user< >pname<
i.e pkill -u cloud_user sshd
How do you run a command and put it in the background as a job?
‘&’ command
i.e yes»_space; /dev/null &
How do you show running jobs?
jobs
How do you stop (pause) a running job?
kill -19 %
*% targets job instead of process
What is nice an renice?
Sets the priority for a process
-20 - highest priority
19 - lowest priority
How do you start a process with a specific priority level?
nice -n >n< >pname<
i. e nice 0 httpd
* child processes will have the same priority
How do you set the priority of an already running process?
renice -n >n< >pid<
i.e renice 5 2743
How do you set the priority of all running processes with a specific name?
renice -n {n} $(pgrep {pname})
*$() subshell is evaluated as a command and passed as a parameter to renice
How do you measure the time for a command to complete?
time
i.e time w
How would you get the number of processors on a system?
cat /proc/cpuinfo | grep 'model name' | wc -l */proc/cpuinfo is pseudo filesystem
Within the top command what are RES and SHR?
RES - no swap physical memory size
SHR - shared memory size
How do you use top to refresh a specified number of times then quit?
top -n >n<
i.e top -n 5
How do you use top with a specific frequency to update process information?
top -d >n<
i. e top -d 0.5
* twice a second
What is the output of load average for instance with the uptime command?
load average 1m 5m 15m
*divide percentage by number of CPUs to get system as a whole, numbers are represented in decimal format