Linux tricks, one-liners & shell magic

#!/bin/vpp.dk

Community Linux tricks, one-liners & shell scripts — searchable & formatted.

Category: process-management — 3 trick(s)

+ Add a New Trick

List all systemd services and their current status on modern Linux systems.
bash
$ systemctl list-units --type=service --state=running # Full list including inactive: systemctl list-units --type=service
Delete this trick? This cannot be undone.
Quickly find the PID of a running process and kill it — no need to first run ps and note the ID manually.
bash
$ kill $(pgrep -f process_name) # Or with a signal: kill -9 $(pgrep -f process_name)
Delete this trick? This cannot be undone.
The watch command re-runs a command at a set interval and displays the output — great for monitoring.
bash
$ # Refresh every 2 seconds (default): watch df -h # Every 0.5 seconds, highlight differences: watch -n 0.5 -d 'free -m'
Delete this trick? This cannot be undone.