Runtime behavior

Runtime behavior

Processes and Services

How Linux runs programs, tracks processes, handles signals, manages background jobs, starts services, and records logs.

Audience
Desktop users, developers, and administrators
Reading time
21 min
Process identity
PID
Common init
systemd
Clean stop signal
SIGTERM

What a process is

A process is a running instance of a program. It has a process ID, a parent process, memory, open files, environment variables, permissions, and scheduling state.

Programs are files on disk. Processes are live execution. Running /usr/bin/ssh creates an ssh process. Running it twice creates two processes.

What a process is diagram
systemd PID 1root of user space
sshdremote login
shellinteractive child
servicedaemon
workerchild process

Parent and child processes

Processes form a tree. Your terminal starts a shell. The shell starts commands as child processes. Services may start worker children. When a parent exits, children are reparented or stopped depending on how they were launched.

Seeing the tree helps explain why closing a terminal can stop programs launched from it, and why services should be managed by systemd rather than started manually in a random shell.

Foreground and background jobs

A foreground job owns the terminal until it exits, pauses, or is interrupted. A background job continues while the shell accepts more commands. Shell job control is useful for interactive work but is not a service manager.

Run a command in the background
long-command &
jobs
fg %1

Process states and signals

Processes may be running, sleeping, stopped, zombie, or waiting on I/O. A process consuming no CPU may still be alive because it is waiting for disk, network, timers, or input.

Signals are messages sent to processes. SIGTERM asks a process to exit. SIGKILL forces immediate termination. SIGHUP often asks daemons to reload configuration, depending on the program.

Process states and signals
SignalMeaningUse carefully because
SIGTERMRequest clean terminationThe process may need time to shut down
SIGKILLForce terminationNo cleanup is possible
SIGHUPHangup or reload requestBehavior is program-specific
SIGSTOPPause processIt cannot be caught by the process

systemd, services, and daemons

A daemon is a background process that provides a service, such as SSH, printing, logging, DNS caching, a database, or a web server. systemd is the init system and service manager used by many distributions.

systemd units describe how services start, stop, restart, depend on other units, log output, and participate in boot. A service can be active now without being enabled at boot, and enabled at boot without currently running.

systemd, services, and daemons diagram
disablednot at boot
enabledstarts at boot
activerunning now
journallogs

Enabling, disabling, starting, and stopping

start and stop affect the current boot. enable and disable affect future boot behavior. restart stops and starts a service. reload asks a service to reread configuration without a full restart if it supports that operation.

Inspect a service
systemctl status ssh
Start now and enable at boot
sudo systemctl enable --now ssh
Read service logs
journalctl -u ssh --since today

Boot-to-login flow

After the kernel starts the first user-space process, systemd brings up targets and services. On a server, the path may end with a text login or SSH service. On a desktop, it continues through a display manager and desktop session.

When troubleshooting startup, ask which phase failed: kernel boot, systemd unit startup, login manager, desktop session, or a user shell configuration file.