Essential Linux command reference - filesystem, permissions, process management, disk usage, networking, and systemd for daily server work.
Move around and locate files quickly.
pwd ## print working directory
ls -lah /var/log/nginx/ ## list with size, hidden files
cd /var/log/nginx/ && cd - ## jump, then return to previous dir
find /var/log -name "*.log" -mtime -1 ## files modified in last 1 day
find / -size +100M 2>/dev/null ## files larger than 100MB
locate nginx.conf ## fast indexed search
which python3 ## show full path of a command
Parameter Breakdown:
ls -lah: Long format, human-readable sizes, includes hidden filesfind -mtime -1: Negative number means "within" the last N days2>/dev/null: Suppresses permission-denied errors when searching from /Copy, move, link, and remove files safely.
cp -r ./config /etc/orders-api/config ## copy directory recursively
mv old-report.csv archive/report.csv
rm -i sensitive-file.txt ## confirm before deleting
rm -rf /tmp/build-cache/ ## force recursive delete, no prompt
mkdir -p /opt/orders-api/{logs,config} ## create nested dirs in one shot
ln -s /opt/orders-api/current /opt/orders-api/latest
Parameter Breakdown:
-i: Interactive — prompts before overwrite or delete, good default for prod boxesmkdir -p: Creates parent directories as needed, no error if they existln -s: Symbolic link — points to a path, breaks if the target movesControl who can read, write, and execute.
chmod 644 app.conf ## rw-r--r--
chmod 755 deploy.sh ## rwxr-xr-x
chmod -R 750 /opt/orders-api/ ## recursive, owner+group only
chown deploy:deploy /opt/orders-api/ ## change owner and group
chgrp devops /var/log/orders-api/
umask 022 ## default permission mask for new files
Command Parameter Table:
| Value | Meaning |
|---|---|
644 |
Owner read/write, group and others read-only |
755 |
Owner full access, group and others read/execute |
750 |
Owner full access, group read/execute, others nothing |
Find, monitor, and control running processes.
ps aux | grep orders-api ## find a process by name
top ## live process viewer
htop ## improved interactive viewer
kill 4521 ## graceful terminate (SIGTERM)
kill -9 4521 ## force kill (SIGKILL)
pkill -f orders-api ## kill by name match
nice -n 10 ./batch-export.sh ## run with lower priority
jobs ## list background jobs in this shell
fg %1 ## bring job 1 to foreground
Parameter Breakdown:
kill -9: Last resort — bypasses cleanup, the process cannot trap or ignore itnice -n: Range is -20 (highest priority) to 19 (lowest); only root can go negativeps aux: a = all users, u = user-readable format, x = include no-tty processesCheck usage and manage mounted filesystems.
df -h ## disk space per filesystem
du -sh /var/log/* ## size per subdirectory
du -sh /opt/orders-api/ --max-depth=1
lsblk ## list block devices
mount | grep /data ## show mount details for /data
fdisk -l ## list partitions (needs root)
Parameter Breakdown:
df -h: Human-readable totals — first command when you get "no space left on device"du -sh: Summary, human-readable — use to find which directory is eating disklsblk: Tree view of disks and partitions, no root requiredDiagnose connectivity from the command line.
ip addr show ## list interfaces and IPs
ss -tulnp ## listening ports and owning process
curl -I https://api.razorpay.com/health ## headers only, fast health check
curl -o output.json https://api.example.com/data
wget https://example.com/release.tar.gz
ping -c 4 db.internal.razorpay.net ## 4 packets, then stop
traceroute api.razorpay.com ## hop-by-hop path
dig orders-api.payments.svc.cluster.local
Command Parameter Table:
| Flag | Description |
|---|---|
ss -tulnp |
TCP/UDP listening sockets with process name and PID |
curl -I |
HEAD request — checks status without downloading the body |
dig |
DNS lookup — shows resolved IP and which server answered |
Search, transform, and filter file content.
grep -r "ERROR" /var/log/orders-api/ ## recursive search
grep -i "timeout" app.log ## case-insensitive
grep -c "WARN" app.log ## count matching lines
sed 's/staging/production/g' config.yaml > config-prod.yaml
awk '{print $1, $4}' access.log ## print columns 1 and 4
cut -d',' -f2 report.csv ## extract field 2 from CSV
sort access.log | uniq -c | sort -rn ## frequency count, descending
Parameter Breakdown:
grep -c: Returns a count instead of the matching lines themselvessed 's/old/new/g': Global find-replace, prints to stdout unless -i is addedsort | uniq -c | sort -rn: Classic pattern for "most frequent line" analysisPackage files for transfer or backup.
tar -czvf backup-2026-06-19.tar.gz /opt/orders-api/ ## create gzipped archive
tar -xzvf backup-2026-06-19.tar.gz -C /restore/ ## extract to a directory
tar -tzvf backup-2026-06-19.tar.gz ## list contents, no extract
zip -r config-backup.zip ./config/
unzip config-backup.zip -d ./restored/
gzip large-export.csv ## compress in place
gunzip large-export.csv.gz
Parameter Breakdown:
-czvf: Create, gzip, verbose, file — the standard combo for backups-xzvf: Extract, gzip, verbose, file — the matching restore combo-C: Extracts into a target directory instead of the current oneCheck load and resource health.
uptime ## load average + how long up
free -h ## memory usage, human-readable
vmstat 2 5 ## 5 samples, 2 seconds apart
iostat -x 2 ## disk I/O stats every 2 seconds
dmesg -T | tail -50 ## recent kernel messages, timestamped
journalctl -p err -since "1 hour ago" ## recent error-level logs
Parameter Breakdown:
uptime: The three load numbers are 1, 5, and 15-minute averagesfree -h: Watch the available column, not just free — it accounts for reclaimable cachedmesg -T: -T converts raw timestamps into human-readable datesControl and inspect services on modern Linux distros.
systemctl status orders-api
systemctl start orders-api
systemctl stop orders-api
systemctl restart orders-api
systemctl enable orders-api ## start automatically on boot
systemctl disable orders-api
journalctl -u orders-api -f ## stream logs for one service
journalctl -u orders-api --since today
Parameter Breakdown:
enable vs start: enable controls boot behavior, start controls right now — they're independentjournalctl -u: Filters the systemd journal to one unit's logs only-f: Follows the log in real time, same idea as tail -fShortcuts worth adding to .bashrc.
alias ll='ls -lah'
alias ports='ss -tulnp'
alias df='df -h'
alias du='du -h'
## Find and kill whatever is listening on a port
lsof -i :8080 | awk 'NR==2{print $2}' | xargs kill -9
## Top 10 largest directories under current path
du -ah . | sort -rh | head -10
## Watch a log file with color-highlighted errors
tail -f app.log | grep --color=always -E "ERROR|$"