Every standard command: the complete cross-platform terminal reference

general / published / guide #75 / ≈ 17 min read

The essential-commands guide is the short list — the few dozen commands you use every day. This is the long list: a categorised reference of the standard command-line tools on Unix-like systems (Linux, the BSDs, macOS) and on Windows (both the legacy Command Prompt and modern PowerShell). You will not memorise all of these. The point of a reference is the opposite of memorising: you skim it once so you know a tool exists, then come back and copy the example when you need it.

How to read this guide:

  • Each section is a table: the command, what it does, and a copy-paste example.
  • Sections 1–17 are the Unix world (Linux/BSD/macOS). Sections 18–20 cover Windows.
  • Most Unix tools here are part of POSIX or the GNU coreutils / util-linux packages shipped by every distribution. A handful (htop, tree, zstd, rg, nmcli, tldr) are popular add-ons you may need to install — they are marked (install).
  • Anything in <angle-brackets> is a placeholder you substitute. Commands needing root are shown with sudo.

1. Navigating the filesystem

Where am I, what is here, and how do I move around.

Command What it does Example
pwd Print the current (working) directory. pwd
cd Change directory. No argument goes home; - goes back. cd /etc · cd ~ · cd -
ls List directory contents. ls -lah
dir / vdir GNU aliases for ls with preset formats. vdir
tree (install) Show the directory hierarchy as an indented tree. tree -L 2
pushd / popd Change directory but remember the old one on a stack. pushd /tmp · popd
dircolors Set up the LS_COLORS used by ls --color. eval "$(dircolors -b)"

2. Files and directories

Create, copy, move, delete, link, and inspect files. Handle rm with respect: there is no recycle bin.

Command What it does Example
cp Copy files or directories (-r for directories). cp -r src/ dst/
mv Move or rename. mv old.txt new.txt
rm Delete files (-r recursive, -i ask first). rm -i file.txt
mkdir Make directories (-p makes parents). mkdir -p a/b/c
rmdir Remove empty directories. rmdir olddir
touch Create an empty file or update its timestamp. touch file.txt
ln Make links: -s for a symbolic link. ln -s /opt/app/bin app
readlink Show where a symlink points. readlink -f ./app
realpath Resolve a path to its absolute, canonical form. realpath ../x
basename / dirname Strip the directory / strip the filename from a path. basename /a/b.txt
stat Show full metadata: size, owner, timestamps, inode. stat file.txt
file Identify a file’s type by content, not name. file mystery.bin
mktemp Create a uniquely-named temp file or directory safely. mktemp -d
install Copy files and set mode/owner in one step. install -m 755 x /usr/local/bin
shred Overwrite a file so it is hard to recover, then delete. shred -u secret.key
truncate Shrink or extend a file to an exact size. truncate -s 0 log.txt
rename Bulk-rename via a pattern (Perl rename on many distros). rename 's/.txt$/.md/' *.txt
mkfifo Create a named pipe (FIFO) for inter-process streams. mkfifo mypipe

3. Viewing and dissecting file content

Read files whole, page through them, peek at the ends, or crack them open byte by byte.

CommandWhat it doesExample
catConcatenate / dump a file to the screen.cat file.txt
tacLike cat but bottom-to-top (reversed lines).tac file.txt
less / morePage through a file (q quits, / searches).less /var/log/syslog
head / tailFirst / last N lines. tail -f follows a growing file.tail -f app.log
nlNumber the lines of a file.nl script.sh
teeCopy stdin to a file and to the screen.make 2>&1 | tee build.log
odOctal/hex dump of raw bytes.od -c file.bin
hexdump / xxdHex view of a file (and back, with xxd -r).xxd file.bin | head
stringsPull printable text out of a binary.strings /bin/ls | less
split / csplitSplit a file into pieces by size/lines or by pattern.split -b 10M big.iso part_
foldWrap long lines to a fixed width.fold -w 72 essay.txt
fmt / prReformat / paginate text for reading or printing.fmt -w 80 notes.txt

4. Finding things

Locate files by name or attribute, and search inside them. For the deep dive on find, xargs, and safely handling odd filenames, see the find, xargs, and the -print0 dance guide.

Command What it does Example
find Walk a directory tree filtering by name, type, age, size… find . -name "*.log" -mtime -7
locate / updatedb Instant name search from a prebuilt index; refresh with updatedb. locate sshd_config
which Show the path of the executable that would run. which python3
whereis Locate the binary, source, and man page for a command. whereis ls
type Is it a builtin, alias, function, or binary? type cd
grep Search inside files for lines matching a pattern. grep -rin "error" .
rg (install) ripgrep: a much faster, gitignore-aware recursive grep. rg "TODO"

5. Processing and transforming text

The heart of the Unix philosophy: small tools that filter streams. For the two big ones, see awk in ten minutes and sed in ten minutes.

CommandWhat it doesExample
awkField-oriented mini-language for columns and reports.awk -F, '{print $2}' data.csv
sedStream editor: substitute, delete, insert by pattern.sed 's/old/new/g' file
cutExtract columns by delimiter or character position.cut -d: -f1 /etc/passwd
pasteMerge lines of files side by side.paste names.txt ages.txt
joinRelational join of two sorted files on a key.join a.txt b.txt
sortSort lines (-n numeric, -h human sizes, -r reverse).du -sh * | sort -h
uniqCollapse or count adjacent duplicate lines.sort f | uniq -c
commCompare two sorted files line by line (common/unique).comm -23 a.txt b.txt
trTranslate or delete characters.tr a-z A-Z < file
wcCount lines, words, and bytes.wc -l file.txt
expand / unexpandConvert tabs to spaces and back.expand -t4 code.py
columnFormat input into neat aligned columns.column -t -s, data.csv
diff / diff3Show differences between two (or three) files.diff -u old new
cmpByte-for-byte comparison; reports the first difference.cmp a.bin b.bin
patchApply a diff/patch to files.patch -p1 < fix.patch
revReverse the characters of each line.echo abc | rev
exprEvaluate a simple arithmetic/string expression.expr 3 + 4
seqPrint a sequence of numbers.seq 1 10
shufShuffle lines / pick a random selection.shuf -n1 names.txt
numfmtConvert numbers to/from human-readable units.numfmt --to=iec 1048576
printfFormatted output (more predictable than echo).printf '%s=%d ' x 5
yesRepeat a string forever (to feed prompts).yes | rm -ri junk/

6. Archives and compression

Bundle directories and squeeze them. Remember tar’s flags: create, extract, t=list, file, z=gzip, j=bzip2, J=xz.

CommandWhat it doesExample
tarCreate/extract archives, optionally compressed.tar -czf out.tgz dir/
gzip / gunzip / zcatCompress / decompress / view a single .gz file.gzip -k big.log
bzip2 / bunzip2Slower but tighter compression than gzip.bzip2 dump.sql
xz / unxzVery high compression ratio (slow).xz -9 archive.tar
zstd (install)Modern compressor: near-gzip ratio at very high speed.zstd -19 file
zip / unzipWindows-compatible zip archives.zip -r site.zip site/
cpioOld-school archiver, still used by initramfs/RPM.find . | cpio -o > a.cpio
arCreate/extract .a static-library and .deb archives.ar t libfoo.a
ddBlock-level copy: images, disks, exact byte transfers.sudo dd if=img.iso of=/dev/sdX bs=4M status=progress

7. Permissions and ownership

Who can read, write, and execute what. For the full mental model (including the sticky bit and setgid), see permissions, ownership, and the sticky bit.

Command What it does Example
chmod Change permission bits (symbolic or numeric). chmod 755 script.sh
chown Change the owning user (and group). sudo chown alice:staff f
chgrp Change only the owning group. sudo chgrp wheel f
umask Show/set default permissions for new files. umask 022
getfacl / setfacl Read/write fine-grained POSIX access control lists. setfacl -m u:bob:rw f
chattr / lsattr Set/list extended ext-fs attributes (e.g. immutable). sudo chattr +i important

8. Users, groups, and identity

Who you are, who else is here, and how to become someone else. For account management end to end, see users, groups, and sudo.

Command What it does Example
whoami Print your current username. whoami
id Show your UID, GID, and group memberships. id
groups List the groups you belong to. groups
who / w Who is logged in (and what they are doing). w
last Show recent login history. last -10
su Switch to another user (root by default). su - alice
sudo Run a single command as root (or another user). sudo systemctl restart sshd
passwd Change a password. passwd
useradd / usermod / userdel Create / modify / delete user accounts. sudo useradd -m bob
groupadd / newgrp Create a group / switch your active group. sudo groupadd devs
chsh / chfn Change your login shell / your contact (GECOS) info. chsh -s /bin/zsh

9. Processes and jobs

See what is running, control it, and keep it alive. Deeper material in processes and system monitoring.

Command What it does Example
ps Snapshot of running processes. ps aux
top Live, updating process viewer. top
htop (install) Friendlier, colourful interactive top. htop
pgrep / pidof Find process IDs by name. pgrep -f nginx
kill Send a signal to a PID (default: ask it to quit). kill -9 1234
pkill / killall Signal processes by name. pkill firefox
nice / renice Start / change a process’s scheduling priority. nice -n 19 backup.sh
nohup Run a command that survives logout. nohup ./worker &
jobs / fg / bg List / foreground / background shell jobs. jobs · fg %1
disown Detach a job from the shell so it survives exit. disown -h %1
wait Block until background jobs finish. wait
time Measure how long a command takes. time make
timeout Kill a command if it runs too long. timeout 30 ./slow
watch Re-run a command every N seconds. watch -n1 df -h
fuser / lsof Find which process holds a file/port open. sudo lsof -i :443
strace (install) Trace the system calls a process makes. strace -f ./app

10. System information and hardware

Facts about the machine: kernel, CPU, memory, disks, devices.

CommandWhat it doesExample
unameKernel name, version, and architecture.uname -a
hostnameShow or set the machine’s name.hostname
uptimeHow long up, plus load average.uptime
date / calCurrent date/time / a calendar.date +%F · cal
dfFree space per mounted filesystem.df -h
duDisk used by files/directories.du -sh *
freeMemory and swap usage (Linux).free -h
vmstat / iostatLive virtual-memory / IO statistics.vmstat 1
lscpuCPU model, cores, cache, flags.lscpu
lsblkTree of block devices and partitions.lsblk -f
lsusb / lspciList USB / PCI devices.lspci | grep -i vga
dmidecodeRead hardware details from the BIOS/SMBIOS.sudo dmidecode -t memory
sysctlRead/set kernel parameters at runtime.sysctl vm.swappiness
dmesgKernel ring-buffer messages (boot, hardware, drivers).dmesg -w
lsmodList loaded kernel modules.lsmod | grep snd
env / printenvShow the environment variables.printenv PATH

11. Disks, partitions, and filesystems

Partition, format, mount, and check storage. Mistakes here can erase data — double-check the device name. See disks: lsblk, fdisk, mkfs, fstab, UUIDs and filesystems explained.

Command What it does Example
mount / umount Attach / detach a filesystem. sudo mount /dev/sdb1 /mnt
fdisk / parted Create and edit a partition table. sudo fdisk -l
mkfs Create (format) a filesystem. sudo mkfs.ext4 /dev/sdb1
fsck Check and repair a filesystem (unmounted). sudo fsck /dev/sdb1
blkid Show UUIDs and types of block devices. blkid
sync Flush pending disk writes to hardware. sync
swapon / swapoff Enable / disable swap space. sudo swapon -a
tune2fs Tune ext2/3/4 parameters (labels, reserved blocks). sudo tune2fs -l /dev/sda1
badblocks Scan a device for bad sectors. sudo badblocks -sv /dev/sdb

12. Networking

Reach other machines, move files, and inspect connections. See networking basics, SSH the boring way, and rsync without losing data.

Command What it does Example
ping Is a host reachable? Measure round-trip time. ping -c4 example.com
curl Transfer data to/from URLs (HTTP, FTP, …). curl -L https://x.test
wget Download files (good at resuming/mirroring). wget -c big.iso
ssh Secure shell into another machine. ssh user@host
scp / sftp Copy files over SSH. scp f user@host:/tmp/
rsync Efficient incremental file sync (local or remote). rsync -avz src/ host:/dst/
nc (netcat) Raw TCP/UDP: test ports, move data, simple servers. nc -vz host 22
ip Modern Linux net config: addresses, routes, links. ip addr
ifconfig Legacy interface config (still default on BSD/macOS). ifconfig
ss / netstat List sockets and connections. ss -tulpn
traceroute / tracepath Show the network hops to a host. traceroute example.com
dig / host / nslookup Query DNS. dig +short example.com
arp Show the ARP table (IP↔MAC mapping). arp -a
tcpdump Capture and inspect network packets. sudo tcpdump -i any port 53
nmcli (install) Control NetworkManager from the terminal. nmcli device wifi list

13. Shell builtins and control flow

These are part of the shell itself (bash/zsh), not separate programs — which is why man cd fails but help cd works.

CommandWhat it doesExample
echoPrint arguments to stdout.echo "hi"
exportMark a variable for the environment of child processes.export PATH="$PATH:~/bin"
alias / unaliasMake / remove a command shortcut.alias ll='ls -lah'
source / .Run a script in the current shell (keeps its vars).source ~/.bashrc
execReplace the shell with another program.exec bash
evalEvaluate a string as a command.eval "$(ssh-agent)"
set / unsetSet shell options / variables, or remove variables.set -euo pipefail
readRead a line of input into variables.read -p "Name: " n
test / [Evaluate a condition (files, strings, numbers).[ -f file ] && echo yes
true / falseDo nothing, succeed / fail (for loops and defaults).while true; do :; done
historyShow or search your command history.history | grep ssh
trapRun code on a signal or on exit.trap cleanup EXIT
exitLeave the shell with a status code.exit 0
command / hash / ulimitBypass aliases / cache lookups / set resource limits.ulimit -n 4096
getoptsParse option flags inside a shell script.while getopts ":v" o; do ...

14. Scheduling and services

Run things later, on a schedule, or as managed background services. See cron and systemd timers.

CommandWhat it doesExample
crontabEdit/list your scheduled (cron) jobs.crontab -e
at / atq / atrmRun a command once at a future time; list/remove.echo "reboot" | at 2am
batchRun a job when system load is low.batch < job.sh
sleepPause for a duration.sleep 5
systemctlManage systemd services (start/stop/enable/status).systemctl status sshd
journalctlQuery the systemd journal (logs).journalctl -u nginx -f
serviceLegacy/portable wrapper to start/stop services.sudo service cron restart

15. Terminal and session control

Tidy and reconfigure the terminal itself — including clear, the everyday command missing from the short guide.

Command What it does Example
clear Clear the screen (same as Ctrl+L). clear
reset Fully reinitialise a terminal mangled by binary output. reset
tput Query/set terminal capabilities (colours, cursor). tput cols
stty Show/change terminal line settings. stty -echo
tty Print the terminal device you are attached to. tty
script Record everything in a session to a file. script session.log
setterm Set terminal attributes (blanking, bold, colour). setterm --blank 0
locale Show/set language and character-encoding settings. locale
tmux / screen (install) Terminal multiplexer: persistent, splittable sessions. tmux new -s work

For the full multiplexer workflow, see tmux in twenty minutes.

16. Maths, encoding, and miscellany

Calculators, hashes, encoders, and the odd-but-useful utilities.

CommandWhat it doesExample
bc / dcArbitrary-precision calculators (infix / RPN).echo "2^10" | bc
unitsConvert between units of measure.units "10 mi" km
xargsBuild and run commands from input items.find . -name "*.bak" | xargs rm
envRun a command with a modified environment.env FOO=1 ./app
base64 / base32Encode/decode binary as text.base64 file > file.b64
md5sum / sha256sumCompute/verify file checksums.sha256sum download.iso
cksumCRC checksum and byte count.cksum file
uuidgenGenerate a random UUID.uuidgen
gpgEncrypt, decrypt, and sign with OpenPGP.gpg -c secret.txt
opensslSwiss-army crypto: keys, certs, hashes, TLS tests.openssl rand -hex 16
flockTake a lock so two scripts do not run at once.flock /tmp/x.lock cmd

17. Getting help

The terminal documents itself. Learn these and you can teach yourself the rest.

Command What it does Example
man The manual page for a command. man tar
info GNU’s longer, hyperlinked manuals. info coreutils
apropos / whatis Search man pages by keyword / one-line summary. apropos copy
help Documentation for shell builtins. help cd
tldr (install) Community cheat-sheets: just the common examples. tldr tar
<cmd> --help Most commands print a short usage summary. ls --help

18. Windows: Command Prompt (CMD)

Everything above assumes a Unix-like shell. Windows ships its own command line. The legacy Command Prompt (cmd.exe) uses a different command set; commands and flags are case-insensitive and use /flag rather than -flag.

CommandWhat it doesExample
dirList directory contents (like ls).dir /a
cd / chdirChange / print the current directory.cd Users
copy / xcopy / robocopyCopy files; robocopy is the robust mirroring tool.robocopy src dst /MIR
moveMove or rename files.move a.txt b.txt
del / eraseDelete files.del *.tmp
ren / renameRename a file.ren a.txt b.txt
md / rdMake / remove a directory.md newdir
typePrint a file (like cat).type notes.txt
morePage through output.type big.log | more
clsClear the screen (the CMD clear).cls
find / findstrSearch text in files (findstr supports regex).findstr /s "TODO" *.cs
treeShow the directory tree.tree /f
attribShow/change file attributes (read-only, hidden).attrib +r file.txt
fc / compCompare two files.fc a.txt b.txt
whereLocate an executable (like which).where python
setShow/set environment variables.set PATH
tasklist / taskkillList / kill processes.taskkill /IM notepad.exe /F
sc / netManage Windows services and shares.net start spooler
systeminfo / verOS, hardware summary / just the version.systeminfo
hostnameShow the computer name.hostname
ipconfigShow/refresh IP configuration.ipconfig /all
ping / tracert / pathpingReachability / route / route+loss to a host.tracert example.com
nslookupQuery DNS.nslookup example.com
netstat / route / arpConnections / routing table / ARP cache.netstat -ano
getmacShow network adapter MAC addresses.getmac
sfc / chkdskCheck/repair system files / a disk.sfc /scannow
diskpartInteractive disk and partition management.diskpart
format / label / volFormat a drive / set / show its volume label.format D: /FS:NTFS
assoc / ftypeMap file extensions to programs.assoc .txt
shutdownShut down or restart the machine.shutdown /r /t 0
echo / date / timePrint text / show-set date / show-set time.echo Hello
helpList built-in commands or help for one.help dir

19. Windows: PowerShell

Modern Windows (and cross-platform PowerShell 7) uses a richer shell built on objects, not text. Commands are cmdlets named Verb-Noun, but most have short aliases — several deliberately match Unix names. Below, each row notes the built-in alias in parentheses.

Cmdlet (alias)What it doesExample
Get-ChildItem (ls, dir)List items in a directory.Get-ChildItem -Recurse
Set-Location (cd)Change directory.Set-Location C:
Get-Location (pwd)Print the current directory.Get-Location
Copy-Item (cp)Copy files or directories.Copy-Item a.txt b.txt
Move-Item (mv)Move or rename.Move-Item a.txt b.txt
Remove-Item (rm, del)Delete files or directories.Remove-Item -Recurse old
New-ItemCreate a file or directory.New-Item -ItemType Directory d
Get-Content (cat, type)Read a file’s contents.Get-Content log.txt -Tail 20
Set-Content / Add-ContentWrite / append to a file.Set-Content f.txt "hi"
Select-String (sls)Search text (like grep).Select-String "error" *.log
Get-Process (ps)List running processes.Get-Process | Sort CPU
Stop-Process (kill)Kill a process.Stop-Process -Name notepad
Get-Service / Start-Service / Stop-ServiceManage Windows services.Get-Service | Where Status -eq Running
Test-ConnectionPing a host (object output).Test-Connection example.com
Invoke-WebRequest (curl, wget)Fetch a URL / download a file.Invoke-WebRequest -Uri $u -OutFile f
Where-Object / ForEach-ObjectFilter / iterate the object pipeline.Get-Process | Where CPU -gt 10
Select-Object / Sort-Object / Measure-ObjectPick columns / sort / count & sum.... | Sort-Object Name
Get-Command / Get-Help (man)Discover cmdlets / read their help.Get-Help Get-ChildItem -Examples
Clear-Host (cls, clear)Clear the screen.Clear-Host
Set-ExecutionPolicyControl whether scripts may run.Set-ExecutionPolicy RemoteSigned

20. Unix → Windows quick translation

If you know the Unix command, here is the everyday Windows equivalent in each shell. Exact flags differ — this is for “what is this called over there?”

Unix CMD PowerShell
ls dir Get-ChildItem
cd (alone) cd Get-Location
pwd cd Get-Location
cp copy / robocopy Copy-Item
mv move Move-Item
rm del / rd Remove-Item
mkdir md New-Item -ItemType Directory
cat type Get-Content
grep findstr Select-String
clear cls Clear-Host
man help <cmd> / <cmd> /? Get-Help
which where Get-Command
ps tasklist Get-Process
kill taskkill Stop-Process
ifconfig / ip ipconfig Get-NetIPConfiguration
netstat netstat Get-NetTCPConnection
curl / wget curl (Win10+) Invoke-WebRequest
df wmic logicaldisk Get-PSDrive
chmod icacls icacls / Set-Acl
top tasklist Get-Process
env set Get-ChildItem Env:
shutdown -r shutdown /r Restart-Computer

The honest truth, again

This is a long list, and nobody holds it all in their head. The win is recognition, not recall: once you know a job has a tool — “there is a command that mirrors a directory tree”, “there is one that follows a log” — you can find the exact name and flags here or in man in under a minute. Start with the essential-commands short list, keep this page bookmarked, and grow your toolkit one remembered name at a time.

← back to index