A program is a file on disk, and a process is that program loaded into memory and running.
Every process has a PID (its own number) and a PPID (its parent's number).
The ancestor of every process is PID 1 — formerly init, now systemd.
A foreground process holds the screen, and a background process runs behind the scenes. To send one to the background, add & at the end of the command.
A daemon is a process that waits in the background to provide a service. Its name usually ends in d — httpd, sshd.
echo $$ # 2314 ← PID of the current shellbash # launch a child shellecho $$ # 2901 ← got a new PIDecho $PPID # 2314 ← the parent is the shell we just leftexit # end the child and return to the parent
Category
fork
exec
PID
Gets a new number
Stays the same
Original process
Remains as the parent
Is overwritten and disappears into the new program
Process count
Increases by one
Unchanged
When the shell runs ls, it makes a copy of itself with fork, and that copy becomes ls with exec. That is why the shell is still there after ls finishes.
If you type exec ls in the terminal, the shell itself turns into ls without a fork. When ls ends there is no shell to return to, so the terminal closes.
A state where the child has ended but the parent has not collected its exit status
A zombie is a process that has already ended. It uses neither CPU nor memory and only occupies a slot in the process table. In ps its state appears as Z.
A zombie cannot be killed directly. It is already dead. Terminate the parent and PID 1 cleans it up.
When a child ends, the kernel keeps "how it ended" (the exit status) until the parent collects it. That held state is the zombie. ps shows it as <defunct>.
So every process passes briefly through a zombie state when it ends. If the parent collects it right away, you do not notice it. The problem is when the parent does not collect it and the zombie stays.
In the output above, the zombie's PID is 3120 and its parent is 3100. The thing to deal with is 3100, not 3120.
Category
Orphan process
Zombie process
Which side ended first
The parent
The child
State of the child
Alive and running
Already ended
Resources used
Same as a normal process
Only one slot in the process table
In ps
PPID changes to 1
State Z, <defunct>
Action
None needed — PID 1 takes over and collects it when it ends
Make the parent collect it, or terminate the parent
An orphan is a process that is working normally. Only its parent has changed. A zombie, by contrast, is an empty shell that does no work.
The exam answer is "PID 1 adopts it." On recent distributions, the systemd process that manages the user session may become the new parent instead, so the PPID can show a value other than 1.
A single zombie is harmless, but if they keep piling up they use up all the PIDs and new processes can no longer be created.
The TTY column is ?. It means there is no connected terminal, and it is the sign for recognizing a daemon. A process I launched from a terminal shows up like pts/0.
The PPID is 1. It was not launched by a user logging in; PID 1 started it at boot.
Ending in d is only a convention, not a rule. There are daemons that do not end in d, such as nginx and sendmail, and conversely find, pwd, and useradd end in d but are not daemons.
Category
Background process
Daemon
Who launches it
The user, with &
The system, at boot
Terminal
Connected (pts/0)
None (?)
When it ends
When the work finishes or the terminal closes
Until the system shuts down or stops it
On distributions that use systemd, daemons are handled like systemctl start sshd and systemctl stop sshd. The older way was service httpd start.