Shorts
Processes
SHORT
COMMAND COVERED
ps - process status
List running processes using ps
This example runs the
ps command to list processes associated with the current terminal session and pipes the output to head to show the first few lines. Each line includes the process ID, terminal (also referred to as TTY), CPU time, and command name. By default the ps command only shows processes owned by the shell's current user. It's a quick way to see what's running without the overhead of an interactive tool like top.
Processes
SHORT
COMMAND COVERED
top - display information about processes
Monitor live process activity using top
This example launches the
top command, which displays a live, continuously updating view of system processes. The -stats option is used to specify only process ID's (also referred to as PID), the command, cpu usage percentage, and process state. The top command refreshes every few seconds, making it useful for spotting runaway processes in real time. Press q to exit the interactive display.
Processes
SHORT
COMMAND COVERED
jobs - display jobs status
List background jobs using jobs
This example starts a
sleep 10 command, but puts the command process in the background using &. This usage of the & symbol returns control to the shell immediately. Running the jobs command then lists all background jobs associated with the current session. Each job shows a job number, status, and the command that was issued. The job number, shown in between square brackets as 1, followed by the process id 90765, can be used to reference the process for commands like kill and fg.
Processes
SHORT
COMMAND COVERED
kill - terminate or signal a process
Terminate a background job using kill %1
This example starts a background
sleep process and confirms it's running with the jobs command. The kill %1 command sends a termination signal to job number 1. Running jobs again shows the process has been terminated. The % prefix is used to reference jobs by their shell job number rather than their system process ID.