What Happens When You Type a URL and Press Enter
DNS lookups, TCP and TLS handshakes, HTTP requests, servers, and the browser's rendering pipeline. The whole journey of a web page, explained so it finally clicks.
Read →Servers, containers and CI all speak Linux. The commands you'll actually use for files, searching, processes, logs, permissions and networking, plus pipes that turn small tools into superpowers.
Even if you develop on Windows or macOS, your code almost certainly runs on Linux: in a container, on a VPS, inside a CI runner. Sooner or later you'll SSH into a server at an awkward moment with something broken. Knowing a few dozen commands turns that from panic into a short checklist.
pwd # where am I?
ls -la # list files, including hidden ones, with details
cd /var/www/app # change directory
cd .. # up one level
cd ~ # home directory
cd - # back to the previous directory
Use Tab to autocomplete paths. It saves time and typos.
mkdir -p logs/archive # create nested directories
touch notes.txt # create an empty file
cp config.example config # copy
mv old.txt new.txt # move or rename
rm file.txt # delete (no recycle bin!)
rm -r folder/ # delete a directory and its contents
rm is permanent. Double-check paths, especially with -r and anything involving *.
cat package.json # print the whole file
less app.log # scroll through big files (q to quit, / to search)
head -n 20 app.log # first 20 lines
tail -n 50 app.log # last 50 lines
tail -f app.log # follow new lines as they're written
tail -f on a log file while reproducing a bug is one of the most useful debugging moves on a server.
grep "ERROR" app.log # lines containing ERROR
grep -i "timeout" app.log # case-insensitive
grep -rn "DATABASE_URL" . # recursive, with line numbers
find . -name "*.log" -mtime +7 # .log files older than 7 days
The | symbol sends one command's output into another. This is where the command line gets powerful:
# How many errors today?
grep "ERROR" app.log | wc -l
# Top 10 IP addresses hitting the server
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head
# Find the process using the most memory
ps aux --sort=-%mem | head -5
Redirection saves output to files: > overwrites, >> appends, and 2>&1 includes errors.
ls -l deploy.sh # -rwxr-xr-x owner/group/others permissions
chmod +x deploy.sh # make executable
chmod 600 ~/.ssh/id_ed25519 # owner read/write only (required for SSH keys)
chown www-data:www-data uploads/ # change owner
sudo command # run as administrator
"Permission denied" is usually one of three things: the file isn't executable, the wrong user owns it, or you need sudo. Avoid chmod 777; it gives everyone full access and is almost never the right fix.
ps aux | grep node # find running Node processes
top # live view of CPU and memory (htop is nicer if installed)
kill 12345 # ask a process to stop
kill -9 12345 # force it (last resort)
"Port already in use"? Find what's holding it:
sudo lsof -i :3000
# or
sudo ss -ltnp | grep 3000
A full disk causes bizarre errors: failed writes, crashed databases, broken deploys.
df -h # free space per disk
du -sh * # size of each item in the current directory
du -sh /var/log/* # find which logs are huge
Old logs, Docker images and build artefacts are the usual culprits. (docker system prune cleans unused Docker data, but read the prompt first.)
Most Linux servers use systemd to run long-lived services:
sudo systemctl status nginx # is it running?
sudo systemctl restart myapp # restart a service
sudo systemctl enable myapp # start on boot
journalctl -u myapp -f # follow a service's logs
journalctl -u myapp --since "1 hour ago"
curl -I https://example.com # response headers only
curl -s localhost:3000/health # is the app answering locally?
ping example.com # basic reachability
dig example.com +short # DNS lookup
ss -ltnp # which ports are listening
Testing localhost from the server itself quickly tells you whether a problem is the app or something in front of it, like Nginx, a firewall or DNS. (DNS explained.)
ssh deploy@203.0.113.10 # log in
scp backup.dump deploy@server:/tmp/ # copy a file to the server
Use SSH keys, not passwords. (SSH keys explained.)
history and Ctrl+R to search previous commands.sudo, rm -rf or curl ... | bash.man command or command --help for options.Ready to use these for real? Try deploying a Node.js app to a VPS.
Navigation (cd, ls), file operations (cp, mv, rm), reading files (cat, less, tail -f), searching (grep, find), permissions (chmod, chown), processes (ps, kill), disk usage (df, du), services (systemctl, journalctl) and networking (curl, ss, ssh).
Run sudo lsof -i :PORT or sudo ss -ltnp | grep PORT to see which process is listening on that port.
Yes. Use WSL (Windows Subsystem for Linux) to run a real Linux environment, or Git Bash for many common commands.
DNS lookups, TCP and TLS handshakes, HTTP requests, servers, and the browser's rendering pipeline. The whole journey of a web page, explained so it finally clicks.
Read →There are dozens of HTTP status codes, but about fifteen cover nearly everything. What each one means, when to return it, and the mix-ups (401 vs 403, 301 vs 302) that confuse everyone.
Read →A, AAAA, CNAME, MX, TXT and NS records in plain English, why DNS changes seem slow, and the troubleshooting commands that tell you what is really going on.
Read →