DevOps Reference
Linux Commands Reference
Linux commands are small programs you combine: one to list or find files (ls, find), one to read or filter text (cat, grep, awk), one to change permissions (chmod, chown), one to inspect processes (ps, top, kill) and one to move data over the network (curl, ssh, scp). This reference lists each with a working example.
Browse by Category
Files & Directories
16Creating, moving, copying and removing things on disk.
Viewing & Editing
12Reading file contents and editing them in place.
Search & Text Processing
15Finding files and transforming their contents.
Permissions & Ownership
10Who may read, write or execute what.
Processes & Jobs
16Starting, watching and stopping running programs.
System & Monitoring
14Disk, memory, uptime and hardware information.
Networking
18Connections, transfers and name resolution.
Archives & Packages
10Compressing, extracting and installing software.
Shell & Users
14Accounts, environment and shell built-ins.
All Linux Commands (125)
Files & Directories (16)
Creating, moving, copying and removing things on disk.
| Command | Does | Description | Example |
|---|---|---|---|
ls | List directory | Lists directory contents. -l gives the long form with permissions and size, -a includes dotfiles, -h makes sizes human-readable. | ls -lah |
cd | Change directory | Moves the shell to another directory. With no argument it returns home; with - it returns to the previous directory. | cd /var/log |
pwd | Print working dir | Prints the absolute path of the directory you are currently in. | pwd |
mkdir | Create directory | Creates a directory. -p creates missing parents and does not complain if it already exists. | mkdir -p src/app/utils |
rmdir | Remove empty dir | Deletes a directory only if it is empty — safer than rm -r when that is what you mean. | rmdir build |
rm | Delete files | Removes files. -r recurses into directories and -f suppresses prompts. There is no undo and no trash. | rm -rf node_modules |
cp | Copy | Copies files or directories. -r is required for directories, -a preserves permissions and timestamps. | cp -r src/ backup/ |
mv | Move or rename | Moves a file to another path, which is also how renaming is done. | mv draft.md final.md |
touch | Create or timestamp | Creates an empty file, or updates the modification time of one that exists. | touch .env.local |
ln -s | Symbolic link | Creates a symlink pointing at another path. Without -s it makes a hard link to the same inode. | ln -s /opt/app/current /usr/local/app |
stat | File metadata | Shows size, permissions, inode, and access, modification and change timestamps. | stat app.log |
file | Identify a file | Reports what a file actually is by inspecting its contents rather than trusting the extension. | file image.dat |
basename | Strip the path | Prints the final component of a path, optionally with a suffix removed. | basename /var/log/app.log .log |
dirname | Strip the filename | Prints everything but the last component of a path. | dirname /var/log/app.log |
realpath | Resolve a path | Prints the canonical absolute path with all symlinks and .. segments resolved. | realpath ./bin/../app |
tree | Directory tree | Draws the directory hierarchy as a tree. -L limits the depth. | tree -L 2 src |
Does
List directory
Description
Lists directory contents. -l gives the long form with permissions and size, -a includes dotfiles, -h makes sizes human-readable.
Example
ls -lah
Does
Change directory
Description
Moves the shell to another directory. With no argument it returns home; with - it returns to the previous directory.
Example
cd /var/log
Does
Print working dir
Description
Prints the absolute path of the directory you are currently in.
Example
pwd
Does
Create directory
Description
Creates a directory. -p creates missing parents and does not complain if it already exists.
Example
mkdir -p src/app/utils
Does
Remove empty dir
Description
Deletes a directory only if it is empty — safer than rm -r when that is what you mean.
Example
rmdir build
Does
Delete files
Description
Removes files. -r recurses into directories and -f suppresses prompts. There is no undo and no trash.
Example
rm -rf node_modules
Does
Copy
Description
Copies files or directories. -r is required for directories, -a preserves permissions and timestamps.
Example
cp -r src/ backup/
Does
Move or rename
Description
Moves a file to another path, which is also how renaming is done.
Example
mv draft.md final.md
Does
Create or timestamp
Description
Creates an empty file, or updates the modification time of one that exists.
Example
touch .env.local
Does
Symbolic link
Description
Creates a symlink pointing at another path. Without -s it makes a hard link to the same inode.
Example
ln -s /opt/app/current /usr/local/app
Does
File metadata
Description
Shows size, permissions, inode, and access, modification and change timestamps.
Example
stat app.log
Does
Identify a file
Description
Reports what a file actually is by inspecting its contents rather than trusting the extension.
Example
file image.dat
Does
Strip the path
Description
Prints the final component of a path, optionally with a suffix removed.
Example
basename /var/log/app.log .log
Does
Strip the filename
Description
Prints everything but the last component of a path.
Example
dirname /var/log/app.log
Does
Resolve a path
Description
Prints the canonical absolute path with all symlinks and .. segments resolved.
Example
realpath ./bin/../app
Does
Directory tree
Description
Draws the directory hierarchy as a tree. -L limits the depth.
Example
tree -L 2 src
Viewing & Editing (12)
Reading file contents and editing them in place.
| Command | Does | Description | Example |
|---|---|---|---|
cat | Print a file | Writes a file to standard output. Concatenates when given several, which is where the name comes from. | cat /etc/hostname |
less | Page through | Views a file one screen at a time with search and scrolling, without loading it all into memory. | less /var/log/syslog |
head | First lines | Prints the first 10 lines of a file, or -n of your choosing. | head -n 20 access.log |
tail | Last lines | Prints the last lines of a file — the fastest way to see the most recent entries in a log. | tail -n 50 error.log |
tail -f | Follow a log | Keeps the file open and prints new lines as they are written. -F also survives log rotation. | tail -F /var/log/nginx/access.log |
nano | Simple editor | A terminal editor with on-screen key hints — the one to reach for when you just need to change a config line. | nano /etc/hosts |
vim | Modal editor | A powerful modal editor present on essentially every Unix system. Press Esc then :wq to save and quit. | vim config.yml |
wc | Count | Counts lines, words and bytes. -l for lines is the common use, usually at the end of a pipe. | wc -l access.log |
nl | Number lines | Prints a file with line numbers prepended. | nl script.sh |
diff | Compare files | Shows the lines that differ between two files. -u gives the unified format used by patches. | diff -u old.conf new.conf |
tee | Split output | Writes its input to a file and to standard output at once, so a pipeline can be saved and watched. | make 2>&1 | tee build.log |
xxd | Hex dump | Shows a file as hexadecimal with an ASCII column, for inspecting binaries. | xxd -l 64 image.png |
Does
Print a file
Description
Writes a file to standard output. Concatenates when given several, which is where the name comes from.
Example
cat /etc/hostname
Does
Page through
Description
Views a file one screen at a time with search and scrolling, without loading it all into memory.
Example
less /var/log/syslog
Does
First lines
Description
Prints the first 10 lines of a file, or -n of your choosing.
Example
head -n 20 access.log
Does
Last lines
Description
Prints the last lines of a file — the fastest way to see the most recent entries in a log.
Example
tail -n 50 error.log
Does
Follow a log
Description
Keeps the file open and prints new lines as they are written. -F also survives log rotation.
Example
tail -F /var/log/nginx/access.log
Does
Simple editor
Description
A terminal editor with on-screen key hints — the one to reach for when you just need to change a config line.
Example
nano /etc/hosts
Does
Modal editor
Description
A powerful modal editor present on essentially every Unix system. Press Esc then :wq to save and quit.
Example
vim config.yml
Does
Count
Description
Counts lines, words and bytes. -l for lines is the common use, usually at the end of a pipe.
Example
wc -l access.log
Does
Number lines
Description
Prints a file with line numbers prepended.
Example
nl script.sh
Does
Compare files
Description
Shows the lines that differ between two files. -u gives the unified format used by patches.
Example
diff -u old.conf new.conf
Does
Split output
Description
Writes its input to a file and to standard output at once, so a pipeline can be saved and watched.
Example
make 2>&1 | tee build.log
Does
Hex dump
Description
Shows a file as hexadecimal with an ASCII column, for inspecting binaries.
Example
xxd -l 64 image.png
Search & Text Processing (15)
Finding files and transforming their contents.
| Command | Does | Description | Example |
|---|---|---|---|
grep | Search text | Prints lines matching a pattern. -r recurses, -i ignores case, -n shows line numbers, -v inverts the match. | grep -rn "TODO" src/ |
grep -E | Extended regex | Uses extended regular expressions, so +, ? and | work without backslashes. Same as egrep. | grep -E "error|warn" app.log |
find | Find files | Walks a directory tree selecting files by name, type, size, age or permission, and can act on each result. | find . -name "*.log" -mtime +7 |
find -exec | Act on results | Runs a command for every file found. Ending with + batches them, which is much faster than one call each. | find . -name "*.tmp" -exec rm {} + |
locate | Fast file search | Searches a prebuilt index of filenames — near-instant, but only as fresh as the last updatedb run. | locate nginx.conf |
which | Locate a command | Prints the path of the executable the shell would run for a given name. | which python3 |
sed | Stream edit | Transforms text line by line, most often substituting a pattern. -i edits the file in place. | sed -i 's/8080/3000/g' config.yml |
awk | Field processing | Splits each line into fields and runs a small program over them — the tool for columns and arithmetic. | awk '{sum+=$3} END {print sum}' data.txt |
cut | Extract columns | Selects fields or character ranges from each line. -d sets the delimiter, -f the fields. | cut -d: -f1 /etc/passwd |
sort | Sort lines | Orders lines alphabetically by default. -n sorts numerically, -r reverses, -k picks a column. | sort -k2 -n scores.txt |
uniq | Collapse duplicates | Removes adjacent duplicate lines, so input must be sorted first. -c prefixes each with its count. | sort access.log | uniq -c | sort -rn |
tr | Translate chars | Substitutes or deletes characters across a stream — case conversion, whitespace squeezing and the like. | tr 'a-z' 'A-Z' < in.txt |
paste | Join lines side by side | Merges corresponding lines of several files into columns. | paste names.txt scores.txt |
xargs | Build command lines | Turns standard input into arguments for another command. -0 with find -print0 handles filenames with spaces. | find . -name "*.js" -print0 | xargs -0 wc -l |
jq | Query JSON | Filters and reshapes JSON on the command line. Not always preinstalled, but the standard tool for the job. | curl -s api/x | jq '.items[].name' |
Does
Search text
Description
Prints lines matching a pattern. -r recurses, -i ignores case, -n shows line numbers, -v inverts the match.
Example
grep -rn "TODO" src/
Does
Extended regex
Description
Uses extended regular expressions, so +, ? and | work without backslashes. Same as egrep.
Example
grep -E "error|warn" app.log
Does
Find files
Description
Walks a directory tree selecting files by name, type, size, age or permission, and can act on each result.
Example
find . -name "*.log" -mtime +7
Does
Act on results
Description
Runs a command for every file found. Ending with + batches them, which is much faster than one call each.
Example
find . -name "*.tmp" -exec rm {} +
Does
Fast file search
Description
Searches a prebuilt index of filenames — near-instant, but only as fresh as the last updatedb run.
Example
locate nginx.conf
Does
Locate a command
Description
Prints the path of the executable the shell would run for a given name.
Example
which python3
Does
Stream edit
Description
Transforms text line by line, most often substituting a pattern. -i edits the file in place.
Example
sed -i 's/8080/3000/g' config.yml
Does
Field processing
Description
Splits each line into fields and runs a small program over them — the tool for columns and arithmetic.
Example
awk '{sum+=$3} END {print sum}' data.txt
Does
Extract columns
Description
Selects fields or character ranges from each line. -d sets the delimiter, -f the fields.
Example
cut -d: -f1 /etc/passwd
Does
Sort lines
Description
Orders lines alphabetically by default. -n sorts numerically, -r reverses, -k picks a column.
Example
sort -k2 -n scores.txt
Does
Collapse duplicates
Description
Removes adjacent duplicate lines, so input must be sorted first. -c prefixes each with its count.
Example
sort access.log | uniq -c | sort -rn
Does
Translate chars
Description
Substitutes or deletes characters across a stream — case conversion, whitespace squeezing and the like.
Example
tr 'a-z' 'A-Z' < in.txt
Does
Join lines side by side
Description
Merges corresponding lines of several files into columns.
Example
paste names.txt scores.txt
Does
Build command lines
Description
Turns standard input into arguments for another command. -0 with find -print0 handles filenames with spaces.
Example
find . -name "*.js" -print0 | xargs -0 wc -l
Does
Query JSON
Description
Filters and reshapes JSON on the command line. Not always preinstalled, but the standard tool for the job.
Example
curl -s api/x | jq '.items[].name'
Permissions & Ownership (10)
Who may read, write or execute what.
| Command | Does | Description | Example |
|---|---|---|---|
chmod | Change permissions | Sets read, write and execute bits, either as octal digits or as symbolic changes such as u+x. | chmod 755 deploy.sh |
chmod +x | Make executable | Adds the execute bit so a script can be run directly rather than passed to an interpreter. | chmod +x scripts/build.sh |
chmod -R | Recursive permissions | Applies a mode to a directory and everything under it. Use capital X to set execute on directories only. | chmod -R u+rwX,go+rX public/ |
chown | Change owner | Reassigns the owning user and optionally the group of a file. Requires root. | chown -R www-data:www-data /var/www |
chgrp | Change group | Changes only the group that owns a file. | chgrp developers shared/ |
umask | Default permissions | Shows or sets the bits masked off new files, which is what determines their default mode. | umask 022 |
sudo | Run as another user | Runs one command as root, or as the user given by -u, subject to policy in /etc/sudoers and logged. | sudo systemctl restart nginx |
su | Switch user | Starts a shell as another user, requiring that account's password. | su - deploy |
getfacl | Read ACLs | Shows access control lists, the finer-grained permissions that sit alongside the classic owner-group-other bits. | getfacl /srv/data |
setfacl | Set ACLs | Grants a specific user or group rights to a file without changing its owner or group. | setfacl -m u:alice:rwx report.csv |
Does
Change permissions
Description
Sets read, write and execute bits, either as octal digits or as symbolic changes such as u+x.
Example
chmod 755 deploy.sh
Does
Make executable
Description
Adds the execute bit so a script can be run directly rather than passed to an interpreter.
Example
chmod +x scripts/build.sh
Does
Recursive permissions
Description
Applies a mode to a directory and everything under it. Use capital X to set execute on directories only.
Example
chmod -R u+rwX,go+rX public/
Does
Change owner
Description
Reassigns the owning user and optionally the group of a file. Requires root.
Example
chown -R www-data:www-data /var/www
Does
Change group
Description
Changes only the group that owns a file.
Example
chgrp developers shared/
Does
Default permissions
Description
Shows or sets the bits masked off new files, which is what determines their default mode.
Example
umask 022
Does
Run as another user
Description
Runs one command as root, or as the user given by -u, subject to policy in /etc/sudoers and logged.
Example
sudo systemctl restart nginx
Does
Switch user
Description
Starts a shell as another user, requiring that account's password.
Example
su - deploy
Does
Read ACLs
Description
Shows access control lists, the finer-grained permissions that sit alongside the classic owner-group-other bits.
Example
getfacl /srv/data
Does
Set ACLs
Description
Grants a specific user or group rights to a file without changing its owner or group.
Example
setfacl -m u:alice:rwx report.csv
Processes & Jobs (16)
Starting, watching and stopping running programs.
| Command | Does | Description | Example |
|---|---|---|---|
ps aux | List processes | Prints a snapshot of every running process with its user, PID, CPU and memory use. | ps aux | grep node |
top | Live process view | Updates continuously, sorted by CPU use, so you can watch load as it happens. | top |
htop | Friendlier top | An interactive process viewer with colour, scrolling and per-core meters. Usually needs installing. | htop |
kill | Signal a process | Sends a signal to a PID. The default TERM asks it to shut down cleanly. | kill 4821 |
kill -9 | Force kill | Sends SIGKILL, which the process cannot catch or ignore. Skips cleanup, so try TERM first. | kill -9 4821 |
pkill | Kill by name | Signals every process whose name matches a pattern, without needing to look up PIDs. | pkill -f "node server.js" |
pgrep | Find PIDs by name | Prints the PIDs of processes matching a pattern — the safe look before a pkill. | pgrep -a nginx |
jobs | Shell jobs | Lists background and stopped jobs belonging to the current shell. | jobs -l |
bg / fg | Background/foreground | Resumes a stopped job in the background, or brings a background job to the foreground. | fg %1 |
nohup | Survive logout | Runs a command immune to hangup, so it keeps going after the terminal closes. | nohup ./worker.sh & |
nice / renice | Set priority | Starts a process at a lower CPU priority, or changes the priority of one already running. | nice -n 10 ./batch.sh |
systemctl | Manage services | Starts, stops, enables and inspects systemd units — the standard service manager on modern distributions. | systemctl status nginx |
journalctl | Read system logs | Queries the systemd journal. -u filters to one unit, -f follows, --since takes a time window. | journalctl -u nginx -f |
crontab -e | Schedule jobs | Edits the current user's scheduled tasks, one per line with a five-field time specification. | crontab -e |
watch | Repeat a command | Re-runs a command at a fixed interval and redraws the screen, for watching something change. | watch -n 2 df -h |
timeout | Cap a runtime | Runs a command and kills it if it exceeds a time limit. | timeout 30s ./healthcheck.sh |
Does
List processes
Description
Prints a snapshot of every running process with its user, PID, CPU and memory use.
Example
ps aux | grep node
Does
Live process view
Description
Updates continuously, sorted by CPU use, so you can watch load as it happens.
Example
top
Does
Friendlier top
Description
An interactive process viewer with colour, scrolling and per-core meters. Usually needs installing.
Example
htop
Does
Signal a process
Description
Sends a signal to a PID. The default TERM asks it to shut down cleanly.
Example
kill 4821
Does
Force kill
Description
Sends SIGKILL, which the process cannot catch or ignore. Skips cleanup, so try TERM first.
Example
kill -9 4821
Does
Kill by name
Description
Signals every process whose name matches a pattern, without needing to look up PIDs.
Example
pkill -f "node server.js"
Does
Find PIDs by name
Description
Prints the PIDs of processes matching a pattern — the safe look before a pkill.
Example
pgrep -a nginx
Does
Shell jobs
Description
Lists background and stopped jobs belonging to the current shell.
Example
jobs -l
Does
Background/foreground
Description
Resumes a stopped job in the background, or brings a background job to the foreground.
Example
fg %1
Does
Survive logout
Description
Runs a command immune to hangup, so it keeps going after the terminal closes.
Example
nohup ./worker.sh &
Does
Set priority
Description
Starts a process at a lower CPU priority, or changes the priority of one already running.
Example
nice -n 10 ./batch.sh
Does
Manage services
Description
Starts, stops, enables and inspects systemd units — the standard service manager on modern distributions.
Example
systemctl status nginx
Does
Read system logs
Description
Queries the systemd journal. -u filters to one unit, -f follows, --since takes a time window.
Example
journalctl -u nginx -f
Does
Schedule jobs
Description
Edits the current user's scheduled tasks, one per line with a five-field time specification.
Example
crontab -e
Does
Repeat a command
Description
Re-runs a command at a fixed interval and redraws the screen, for watching something change.
Example
watch -n 2 df -h
Does
Cap a runtime
Description
Runs a command and kills it if it exceeds a time limit.
Example
timeout 30s ./healthcheck.sh
System & Monitoring (14)
Disk, memory, uptime and hardware information.
| Command | Does | Description | Example |
|---|---|---|---|
df -h | Disk free | Shows how full each mounted filesystem is, in human-readable units. | df -h |
du -sh | Directory size | Totals the space a directory occupies. -s summarises rather than listing every file. | du -sh /var/log/* |
free -h | Memory use | Reports used, free and cached memory. On Linux, cache counts as available — look at the available column. | free -h |
uptime | Load and uptime | Shows how long the machine has been running and the load average over 1, 5 and 15 minutes. | uptime |
uname -a | Kernel info | Prints kernel name, version and machine architecture. | uname -a |
lsb_release -a | Distribution info | Reports the distribution and release. /etc/os-release is the more portable source. | lsb_release -a |
lsblk | List block devices | Shows disks and partitions as a tree with sizes and mount points. | lsblk -f |
mount | Attach a filesystem | Makes a device available at a directory. With no arguments it lists what is currently mounted. | mount /dev/sdb1 /mnt/data |
lsof | List open files | Shows which processes have which files open — including sockets, which is how you find what holds a port. | sudo lsof -i :3000 |
dmesg | Kernel messages | Prints the kernel ring buffer, where hardware and driver problems surface first. | dmesg -T | tail -30 |
iostat | Disk throughput | Reports CPU and per-device I/O statistics, for telling a disk-bound system from a CPU-bound one. | iostat -xz 2 |
vmstat | Virtual memory stats | Samples processes, memory, swap and I/O at an interval — a fast first look at where a system is stuck. | vmstat 2 5 |
date | Show or set time | Prints the current date and time, with a format string for scripting. | date +%Y-%m-%d |
ncdu | Interactive disk usage | Browsable disk usage analyser — the fastest way to find what filled a disk. Usually needs installing. | ncdu /var |
Does
Disk free
Description
Shows how full each mounted filesystem is, in human-readable units.
Example
df -h
Does
Directory size
Description
Totals the space a directory occupies. -s summarises rather than listing every file.
Example
du -sh /var/log/*
Does
Memory use
Description
Reports used, free and cached memory. On Linux, cache counts as available — look at the available column.
Example
free -h
Does
Load and uptime
Description
Shows how long the machine has been running and the load average over 1, 5 and 15 minutes.
Example
uptime
Does
Kernel info
Description
Prints kernel name, version and machine architecture.
Example
uname -a
Does
Distribution info
Description
Reports the distribution and release. /etc/os-release is the more portable source.
Example
lsb_release -a
Does
List block devices
Description
Shows disks and partitions as a tree with sizes and mount points.
Example
lsblk -f
Does
Attach a filesystem
Description
Makes a device available at a directory. With no arguments it lists what is currently mounted.
Example
mount /dev/sdb1 /mnt/data
Does
List open files
Description
Shows which processes have which files open — including sockets, which is how you find what holds a port.
Example
sudo lsof -i :3000
Does
Kernel messages
Description
Prints the kernel ring buffer, where hardware and driver problems surface first.
Example
dmesg -T | tail -30
Does
Disk throughput
Description
Reports CPU and per-device I/O statistics, for telling a disk-bound system from a CPU-bound one.
Example
iostat -xz 2
Does
Virtual memory stats
Description
Samples processes, memory, swap and I/O at an interval — a fast first look at where a system is stuck.
Example
vmstat 2 5
Does
Show or set time
Description
Prints the current date and time, with a format string for scripting.
Example
date +%Y-%m-%d
Does
Interactive disk usage
Description
Browsable disk usage analyser — the fastest way to find what filled a disk. Usually needs installing.
Example
ncdu /var
Networking (18)
Connections, transfers and name resolution.
| Command | Does | Description | Example |
|---|---|---|---|
curl | HTTP client | Makes requests to URLs. -I fetches headers only, -o writes to a file, -X sets the method. | curl -I https://example.com |
wget | Download files | Downloads over HTTP or FTP, resuming and recursing where curl would not. | wget -c https://example.com/big.iso |
ping | Test reachability | Sends ICMP echoes to a host and reports round-trip time and loss. | ping -c 4 example.com |
ip a | Show interfaces | Lists network interfaces and their addresses. Replaces the older ifconfig. | ip a |
ip r | Show routes | Prints the routing table, including which interface carries the default route. | ip r |
ss -ltnp | Listening sockets | Lists listening TCP sockets with the owning process. The modern replacement for netstat. | sudo ss -ltnp |
netstat -tulpn | Sockets (legacy) | The older way to list listening sockets and their processes, still common in documentation. | sudo netstat -tulpn |
dig | DNS lookup | Queries DNS and prints the full answer. +short reduces it to just the values. | dig +short example.com A |
nslookup | DNS lookup (simple) | A simpler interactive DNS query tool, widely available including on Windows. | nslookup example.com |
host | DNS one-liner | Resolves a name to addresses in a single compact line. | host example.com |
traceroute | Trace the path | Shows each hop between you and a host, exposing where latency or loss begins. | traceroute example.com |
ssh | Remote shell | Opens an encrypted shell on another machine. -i selects a key, -p a non-default port. | ssh -i ~/.ssh/id_ed25519 user@host |
ssh -L | Port forward | Tunnels a local port to a remote one over SSH — the safe way to reach a database bound to localhost. | ssh -L 5432:localhost:5432 user@host |
scp | Copy over SSH | Copies files between machines over SSH. -r for directories. | scp -r ./dist user@host:/var/www |
rsync | Sync directories | Copies only what differs, resumes, and can delete extras. -avz is the usual archive-verbose-compress trio. | rsync -avz --delete ./dist/ user@host:/var/www/ |
nc | Raw sockets | Reads and writes TCP or UDP connections directly. -zv tests whether a port is open. | nc -zv example.com 443 |
ufw | Firewall | A simplified front end to the kernel firewall, for allowing and denying ports. | sudo ufw allow 443/tcp |
openssl s_client | Inspect TLS | Opens a TLS connection and prints the certificate chain and negotiated cipher. | openssl s_client -connect example.com:443 |
Does
HTTP client
Description
Makes requests to URLs. -I fetches headers only, -o writes to a file, -X sets the method.
Example
curl -I https://example.com
Does
Download files
Description
Downloads over HTTP or FTP, resuming and recursing where curl would not.
Example
wget -c https://example.com/big.iso
Does
Test reachability
Description
Sends ICMP echoes to a host and reports round-trip time and loss.
Example
ping -c 4 example.com
Does
Show interfaces
Description
Lists network interfaces and their addresses. Replaces the older ifconfig.
Example
ip a
Does
Show routes
Description
Prints the routing table, including which interface carries the default route.
Example
ip r
Does
Listening sockets
Description
Lists listening TCP sockets with the owning process. The modern replacement for netstat.
Example
sudo ss -ltnp
Does
Sockets (legacy)
Description
The older way to list listening sockets and their processes, still common in documentation.
Example
sudo netstat -tulpn
Does
DNS lookup
Description
Queries DNS and prints the full answer. +short reduces it to just the values.
Example
dig +short example.com A
Does
DNS lookup (simple)
Description
A simpler interactive DNS query tool, widely available including on Windows.
Example
nslookup example.com
Does
DNS one-liner
Description
Resolves a name to addresses in a single compact line.
Example
host example.com
Does
Trace the path
Description
Shows each hop between you and a host, exposing where latency or loss begins.
Example
traceroute example.com
Does
Remote shell
Description
Opens an encrypted shell on another machine. -i selects a key, -p a non-default port.
Example
ssh -i ~/.ssh/id_ed25519 user@host
Does
Port forward
Description
Tunnels a local port to a remote one over SSH — the safe way to reach a database bound to localhost.
Example
ssh -L 5432:localhost:5432 user@host
Does
Copy over SSH
Description
Copies files between machines over SSH. -r for directories.
Example
scp -r ./dist user@host:/var/www
Does
Sync directories
Description
Copies only what differs, resumes, and can delete extras. -avz is the usual archive-verbose-compress trio.
Example
rsync -avz --delete ./dist/ user@host:/var/www/
Does
Raw sockets
Description
Reads and writes TCP or UDP connections directly. -zv tests whether a port is open.
Example
nc -zv example.com 443
Does
Firewall
Description
A simplified front end to the kernel firewall, for allowing and denying ports.
Example
sudo ufw allow 443/tcp
Does
Inspect TLS
Description
Opens a TLS connection and prints the certificate chain and negotiated cipher.
Example
openssl s_client -connect example.com:443
Archives & Packages (10)
Compressing, extracting and installing software.
| Command | Does | Description | Example |
|---|---|---|---|
tar -czf | Create an archive | Bundles files into a gzip-compressed tarball. c creates, z compresses, f names the file. | tar -czf site.tar.gz public/ |
tar -xzf | Extract an archive | Unpacks a gzip tarball into the current directory. -C extracts somewhere else. | tar -xzf site.tar.gz -C /var/www |
tar -tzf | List archive contents | Shows what is inside an archive without extracting it — worth doing before unpacking anything. | tar -tzf site.tar.gz |
zip / unzip | Zip archives | Creates and extracts zip files, the format to use when the other end is not Unix. | zip -r site.zip public/ |
gzip / gunzip | Compress one file | Compresses a single file in place, replacing it with a .gz version. | gzip access.log |
apt install | Install (Debian) | Installs packages on Debian and Ubuntu. Run apt update first so the index is current. | sudo apt update && sudo apt install nginx |
apt search | Find a package | Searches package names and descriptions in the configured repositories. | apt search postgresql |
dnf install | Install (Fedora/RHEL) | Installs packages on Fedora, RHEL and derivatives. Replaced yum, which still works as an alias. | sudo dnf install nginx |
pacman -S | Install (Arch) | Installs packages on Arch and derivatives. | sudo pacman -S nginx |
dpkg -l | List installed | Lists installed Debian packages and their versions. | dpkg -l | grep nginx |
Does
Create an archive
Description
Bundles files into a gzip-compressed tarball. c creates, z compresses, f names the file.
Example
tar -czf site.tar.gz public/
Does
Extract an archive
Description
Unpacks a gzip tarball into the current directory. -C extracts somewhere else.
Example
tar -xzf site.tar.gz -C /var/www
Does
List archive contents
Description
Shows what is inside an archive without extracting it — worth doing before unpacking anything.
Example
tar -tzf site.tar.gz
Does
Zip archives
Description
Creates and extracts zip files, the format to use when the other end is not Unix.
Example
zip -r site.zip public/
Does
Compress one file
Description
Compresses a single file in place, replacing it with a .gz version.
Example
gzip access.log
Does
Install (Debian)
Description
Installs packages on Debian and Ubuntu. Run apt update first so the index is current.
Example
sudo apt update && sudo apt install nginx
Does
Find a package
Description
Searches package names and descriptions in the configured repositories.
Example
apt search postgresql
Does
Install (Fedora/RHEL)
Description
Installs packages on Fedora, RHEL and derivatives. Replaced yum, which still works as an alias.
Example
sudo dnf install nginx
Does
Install (Arch)
Description
Installs packages on Arch and derivatives.
Example
sudo pacman -S nginx
Does
List installed
Description
Lists installed Debian packages and their versions.
Example
dpkg -l | grep nginx
Shell & Users (14)
Accounts, environment and shell built-ins.
| Command | Does | Description | Example |
|---|---|---|---|
echo | Print text | Writes its arguments to standard output, the workhorse of shell scripting. | echo "$HOME" |
export | Set an env var | Defines a variable and makes it visible to programs the shell starts. | export NODE_ENV=production |
env | Show environment | Prints every exported variable, or runs a command with a modified environment. | env | sort |
alias | Shorthand command | Defines a shorter name for a longer command. Put it in your shell rc file to make it permanent. | alias ll='ls -lah' |
history | Past commands | Lists commands you have run. Pipe through grep to find one you half remember. | history | grep docker |
source | Run in this shell | Executes a script in the current shell so its variables and functions persist afterwards. | source ~/.bashrc |
whoami | Current user | Prints the username the shell is running as — worth checking after a sudo or su. | whoami |
id | User and groups | Shows the numeric user ID, group ID and every group the user belongs to. | id deploy |
useradd | Create a user | Adds an account. -m creates the home directory, -s sets the login shell. | sudo useradd -m -s /bin/bash deploy |
usermod -aG | Add to a group | Appends a user to a supplementary group. Omitting -a replaces their groups instead of adding. | sudo usermod -aG docker deploy |
passwd | Change password | Sets a password for your account, or for another when run as root. | sudo passwd deploy |
man | Read the manual | Opens a command's manual page — the authoritative reference for flags this table only samples. | man tar |
chsh | Change shell | Sets the login shell for an account. | chsh -s /bin/zsh |
clear | Clear the screen | Blanks the terminal. Ctrl+L usually does the same thing without typing. | clear |
Does
Print text
Description
Writes its arguments to standard output, the workhorse of shell scripting.
Example
echo "$HOME"
Does
Set an env var
Description
Defines a variable and makes it visible to programs the shell starts.
Example
export NODE_ENV=production
Does
Show environment
Description
Prints every exported variable, or runs a command with a modified environment.
Example
env | sort
Does
Shorthand command
Description
Defines a shorter name for a longer command. Put it in your shell rc file to make it permanent.
Example
alias ll='ls -lah'
Does
Past commands
Description
Lists commands you have run. Pipe through grep to find one you half remember.
Example
history | grep docker
Does
Run in this shell
Description
Executes a script in the current shell so its variables and functions persist afterwards.
Example
source ~/.bashrc
Does
Current user
Description
Prints the username the shell is running as — worth checking after a sudo or su.
Example
whoami
Does
User and groups
Description
Shows the numeric user ID, group ID and every group the user belongs to.
Example
id deploy
Does
Create a user
Description
Adds an account. -m creates the home directory, -s sets the login shell.
Example
sudo useradd -m -s /bin/bash deploy
Does
Add to a group
Description
Appends a user to a supplementary group. Omitting -a replaces their groups instead of adding.
Example
sudo usermod -aG docker deploy
Does
Change password
Description
Sets a password for your account, or for another when run as root.
Example
sudo passwd deploy
Does
Read the manual
Description
Opens a command's manual page — the authoritative reference for flags this table only samples.
Example
man tar
Does
Change shell
Description
Sets the login shell for an account.
Example
chsh -s /bin/zsh
Does
Clear the screen
Description
Blanks the terminal. Ctrl+L usually does the same thing without typing.
Example
clear
Frequently Asked Questions
What does chmod 755 mean?
Each digit is a permission set in octal for owner, group and everyone else. 7 is read+write+execute (4+2+1), 5 is read+execute (4+1). So 755 means the owner can read, write and run the file while everyone else can read and run it — the usual mode for a script or a directory.
What is the difference between grep, sed and awk?
grep selects lines that match a pattern. sed edits a stream, most often substituting text line by line. awk splits each line into fields and lets you compute over them, so it handles columns and arithmetic that grep and sed cannot.
How do I find which process is using a port?
Run sudo lsof -i :8080 or sudo ss -ltnp | grep 8080. Both print the PID of the listening process, which you can then stop with kill. ss is the modern replacement for netstat and is installed by default on most current distributions.
What is the difference between sudo and su?
sudo runs a single command as another user (root by default) after checking a policy file, and logs it. su opens a whole shell as that user and needs the target account's password. sudo is preferred because it is scoped to one command and leaves an audit trail.