Linux web01 5.15.0-94-generic #104-Ubuntu SMP x86_64 GNU/Linux
Note -a shows all info. -r shows kernel release. -s shows kernel name. -m shows architecture (x86_64, aarch64). Useful in scripts that need to detect the OS: if [[ $(uname -s) == 'Darwin' ]]; then ... (macOS) fi.
kernel versionos infosystem infolinux versionarchitecturedetect os
Disk Space Usage
syntax
df [options] [filesystem]
example
df -h
df -h /
df -hT
output
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 50G 32G 16G 67% /
/dev/sdb1 xfs 200G 145G 55G 73% /data
Note -h for human-readable sizes. -T shows filesystem type. -i shows inode usage (you can run out of inodes even with free space if you have millions of tiny files). Check df regularly on servers to prevent disk-full outages.
disk spacecheck storagedisk usagefree spacefilesystemdisk full
Directory Size
syntax
du [options] [directory]
example
du -sh /var/log/
du -h --max-depth=1 /opt/ | sort -rh
du -sh ~/projects/*
Note -s shows total for each argument (summary). -h is human-readable. --max-depth limits how deep to report. Combining with sort -rh quickly identifies what is consuming the most space.
directory sizefolder sizewhat is using spacedisk usage by folderlargest directories
Memory Usage
syntax
free [options]
example
free -h
output
total used free shared buff/cache available
Mem: 16Gi 5.2Gi 2.1Gi 312Mi 8.7Gi 10Gi
Swap: 4.0Gi 128Mi 3.9Gi
Note -h for human-readable. The 'available' column is the best indicator of how much memory is actually free for applications (it includes reclaimable buffer/cache). Linux aggressively caches, so low 'free' is normal and does not mean you are out of memory. Not available on macOS; use vm_stat instead.
Note Load averages are for the last 1, 5, and 15 minutes. On a single-core system, a load of 1.0 means it is fully utilized. On a 4-core system, a load of 4.0 is fully utilized. Consistently high load relative to core count indicates the server needs investigation.
uptimesystem loadload averagehow long runningserver uptime
Note whoami prints just the username. id shows uid, gid, and all group memberships. Useful in scripts to verify you are running as the expected user: if [[ $(whoami) != 'root' ]]; then echo 'Run as root'; exit 1; fi.
current userwho am iuser groupsuser idcheck user
Environment Variables
syntax
env
export VAR=value
printenv VAR
example
env | grep PATH
export DATABASE_URL='postgres://user:pass@db:5432/mydb'
printenv HOME
output
/home/deploy
Note env lists all environment variables. export makes a variable available to child processes. Variables set without export are local to the current shell. printenv retrieves a single variable. Avoid putting secrets in environment variables on shared systems; prefer a secrets manager.
date
date '+%Y-%m-%d %H:%M:%S'
date -d '+7 days''+%Y-%m-%d'
date -u
output
Sat Apr 4 14:22:01 UTC 2026
2026-04-04 14:22:01
2026-04-11
Note Common format tokens: %Y (year), %m (month), %d (day), %H (hour), %M (minute), %S (second), %s (Unix epoch). -d adjusts the date (GNU only; on macOS use -v). -u outputs UTC. Useful for timestamped filenames: backup_$(date +%Y%m%d_%H%M%S).tar.gz.
current dateformat datetimestampunix epochdate calculation
CPU Information
syntax
lscpu
example
lscpu
output
Architecture: x86_64
CPU(s): 8
Model name: Intel(R) Core(TM) i7-10700 @ 2.90GHz
Thread(s) per core: 2
Core(s) per socket: 4
Note Shows CPU architecture, core count, threads, cache sizes, and more. On macOS, use sysctl -n machdep.cpu.brand_string and sysctl -n hw.ncpu instead.
cpu infoprocessor detailscore countcpu architecturehow many cores
Note -f shows filesystem type, label, UUID, and mount points. Useful for identifying disks before mounting or partitioning. Linux only; on macOS, use diskutil list.
list disksblock devicespartitionsdisk layoutmount points