Bash: Process Handling Cheat Sheet

# To suspend a job, type CTRL+Z while it is running. You can also suspend a job with CTRL+Y.
# This is slightly different from CTRL+Z in that the process is only stopped when it attempts to read input from terminal.
# Of course, to interupt a job, type CTRL+C.
myCommand &runs the job in the background and prompts back the shell
jobslists all jobs (use with -l to see associated PID)
fgbrings a background job into the foreground
fg %+brings most recently invoked background job
fg %-brings the second most recently invoked background job
fg %Nbrings job number N
fg %stringbrings a job whose command begins with the string
fg %?stringbrings a job whose command contains the string
kill -lreturns a list of all signals on the system, by name and number
kill PIDterminates the process with specified PID
psprints a line of information about the current running login shell and any processes running under it
ps -aselects all processes with a TTY except session leaders
trap cmd sig1 sig2executes a command when a signal is received by the script
trap "" sig1 sig2ignores that signals
trap - sig1 sig2resets the action taken when the signal is received to the default
disown <PID|JID>removes the process from the list of jobs
waitwaits until all background jobs have finished

Leave a Reply

Your email address will not be published. Required fields are marked *