opscape

System and users cheat sheet

The most useful system and users commands on one printable page, every line checked by running it.

cal Print a calendar for a month, a few months, or a whole year.

cal 2 2026
Show a specific month output
cal -3
Show last, this and next month output
ncal -bM 2 2026
Start weeks on Monday output

date Print the current date and time in any format, or convert and calculate dates.

date '+%Y-%m-%d %H:%M:%S'
Print a date in a custom format output
date +%s
Get the current Unix timestamp output
date -u -d @1700000000 date -u -d @1700000000 +%F
Convert a Unix timestamp to a date output
date -d '2026-03-14 08:00:01 UTC' +%s
Convert a date to a Unix timestamp output
date -d '2026-03-14 +3 days' +%F date -d '2026-03-14 -2 weeks' +%F date -d '2026-01-31 +1 month' +%F date -d '2026-03-14 08:00 UTC +90 minutes' '+%F %H:%M'
Calculate relative dates output

env Print the environment, or run a command with a modified environment.

env GREETING=hello bash -c 'echo "$GREETING from a child"' echo "parent sees: ${GREETING:-nothing}"
Run a command with an extra variable output
env -u EDITOR printenv EDITOR; echo "exit: $?"
Remove a variable for one command output
env -i bash -c 'env'
Run a command with an empty environment output
chmod +x strict.sh; ./strict.sh
Pass options in a shebang with env -S output

free Show how much RAM and swap is in use, free, and available to new programs.

free -h
Show memory in readable units output
free -h -s 1 -c 3
Sample memory a few times output
free -m | awk '/^Mem:/ { print $7 }'
Get available memory as a number for a script output

groups Print the groups the current user, or each named user, belongs to.

groups
List your own groups output
groups root
List another user's groups output
getent group sudo users
See who is in a group output

id Print the user and group IDs of the current user or of a named user.

id
Show your user and groups output
id -u
Print just the numeric user ID output
id -Gn root
List all group names, space-separated output
if id deploy >/dev/null 2>&1; then echo "deploy exists"; else echo "no deploy user"; fi id deploy
Check whether an account exists output

journalctl Read and filter the systemd journal, the log store for services, the kernel and the boot process.

journalctl -u nginx
Show the logs of one service output
journalctl -u nginx -f
Follow a service's log live output
journalctl -b journalctl -b -1 -e journalctl --list-boots
Show messages from the current or previous boot output
journalctl -u nginx --since '2026-03-14 08:00' --until '2026-03-14 09:00' journalctl --since '1 hour ago' journalctl --since today
Show a time window output

printenv Print all environment variables, or the values of the ones you name.

printenv HOME
Print one variable's value output
printenv DATABASE_URL; echo "exit: $?"
Ask for a variable that is not set output
region=eu-west printenv region || echo "not exported yet" export region printenv region
See the difference between a shell variable and an exported one output

systemctl Start, stop, enable and inspect services and other units managed by systemd.

systemctl status nginx
Check whether a service is running output
sudo systemctl enable --now nginx
Start a service now and at every boot output
if systemctl is-active --quiet nginx; then echo "nginx is up" else echo "nginx is down" >&2 fi
Test a service's state in a script output
systemctl list-units --failed
List units that have failed output

uname Print the kernel name, release and version, the hostname, and the machine hardware type.

uname -a
Print everything at once output
uname -r
Show the kernel release output
uname -m
Show the CPU architecture output

uptime Show how long the system has been running, how many users are logged in, and the load averages.

uptime
Show uptime and load at a glance output
uptime -p
Print only the running time, in words output
uptime -s
Show when the system booted output

vmstat Report processes, memory, swap, I/O and CPU activity, once or at a regular interval.

vmstat 1 3
Sample once a second, three times output
vmstat -y 1 2
Skip the since-boot line output
vmstat -t -y 1 2
Timestamp each line for a log output

whoami Print the user name of the effective user ID the current process runs as.

whoami
Print who you are output
id -un
Get the same answer from id output