appzasGamesToolsDevLearnCheat sheetsQuick calcsConvertersReferenceNetworkTimeCalculatorsCompareLLM prices

Linux cheat sheet

Free and printable

The commands most people reach for on a Linux server or in a terminal.

Navigate

pwd
Print the current folder
ls -la
List all files with details
cd <folder>
Change folder
cd ..
Go up one level
cd ~
Go to your home folder

Files

mkdir <name>
Create a folder
touch <file>
Create an empty file or update its time
cp <from> <to>
Copy a file (-r for folders)
mv <from> <to>
Move or rename
rm <file>
Delete a file (-r for folders, no undo)
cat <file>
Print a file
less <file>
Page through a file (q to quit)
head -n 20 <file>
First 20 lines
tail -f <file>
Follow new lines as they are written

Search

grep "text" <file>
Lines containing text
grep -ri "text" .
Search folders recursively, ignoring case
find . -name "*.log"
Find files by name
wc -l <file>
Count lines
sort | uniq -c
Count repeated lines in a pipe

Permissions

chmod 644 <file>
Owner read/write, others read
chmod 600 <file>
Owner only (use for SSH private keys)
chmod +x <file>
Make a file executable
chown user:group <file>
Change owner and group
sudo <command>
Run as administrator

Processes

ps aux
List all processes
top
Live view of processes (q to quit)
kill <pid>
Ask a process to stop
kill -9 <pid>
Force a process to stop
systemctl status <service>
State of a service
systemctl restart <service>
Restart a service
journalctl -u <service> -n 50
Last 50 log lines of a service

System

df -h
Disk space by filesystem
du -sh <folder>
Size of a folder
free -h
Memory use
uname -a
Kernel and system information
ss -tlnp
Listening TCP ports and their programs
tar -czf out.tar.gz <folder>
Create a compressed archive
tar -xzf out.tar.gz
Extract an archive

More cheat sheets