Field guide — 203 commands

Intro to Linux,
one command at a time.

A quiet, animated walkthrough of the shell — cd, ls, grep, sudo and the rest. Tap any card to re-run its demo.

203
commands
10
categories
combinations
operator@cabal
zsh
~

The commands

203 of 203 shown · tap any card to replay

Navigation

NAV
09 commands

pwd

NAV
pwd

Print the current working directory.

~

cd

NAV
cd <path>

Change directory. `cd ..` up, `cd ~` home, `cd -` previous.

~

pushd

NAV
pushd <path>

Push a directory onto the stack and cd into it.

~

popd

NAV
popd

Pop the directory stack, returning to the previous location.

~

tree

NAV
tree -L 2

Recursive, indented directory listing.

~

ls -R

NAV
ls -R <dir>

Recursively list every file below a directory.

~

cd -

NAV
cd -

Jump back to the previous working directory.

~

dirs

NAV
dirs -v

Show the current directory stack, numbered.

~

cd ~

NAV
cd ~

Jump to the current user's home directory.

~

Files & directories

FS
26 commands

ls

FS
ls [-lah] [path]

List directory contents. `-l` long, `-a` hidden, `-h` human.

~

dir

FS
dir

List files (DOS-friendly alias of `ls`).

~

mkdir

FS
mkdir [-p] <dir>

Create directories. `-p` makes parents as needed.

~

rmdir

FS
rmdir <dir>

Remove an empty directory.

~

rm

FS
rm [-rf] <path>

Remove files. `-r` recursive, `-f` force. Care.

~

cp

FS
cp [-r] <src> <dst>

Copy files or directories.

~

mv

FS
mv <src> <dst>

Move or rename files.

~

touch

FS
touch <file>

Create an empty file or update its timestamp.

~

ln

FS
ln -s <target> <link>

Create a symbolic link.

~

stat

FS
stat <file>

Detailed file metadata: size, inode, mode, times.

~

file

FS
file <path>

Identify a file's type by content, not extension.

~

basename

FS
basename <path>

Strip directory and suffix from a path.

~

dirname

FS
dirname <path>

Return the directory portion of a path.

~

realpath

FS
realpath <path>

Resolve a path to its canonical absolute form.

~

rename

FS
rename <expr> <files>

Rename many files with a pattern.

~

shred

FS
shred -u <file>

Overwrite and remove a file to hinder recovery.

~

install

FS
install -m 755 <src> <dst>

Copy files and set mode in one shot.

~

readlink

FS
readlink -f <path>

Print resolved value of a symbolic link.

~

truncate

FS
truncate -s <size> <file>

Shrink or extend a file to an exact size.

~

md5sum

FS
md5sum <file>

Compute and print an MD5 hash.

~

sha256sum

FS
sha256sum <file>

Compute and print a SHA-256 hash.

~

chattr

FS
sudo chattr +i <file>

Change ext filesystem attributes (e.g. +i = immutable).

~

lsattr

FS
lsattr <file>

List ext filesystem attributes on a file.

~

dd

FS
dd if=<in> of=<out> bs=<n>

Convert and copy raw data blocks. Careful — no undo.

~

cmp

FS
cmp <a> <b>

Byte-by-byte compare two files.

~

mktemp

FS
mktemp

Safely create a unique temporary file or directory.

~

Reading files

VIEW
17 commands

cat

VIEW
cat <file>

Concatenate and print file content.

~

less

VIEW
less <file>

Page through a file. `q` quit, `/` search.

~

more

VIEW
more <file>

Simple pager. Space for next page, `q` to quit.

~

head

VIEW
head -n <N> <file>

Show the first N lines of a file.

~

tail

VIEW
tail -f <file>

Show the last lines. `-f` follows new writes.

~

tac

VIEW
tac <file>

Concatenate and print files in reverse.

~

nl

VIEW
nl <file>

Number the lines of a file.

~

echo

VIEW
echo <text>

Print text or variables to stdout.

~

diff

VIEW
diff <a> <b>

Compare files line by line.

~

hexdump

VIEW
hexdump -C <file>

Canonical hex + ASCII view of any file.

~

xxd

VIEW
xxd <file>

Make a hex dump — or reverse one back to bytes.

~

od

VIEW
od -c <file>

Octal / character dump of a file.

~

bat

VIEW
bat <file>

Syntax-highlighted, git-aware `cat` clone.

~

strings

VIEW
strings <file>

Print sequences of printable characters from a binary.

~

printf

VIEW
printf <fmt> <args>

Formatted output — like C's printf, but from the shell.

~

vim

VIEW
vim <file>

Modal editor. `i` insert, `Esc` normal, `:wq` save+quit.

~

nano

VIEW
nano <file>

Friendly terminal editor. `Ctrl-O` save, `Ctrl-X` quit.

~

Search & locate

FIND
09 commands

grep

FIND
grep [-rni] <pat> <path>

Search text using patterns. `-r` recurse, `-i` case, `-n` lines.

~

find

FIND
find <path> -name <glob>

Walk a directory tree looking for matches.

~

which

FIND
which <cmd>

Locate a command in your PATH.

~

whereis

FIND
whereis <cmd>

Locate binary, source, and manual for a command.

~

locate

FIND
locate <name>

Quickly find files by name via the updatedb index.

~

type

FIND
type <cmd>

Reveal how the shell will interpret a command.

~

rg

FIND
rg <pat> <path>

Ripgrep — blazing recursive text search.

~

fd

FIND
fd <pattern>

Simple, fast alternative to `find`.

~

ag

FIND
ag <pat>

The Silver Searcher: fast code search.

~

Processes

PROC
20 commands

ps

PROC
ps aux

Snapshot of running processes.

~

top

PROC
top

Live process viewer.

~

htop

PROC
htop

Friendlier, colorful process viewer with mouse support.

~

kill

PROC
kill [-9] <pid>

Send a signal to a process. `-9` = SIGKILL.

~

killall

PROC
killall <name>

Kill processes by name.

~

pgrep

PROC
pgrep <name>

Print PIDs matching a name.

~

nohup

PROC
nohup <cmd> &

Run a command immune to hangups, output to nohup.out.

~

jobs

PROC
jobs

List jobs in the current shell.

~

bg / fg

PROC
bg %1 | fg %1

Move a job to background or foreground.

~

systemctl

PROC
systemctl <action> <unit>

Control systemd services and units.

~

crontab

PROC
crontab -e

Edit the current user's scheduled jobs.

~

pkill

PROC
pkill <name>

Signal processes by name pattern.

~

renice

PROC
renice <n> -p <pid>

Change scheduling priority of a running process.

~

nice

PROC
nice -n <n> <cmd>

Run a command with adjusted scheduling priority.

~

at

PROC
at <time>

Queue a one-shot job for later execution.

~

watch

PROC
watch -n <s> <cmd>

Re-run a command at intervals and show output.

~

time

PROC
time <cmd>

Report how long a command took to run.

~

timeout

PROC
timeout <dur> <cmd>

Run a command with a wall-clock kill switch.

~

wait

PROC
wait [pid]

Block until background jobs / a PID finish.

~

trap

PROC
trap '<cmd>' <signal>

Run a handler when the shell receives a signal.

~

Network

NET
26 commands

ping

NET
ping <host>

Send ICMP echo requests.

~

curl

NET
curl [-X M] <url>

Transfer data from or to a URL.

~

wget

NET
wget <url>

Download files non-interactively.

~

ssh

NET
ssh user@host

Open a secure shell session.

~

scp

NET
scp <src> user@host:<dst>

Copy files over SSH.

~

rsync

NET
rsync -avz <src> <dst>

Efficient incremental file sync, local or remote.

~

ss

NET
ss -tulpn

Inspect open sockets and listeners (modern netstat).

~

ip

NET
ip <object> <cmd>

Show and manipulate routing, devices, and tunnels.

~

traceroute

NET
traceroute <host>

Trace the network path packets take to a host.

~

dig

NET
dig <domain>

DNS lookup utility. Query records directly.

~

nc

NET
nc [-lv] <host> <port>

Netcat: read/write TCP & UDP. Swiss-army knife.

~

netstat

NET
netstat -tulpn

Legacy socket inspector. Prefer `ss`.

~

ifconfig

NET
ifconfig

Legacy interface config tool. Prefer `ip`.

~

arp

NET
arp -a

Show or manipulate the ARP cache.

~

nslookup

NET
nslookup <host>

Query DNS interactively.

~

host

NET
host <domain>

Simple DNS lookup utility.

~

iptables

NET
sudo iptables -L

Configure kernel packet filtering rules.

~

ufw

NET
sudo ufw <cmd>

Uncomplicated firewall front-end for iptables.

~

tcpdump

NET
sudo tcpdump -i <if>

Capture and analyse network packets.

~

nmap

NET
nmap <host>

Network scanner — hosts, ports, services.

~

mtr

NET
mtr <host>

Live traceroute + ping in one continuously updating view.

~

whois

NET
whois <domain>

Look up domain registration info.

~

ftp

NET
ftp <host>

Interactive File Transfer Protocol client.

~

sftp

NET
sftp user@host

Interactive file transfer over SSH.

~

iwconfig

NET
iwconfig

Show wireless interface configuration.

~

nmcli

NET
nmcli <object> <cmd>

Command-line control of NetworkManager.

~

Permissions

PERM
17 commands

chmod

PERM
chmod <mode> <file>

Change file permissions. `755`, `+x`, `o-w` …

~

chown

PERM
chown user:group <file>

Change file ownership.

~

chgrp

PERM
chgrp <group> <file>

Change the group ownership of a file.

~

umask

PERM
umask <mask>

Set the default permission mask for new files.

~

sudo

PERM
sudo <cmd>

Execute a command as the superuser. Power. Responsibility.

~

su

PERM
su [- user]

Switch user. `su -` loads target user's env.

~

passwd

PERM
passwd [user]

Change a user's password.

~

id

PERM
id [user]

Show user and group IDs.

~

getfacl

PERM
getfacl <file>

Show POSIX ACLs on a file.

~

setfacl

PERM
setfacl -m u:op:rw <f>

Modify POSIX ACLs on a file.

~

sudoers

PERM
sudo visudo

Safely edit /etc/sudoers with syntax checking.

~

useradd

PERM
sudo useradd <name>

Create a new user account.

~

usermod

PERM
sudo usermod -aG <g> <u>

Modify a user account (add groups, shell, home).

~

groups

PERM
groups [user]

Show the groups a user belongs to.

~

userdel

PERM
sudo userdel <name>

Delete a user account.

~

groupadd

PERM
sudo groupadd <name>

Create a new group.

~

chage

PERM
sudo chage -l <user>

Show or change password expiration policy.

~

System

SYS
40 commands

uname

SYS
uname -a

Print system and kernel information.

~

df

SYS
df -h

Disk space usage by filesystem.

~

du

SYS
du -sh <path>

Disk usage of a path. `-s` summary, `-h` human.

~

free

SYS
free -h

Memory usage at a glance.

~

uptime

SYS
uptime

How long the system has been up.

~

whoami

SYS
whoami

Print the effective user.

~

history

SYS
history

Show recently executed commands.

~

man

SYS
man <cmd>

The manual. Your most reliable contact.

~

date

SYS
date [+fmt]

Print or set the system date.

~

hostname

SYS
hostname

Show or set the system's hostname.

~

lsblk

SYS
lsblk

List block devices in a tree.

~

dmesg

SYS
dmesg -T

Print or control the kernel ring buffer.

~

journalctl

SYS
journalctl -u <unit>

Query the systemd journal.

~

mount

SYS
mount <dev> <dir>

Attach a filesystem to a mount point.

~

reboot

SYS
reboot

Restart the system.

~

shutdown

SYS
shutdown -h now

Power off or halt the system.

~

env

SYS
env

Print or set environment variables.

~

export

SYS
export KEY=value

Set an env var for child processes.

~

alias

SYS
alias ll='ls -lah'

Create a shortcut for a longer command.

~

clear

SYS
clear

Wipe the visible terminal buffer. `Ctrl-L` too.

~

exit

SYS
exit

Close the current shell session.

~

lscpu

SYS
lscpu

Display CPU architecture information.

~

lsusb

SYS
lsusb

List USB devices attached to the system.

~

lspci

SYS
lspci

List PCI devices on the bus.

~

lsof

SYS
lsof -i :<port>

List open files and the processes that hold them.

~

uptime -p

SYS
uptime -p

Pretty-print how long the system has been up.

~

who

SYS
who

Show who is logged on.

~

last

SYS
last -n <N>

Show the last logged-in users.

~

timedatectl

SYS
timedatectl

Show and change system time / timezone.

~

hostnamectl

SYS
hostnamectl

Query or change the system hostname and metadata.

~

loginctl

SYS
loginctl list-sessions

Inspect systemd-logind sessions.

~

sysctl

SYS
sudo sysctl <var>

Read or write kernel runtime parameters.

~

modprobe

SYS
sudo modprobe <mod>

Load a kernel module (with its dependencies).

~

lsmod

SYS
lsmod

Show the status of loaded kernel modules.

~

uname -r

SYS
uname -r

Print the running kernel release string.

~

swapon

SYS
swapon --show

Show or enable swap devices and files.

~

fdisk

SYS
sudo fdisk -l

Partition table manipulator for block devices.

~

blkid

SYS
blkid

Show block-device UUID, label, and filesystem type.

~

systemctl list-units

SYS
systemctl list-units --type=service

List units systemd currently knows about.

~

shutdown -c

SYS
shutdown -c

Cancel a pending scheduled shutdown.

~

Packages

PKG
13 commands

apt

PKG
sudo apt install <pkg>

Debian/Ubuntu package manager.

~

dnf

PKG
sudo dnf install <pkg>

Fedora/RHEL package manager.

~

pacman

PKG
sudo pacman -S <pkg>

Arch package manager.

~

snap

PKG
sudo snap install <pkg>

Cross-distro sandboxed package manager.

~

brew

PKG
brew install <pkg>

Homebrew: user-space package manager.

~

dpkg

PKG
dpkg -i <file.deb>

Low-level Debian package tool.

~

apt update

PKG
sudo apt update

Refresh available package lists.

~

apt upgrade

PKG
sudo apt upgrade

Install newer versions of installed packages.

~

rpm

PKG
rpm -qa

Query and manage RPM packages directly.

~

yay

PKG
yay -S <pkg>

AUR helper for Arch — like pacman + AUR builds.

~

pip

PKG
pip install <pkg>

Install Python packages from PyPI.

~

npm

PKG
npm install <pkg>

Install Node.js packages from the registry.

~

flatpak

PKG
flatpak install <pkg>

Install and run sandboxed desktop apps.

~

Text & streams

TEXT
26 commands

tar

TEXT
tar -czvf out.tgz <dir>

Archive files. `-x` extract, `-t` list.

~

wc

TEXT
wc -l <file>

Count lines, words, bytes.

~

sort

TEXT
sort <file>

Sort lines of text.

~

uniq

TEXT
uniq [-c]

Filter adjacent duplicate lines. Pair with sort.

~

awk

TEXT
awk '{ print $1 }'

Pattern-scanning and processing language.

~

sed

TEXT
sed 's/foo/bar/g'

Stream editor for transforming text.

~

xargs

TEXT
<cmd> | xargs <cmd>

Build and execute commands from stdin.

~

cut

TEXT
cut -d, -f2 <file>

Extract sections from each line.

~

tr

TEXT
tr <set1> <set2>

Translate or delete characters.

~

tee

TEXT
<cmd> | tee <file>

Read stdin, write to stdout AND to files.

~

jq

TEXT
jq '.path' <file>

Sling JSON on the command line.

~

column

TEXT
column -t <file>

Format text into columns.

~

paste

TEXT
paste <a> <b>

Merge lines of files side by side.

~

fold

TEXT
fold -w <N>

Wrap each input line to fit a given width.

~

rev

TEXT
rev <file>

Reverse the characters of each line.

~

split

TEXT
split -l <N> <file>

Split a file into fixed-size pieces.

~

yes

TEXT
yes [string]

Repeatedly print a string until killed (feeds `y` to prompts).

~

expand

TEXT
expand <file>

Convert tab characters to spaces.

~

unexpand

TEXT
unexpand <file>

Convert leading spaces back to tabs.

~

comm

TEXT
comm <a> <b>

Line-by-line compare two sorted files.

~

join

TEXT
join <a> <b>

Join two sorted files on a common field.

~

zip

TEXT
zip <out.zip> <files>

Compress files into a .zip archive.

~

unzip

TEXT
unzip <archive.zip>

Extract files from a .zip archive.

~

gzip

TEXT
gzip <file>

Compress a file to .gz (removes the original).

~

gunzip

TEXT
gunzip <file.gz>

Decompress a .gz file back to the original.

~

base64

TEXT
base64 [-d] <file>

Encode / decode data as Base64.

~