# 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.

Source: https://fullbytedeveloper.com/blog/essential-linux-commands-developers-part-2
Published here: 2026-11-18

Part 2 of the Terminal commands series. Part 1 is [top terminal commands every developer should know (part 1)](/blog/essential-linux-commands-developers-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](/blog/term-stuck) 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.

```bash
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:

```bash
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]

```bash
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
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](/blog/term-stuck).

Background a throwaway sleep, list it, then SIGTERM only that job:

```bash
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](/blog/pipes-redirection-until-obvious).

Send this to the friend who killed their SSH session trying to stop a stuck process.

Image: Process state machine from Running through Stopped (Ctrl-Z), Background (bg), Foreground (fg), to Terminated (kill). Side note: a command ending with & runs asynchronously. No people.
https://fullbytedeveloper.com/media/essential-linux-commands-developers-part-2/process-state-machine.webp
Job control moves a process between running, stopped, background, foreground, and terminated.

Image: Three boxes labeled cmd1, cmd2, and cmd3 linked by one-way pipe arrows. Caption: unidirectional channel. A pipe has a read end and a write end.
https://fullbytedeveloper.com/media/essential-linux-commands-developers-part-2/pipe-unidirectional.webp
A shell pipeline is a unidirectional channel from stdout on the left to stdin on the right.

Image: Safe kill checklist with three steps: copy PID from jobs -l, kill PID with SIGTERM, only then consider kill -9. Badge links to /blog/term-stuck. No people.
https://fullbytedeveloper.com/media/essential-linux-commands-developers-part-2/safe-kill-checklist.webp
Copy the demo PID, send SIGTERM first, and only then consider SIGKILL.

Image: Terminal demo: start sleep 30 in the background, show jobs -l with the PID, kill %1, then confirm the job is gone. No music, no people.
https://fullbytedeveloper.com/media/essential-linux-commands-developers-part-2/job-control.webp
Background a sleep job, list it with jobs -l, then SIGTERM it with kill %1.

## Sources

1. [Linux ps(1), man7.org, accessed 2026-11-14](https://man7.org/linux/man-pages/man1/ps.1.html)
2. [Linux pipe(7), man7.org, accessed 2026-11-14](https://man7.org/linux/man-pages/man7/pipe.7.html)
3. [Linux bash(1), man7.org, accessed 2026-11-14](https://man7.org/linux/man-pages/man1/bash.1.html)
4. [FreeBSD ps(1), FreeBSD 14.0, accessed 2026-11-14](https://man.freebsd.org/cgi/man.cgi?query=ps&sektion=1&manpath=FreeBSD+14.0-RELEASE)
5. [GNU coreutils manual, accessed 2026-11-14](https://www.gnu.org/software/coreutils/manual/)
