Top terminal commands (part 2): processes, pipes, and jobs
See processes, build pipes, and control jobs on a safe sleep demo without killing your SSH shell.
Published here · 5 sources · Resume reading
Part 2 of the Terminal commands series. Part 1 is top terminal commands every developer should know (part 1).
On a remote Linux box you need to see what is running, connect commands with |, park a job in the background, bring it back, and stop it safely. This Part 2 covers ps, pipes, bash jobs, and kill with SIGTERM first. If the terminal looks frozen, read terminal stuck? Do not close the window before you signal anything.
Build a safe demo tree
Work under /tmp/blog-demo-p2. Never send signals to PID 1, the SSH daemon, or your login shell.
rm -rf /tmp/blog-demo-p2
mkdir -p /tmp/blog-demo-p2
cd /tmp/blog-demo-p2
printf 'alpha\nbeta\ngamma\nfindme\n' > sample.txt
ps -o pid,ppid,stat,cmd -p $$You should see a one-line snapshot of your current shell with pid, ppid, stat, and cmd [1]. Read that PID before you send any signal.
List processes with ps and top
ps displays information about a selection of the active processes [1]. Linux procps accepts Unix options (with a dash), BSD options (no dash), and GNU long options [1]. Useful teaching forms:
ps -o pid,ppid,stat,cmd -p $$
ps -p $$ -o pid=,comm=You should see your shell PID twice: once with headers, once as a bare pid and command name. Broader listings such as ps -ef and ps aux both work on many Linux hosts; macOS and FreeBSD are BSD-shaped and do not match every Linux flag [1] [4].
top is the live monitor that ships with procps on many Linux boxes. Quit with q. htop is optional and may be missing on minimal servers; teach top first.
Connect commands with a unidirectional pipe
A shell pipeline is a unidirectional channel from stdout on the left to stdin on the right. man7 pipe(7): "Pipes and FIFOs (also known as named pipes) provide a unidirectional interprocess communication channel. A pipe has a read end and a write end." [2]
cd /tmp/blog-demo-p2
cat sample.txt | grep findme
echo "alpha beta gamma" | tr ' ' '\n' | sort
seq 1 5 | awk '{print $1*$1}'
printf 'a\nb\nc\n' | xargs -n1 echo prefix:You should see findme; then alpha, beta, and gamma on separate sorted lines; then 1 4 9 16 25; then prefix: a, prefix: b, and prefix: c [5].
By default a pipeline's exit status is the last command. With set -o pipefail, bash uses the last non-zero status (or zero if all succeed) [3]:
bash -c 'false | true; echo exit_nopipefail:$?'
bash -c 'set -o pipefail; false | true; echo exit:$?'You should see exit_nopipefail:0, then exit:1.
Control jobs in the background
Job control moves a process between running, stopped, background, foreground, and terminated. A command ending with & runs asynchronously. jobs lists active jobs; jobs -l includes PIDs; fg brings a job to the foreground; bg resumes a job in the background [3]. Typing the suspend character (typically Control-Z) stops a foreground process and returns control to bash [3]. For a stuck pager or prompt, see terminal stuck? Do not close the window.
Background a throwaway sleep, list it, then SIGTERM only that job:
bash -c '
set -m
sleep 30 &
jobs -l
kill %1
wait 2>/dev/null || true
echo killed_background_ok
'You should see a jobs -l line for sleep 30, then killed_background_ok after kill %1. Copy the demo PID, send SIGTERM first, and only then consider SIGKILL. Prefer kill %1 or kill PID (default SIGTERM) before kill -9 [3]. Never replace %1 with PID 1, with sshd, or with your login shell.
Run the Part 1 demo tree on the next SSH box, then add this Part 2 sleep job there before you touch real project processes. When you want the six-operator drill for |, >, >>, 2>, 2>&1, and <, continue with pipes and redirection until they feel obvious.
Send this to the friend who killed their SSH session trying to stop a stuck process.




Keep this guide
Filed under Dev explainers, Dev tools
Questions about this guide
Is this an official Linux Foundation curriculum?
No. It is an editorial Part 2 set for processes, pipes, and job control. Part 1 covers navigation, files, and search.
Do ps -ef and ps aux work the same on macOS?
Not always. Linux procps accepts both Unix and BSD styles. FreeBSD and macOS ps are BSD-shaped and do not match every Linux flag.
Should I start with kill -9?
No. Prefer SIGTERM first (kill PID or kill %1). Reach for SIGKILL only after a clean stop fails. Never signal PID 1, sshd, or your login shell in a demo.
Sources
- FreeBSD ps(1), FreeBSD 14.0, accessed 2026-11-14man.freebsd.org