Linux command line basics
Why it matters: Performance-based questions and real security work often use a terminal. A few dozen commands cover most needs.
Overview
Supplementary — not from your PDFMost servers, network devices and security tools run on Linux. These are the commands used throughout the Practice Labs. Try them in your own practice VM.
Everyday commands
| Command | What it does |
|---|---|
pwd, ls -la, cd | Where am I, list files with permissions, change directory |
cat, less, head, tail -f | Read files; tail -f follows a growing log |
grep -i pattern file | Find matching lines (case-insensitive) |
find /path -name '*.log' | Find files by name |
chmod 640 file, chown user:group file | Change permissions and ownership |
sudo command | Run one command with elevated rights |
ps aux, top, kill PID | See and stop processes |
ip addr, ip route | Network interfaces and routes |
ss -tulpn | Listening ports and the processes that own them |
journalctl -u ssh --since today | Service logs from systemd |
sha256sum file | Compute a file's hash |
sudo apt update && sudo apt upgrade | Patch a Debian/Ubuntu system |
Reading permissions
-rwxr-x---= file type, then owner (rwx), group (r-x) and others (---).- In octal: r=4, w=2, x=1, so
750= rwx for the owner, r-x for the group, nothing for others. - Directories need
xto be entered.chmod 700 ~/.sshkeeps SSH keys private.