Linux systemd and Service Processes

systemd-oriented process inspection, signaling, cgroup views, transient units, and service troubleshooting.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## systemd Service Process Views
Show service status
systemctl status nginx

# Show status, recent logs, and the service main PID.

Show main PID only
systemctl show -p MainPID nginx

# Extract the tracked main PID for a unit.

Show unit definition
systemctl cat nginx

# Print the unit file and drop-ins defining a service.

List running services
systemctl list-units --type=service --state=running

# List active services managed by systemd.

Show logs for a service
journalctl -u nginx -n 100 --no-pager

# Read recent logs associated with one systemd unit.

Show logs for a PID
journalctl _PID=1234 -n 100 --no-pager

# Filter the journal by process ID.

## systemd Service Control
Start a service
sudo systemctl start nginx

# Start a service unit.

Stop a service
sudo systemctl stop nginx

# Stop a service unit gracefully.

Restart a service
sudo systemctl restart nginx

# Restart a service unit.

Reload a service
sudo systemctl reload nginx

# Ask a service to reload its configuration.

Send signal to service cgroup
sudo systemctl kill -s SIGKILL nginx

# Signal all or selected processes in a service cgroup.

Signal only main PID
sudo systemctl kill --kill-whom=main -s SIGUSR1 nginx

# Signal only the service main process.

Reload or restart if reload unsupported
sudo systemctl reload-or-restart nginx

# Use reload when available, else restart.

## Control Groups and Unit Trees
Show cgroup tree
systemd-cgls

# Display control groups and the processes inside them.

Top view for cgroups
systemd-cgtop

# Show top cgroups by CPU, memory, and I/O load.

Show user sessions
loginctl list-sessions

# Inspect active user sessions and seats under systemd-logind.

Inspect one session
loginctl show-session 2

# Inspect one logind session in detail.

Show service cgroup path
systemctl show -p ControlGroup nginx

# Reveal the cgroup path tied to a unit.

## Transient Units and Resource Controls
Run process in transient scope
systemd-run --scope htop

# Run an interactive process in its own transient scope unit.

Run transient service
systemd-run --unit=myjob --remain-after-exit /usr/bin/sleep 60

# Launch a one-off command as a transient service unit.

Set CPU quota on service
sudo systemctl set-property myjob.service CPUQuota=50%

# Apply runtime resource-control properties to a unit.

Set memory cap on service
sudo systemctl set-property myjob.service MemoryMax=1G

# Limit service memory through cgroup controls.

Recommended next

No recommendations yet.