developer reference

Linux cheat sheet

A practical Linux reference with search, one-click copy and printable PDF output.

Go to commands
43
commands
7
categories
0
dependencies

43 commands visible

Files

8 commands
ls -lah

Lists files with details, hidden files and human-readable sizes

Filesafe
Practical example
ls -lah
ls -lah /etc
find <path> -name "<pattern>"

Finds files by name or attributes

Filesafe
Practical example
find . -name "*.py"
find /var -mtime -7 -type f  # modified in the last 7 days
find . -size +10M
cp -r <src> <dst>

Copies files or directories

Filesafe
Practical example
cp file.txt backup.txt
cp -r src/ dst/
mv <src> <dst>

Moves or renames files

Filesafe
Practical example
mv old.txt new.txt
mv *.log /var/logs/
rm -rf <path>

Removes files or directories, irreversible

Filecaution

Permanently deletes files and directories. Verify the resolved path before using -rf.

Practical example
rm file.txt
rm -rf ./tmpdir
mkdir -p <path>

Creates directories (-p also creates parents)

Filesafe
Practical example
mkdir -p /opt/myapp/logs
ln -s <target> <link>

Creates a symbolic link

Filesafe
Practical example
ln -s /opt/myapp /usr/local/bin/myapp
du -sh <path>

Size of files or directories

Filesafe
Practical example
du -sh /var/log
du -sh * | sort -h  # sort by size

Text processing

8 commands
cat <file>

Prints file content

Text processingsafe
Practical example
cat /etc/hosts
cat file1 file2 > merged.txt
grep -rn "<pattern>" <path>

Searches patterns in files/directories

Text processingsafe
Practical example
grep -rn "TODO" ./src
grep -v "^#" config.txt  # exclude comments
grep -E "error|warn" app.log
sed 's/<old>/<new>/g' <file>

Replaces text in files with a stream editor

Text processingsafe
Practical example
sed 's/http/https/g' urls.txt
sed -i 's/foo/bar/g' file.txt  # edit in place
awk '{ print $1 }' <file>

Processes and transforms text column by column

Text processingsafe
Practical example
awk '{print $1, $3}' data.txt
awk -F: '{print $1}' /etc/passwd  # list users
sort

Sorts lines (--numeric-sort, --reverse, -u unique)

Text processingsafe
Practical example
sort file.txt
sort -k2 -n data.txt
sort -u file.txt  # remove duplicates
cut -d'<sep>' -f<n>

Extracts columns from delimited text

Text processingsafe
Practical example
cut -d: -f1 /etc/passwd
cut -d',' -f2,4 data.csv
tail -f <file>

Shows last N lines; -f follows in real time

Text processingsafe
Practical example
tail -100 app.log
tail -f /var/log/syslog
wc -l <file>

Counts lines (-l), words (-w), characters (-c)

Text processingsafe
Practical example
wc -l access.log
grep "ERROR" app.log | wc -l

Processes

6 commands
ps aux

Lists all processes with CPU/RAM usage

Processessafe
Practical example
ps aux
ps aux | grep nginx
top

Interactive real-time process monitor

Processessafe
Practical example
top
top -u www-data  # filter by user
kill -<signal> <pid>

Sends a signal to a process

Processescaution

Verify the PID. Prefer SIGTERM; SIGKILL prevents cleanup and may lose unsaved data.

Practical example
kill -9 1234  # SIGKILL: force termination
kill -15 1234  # SIGTERM: request a clean shutdown
killall <name>

Kills all processes with that name

Processescaution

Targets all matching process names. Verify the name and signal first.

Practical example
killall nginx
nohup <cmd> &

Runs a command that survives logout

Processessafe
Practical example
nohup python3 server.py &
nohup ./script.sh > out.log 2>&1 &
jobs

Lists background jobs in the session

Processessafe
Practical example
jobs
bg %1  # send to the background
fg %1  # return to the foreground

Permissions

4 commands
chown <user>:<group> <file>

Changes owner of files/directories

Permissionssafe
Practical example
chown www-data:www-data /var/www
chown -R enzo:enzo /opt/myapp
sudo <cmd>

Runs a command as superuser

Permissionssafe
Practical example
sudo apt update
sudo -u postgres psql  # as another user
sudo visudo

Safely edits the sudoers file

Permissionssafe
Practical example
sudo visudo

Network

6 commands
curl -X <METHOD> <url>

Transfers HTTP/FTP data from the command line

Networksafe
Practical example
curl -X GET https://api.example.com/users
curl -X POST -H "Content-Type: application/json" -d '{"k":"v"}' <url>
curl -O https://example.com/file.zip
ssh <user>@<host>

Remote SSH connection

Networksafe
Practical example
ssh enzo@192.168.1.100
ssh -i ~/.ssh/id_rsa user@server
ssh -L 8080:localhost:80 user@server  # tunnel
scp <src> <user>@<host>:<dst>

Copies files over SSH

Networksafe
Practical example
scp file.txt enzo@server:/home/enzo/
scp -r ./dist user@server:/var/www/
ss -tulnp

Shows listening ports with processes

Networksafe
Practical example
ss -tulnp
ss -tulnp | grep 8080
ip addr

Shows network interfaces and IP addresses

Networksafe
Practical example
ip addr
ip addr show eth0
ping -c 4 <host>

Checks connectivity with a host

Networksafe
Practical example
ping -c 4 google.com
ping -c 1 192.168.1.1

Disk

4 commands
df -h

Free space per filesystem

Disksafe
Practical example
df -h
df -h /var
lsblk

Lists block devices and partitions

Disksafe
Practical example
lsblk
lsblk -f  # include filesystems
tar -czf <archive.tar.gz> <path>

Creates a gzip-compressed archive

Disksafe
Practical example
# create
tar -czf backup.tar.gz /opt/myapp
# extract
tar -xzf backup.tar.gz -C /tmp
# list archive contents
tar -tzf backup.tar.gz
rsync -avz <src> <dst>

Efficient file synchronization, local or SSH

Disksafe
Practical example
rsync -avz ./dist/ user@server:/var/www/
rsync -avz --delete src/ dst/

System

7 commands
uname -a

Kernel version and system info

Systemsafe
Practical example
uname -a
uptime

Uptime and load average

Systemsafe
Practical example
uptime
uptime -p  # human-readable
systemctl <action> <service>

Manages systemd services

Systemsafe
Practical example
systemctl start nginx
systemctl enable nginx
systemctl status nginx
systemctl restart nginx
journalctl -u <service> -f

systemd logs for a service, follow mode

Systemsafe
Practical example
journalctl -u nginx -f
journalctl -u nginx --since "1 hour ago"
env

Shows environment variables

Systemsafe
Practical example
env
env | grep PATH
export VAR=value

Sets an environment variable for the session

Systemsafe
Practical example
export NODE_ENV=production
export PATH="$PATH:/opt/myapp/bin"
crontab -e

Edits current user cron jobs

Systemsafe
Practical example
# format: minute hour day month weekday command
0 2 * * * /opt/backup.sh  # every night at 02:00
*/5 * * * * /opt/check.sh  # every 5 minutes

How to use this Linux cheat sheet

Why should files and directories use different permissions?

Directories require the execute bit to traverse them. Applying 644 recursively makes directories inaccessible; set directory and file permissions separately for your use case.

Can I print this sheet as a PDF?

Use Print PDF. The printable version includes all commands and practical examples, including sections hidden by a search.

Can I use it locally?

Yes. Serve the static files with a local HTTP server. Search, filters and copying run in your browser; the Regex tester requires a worker-enabled HTTP context.