Free tool · No sign-up

Shell Command Cheat Sheet

The 40 commands you'll use most when running a server, all in one place. Every command is one-click copyable, and below are 7 animated terminal demos — watch how a command runs first, then type it yourself.

Small print: terminal demos show simulated output, but the commands are real — just type them. IPs and paths in the demos are examples.

Files & Directories5 commands

pwd

Show which directory you're in — run this first when you're lost

ls -lah

List files with details: permissions, sizes, timestamps

cd /var/www

Switch to a directory; cd - takes you back to the previous one

mkdir -p /var/www/myapp

Create a directory; -p creates missing parents along the way

cp -r old/ new/

Copy a whole directory — back up configs with this before editing

View & Search Text5 commands

cat Caddyfile

Print a small file's whole content at once

less /var/log/syslog

Browse big files: space to page, / to search, q to quit — safer than cat

grep -rn "TODO" .

Recursively search all files under this directory for TODO; -n shows line numbers

grep -i "error" app.log

Case-insensitive search for error — the go-to when hunting log failures

tail -n 50 app.log

Show the last 50 lines of a file; you usually only care about the tail of logs

Permissions & Users5 commands

chmod 600 ~/.ssh/id_ed25519

Private keys must be readable only by you, or SSH refuses to use them

chmod +x deploy.sh

Make a script executable so you can run it with ./deploy.sh

chown -R www-data:www-data /var/www

Hand your website directory back to the user running the site

sudo -i

Temporarily become root — safer than logging in as root all the time

adduser deploy

Create a regular user for daily work; stop doing everything as root

Processes & System6 commands

ps aux | grep node

Find running node processes — confirm the service is actually up

kill 812

Politely end a process (replace 812 with the PID from ps); use kill -9 only if that fails

top

Watch in real time who's eating CPU and memory; press q to quit

df -h

Check remaining disk space — look here first when the site returns 500

free -h

Check memory usage; build failures on tiny 1-core boxes are usually memory

uptime

See how long the box has been up and the average load — is it slow or just you?

Network Diagnosis5 commands

curl -I https://example.com

Fetch only HTTP response headers — is the site up, is the status code right?

ping -c 4 8.8.8.8

Test network connectivity; -c 4 sends just 4 packets then stops

ss -tlnp

Show which ports are listening — see at a glance whether the service really started

curl ifconfig.me

Look up this machine's public IP — needed when setting DNS

dig example.com +short

Check which IP a domain resolves to — has the DNS change taken effect?

Compress & Extract4 commands

tar -czvf backup.tar.gz /var/www

Pack and compress the site directory — one-liner backup

tar -xzvf backup.tar.gz

Unpack the backup above — use it when restoring

zip -r site.zip .

Make a zip archive — handy for sharing or downloading locally

unzip site.zip -d /tmp/restore

Extract a zip into a target directory without polluting the current one

Package Management5 commands

apt update && apt upgrade -y

Update package lists and upgrade on Ubuntu — first thing on a fresh server

apt install -y curl git htop

Install everyday tools; -y skips the install confirmation

node -v && npm -v

Confirm node is installed and the version is the one you expect

which node

Find where node is actually installed — check this first when versions get confusing

timedatectl set-timezone Asia/Shanghai

Set the timezone to Shanghai so log timestamps make sense

Log Troubleshooting5 commands

systemctl status nginx

When a service dies, look here first: active or failed?

journalctl -u nginx --no-pager -n 50

Last 50 lines of nginx logs — hunt the error message

journalctl -f -u myapp

Follow one service's logs live; Ctrl+C to quit

tail -n 100 -f /var/log/nginx/error.log

Live nginx error log — check here first for 502s

dmesg | tail -n 30

Kernel log — find evidence here when the system kills processes (OOM)

Terminal animation demos

We picked the 7 commands most worth watching. Scroll to them and they auto-play: first how the command is typed, then what the output looks like, and finally a "watch here" note telling you which column to look at. Then grab the command above and use it.

ls -lah: file details

root@vps:~#

👀 Note:The first column is permissions (lines starting with d are directories); the fifth is file size. -h shows human-readable K, M units. Notice id_ed25519 is -rw------- — readable only by you, which is exactly how an SSH key should be.

df -h: disk space

root@vps:~#

👀 Note:Watch the Use% column. Over 80% means clean up logs and caches; at 100% the site returns 500 — run df -h before touching anything.

ps aux | grep node: find a process

root@vps:~#

👀 Note:The second column, 812, is the process ID — kill 812 if the service is stuck. The last line is the grep command itself; ignore it.

tail -f: follow logs live

root@vps:~#

👀 Note:-f keeps waiting and scrolls as new logs arrive — that scrolling is simulated above. When tracking down a problem, keep a window tailing the log; Ctrl+C to quit.

curl -I: is the site up?

root@vps:~#

👀 Note:Only the first line matters — 200 means it's up; 301/302 are redirects; 404 means no such page; 502 usually means the backend service didn't start.

chmod 600: fix SSH key permissions

root@vps:~#
root@vps:~#

👀 Note:chmod succeeds silently — no news is good news. Now verify:

👀 Note:Permissions are now -rw------- — readable only by you, which is what SSH requires. If it's -rw-r--r--, login will be rejected.

systemctl status: is the service alive?

root@vps:~#

👀 Note:Just read the Active line — active (running) means alive, failed means dead. If it's dead, don't restart right away; scroll down into the logs to find out why it died.

Want to learn properly? The blog has matching hands-on guides: "10 things to do first on a new VPS", "Caddy reverse proxy: add HTTPS to your site in 5 minutes", "systemd daemons: restart the service automatically when it dies" — visit the blog →

Shell Command Cheat Sheet · Free · EazyOPC