Key takeaways
- Learn navigation, file, permission and search commands first; they cover most daily work.
- Use man command or command --help to see options on your own system.
- Pipes connect commands: the output of one becomes the input of the next.
- Be careful with rm, chmod and sudo, especially with recursive options.
- Practise in a safe virtual machine or container before touching production.
What is Linux commands cheat sheet?
How do I use this cheat sheet?
Commands below work on most Linux distributions with a Bash shell. Options can differ slightly between systems, so confirm with man <command> or <command> --help. Practise in a virtual machine or a container, not on a live server.
How do I move around the file system?
pwd # show current directory
ls -la # list all files with details
cd /var/log # go to a directory
cd .. # go up one level
cd ~ # go to your home directory
tree -L 2 # show folder tree (if installed)
How do I work with files and folders?
mkdir -p app/logs # create nested folders
touch notes.txt # create an empty file
cp a.txt b.txt # copy a file
cp -r src backup # copy a folder
mv old.txt new.txt # move or rename
rm file.txt # delete a file
rm -r folder # delete a folder and contents (careful)
cat file.txt # print a file
less file.txt # scroll through a file
head -n 20 file.txt # first 20 lines
tail -n 20 file.txt # last 20 lines
tail -f app.log # follow a log as it grows
There is no recycle bin in the shell, so double-check before using rm -r.
How do permissions work?
ls -l shows permissions such as -rwxr-xr--: the first character is the type, then three sets of read (r), write (w) and execute (x) for the owner, group and others.
chmod 644 file.txt # owner read/write, others read
chmod +x script.sh # make executable
chown user:group file.txt # change owner and group
sudo command # run as administrator
Numeric values: read is 4, write is 2 and execute is 1, so 7 means all three. Avoid chmod 777, which gives everyone full access.
How do I search for text and files?
grep "error" app.log # lines containing error
grep -i "error" app.log # ignore case
grep -rn "TODO" src/ # search folders recursively with line numbers
find . -name "*.log" # find files by name
find /var -size +100M # find large files
wc -l file.txt # count lines
sort names.txt | uniq -c # count repeated lines
cut -d, -f1,3 data.csv # pick columns from a CSV
How do pipes and redirection work?
ls | wc -l # count files
cat app.log | grep ERROR | tail -5
echo "hello" > out.txt # write to file (overwrites)
echo "more" >> out.txt # append to file
command 2> errors.txt # send errors to a file
command > out.txt 2>&1 # send both to a file
How do I manage processes?
ps aux | grep nginx # find a process
top # live view of processes
kill 1234 # ask a process to stop
kill -9 1234 # force stop (last resort)
bg / fg / jobs # background and foreground jobs
nohup ./run.sh & # keep running after logout
How do I check disk, memory and the system?
df -h # disk space by file system
du -sh folder # size of a folder
free -h # memory use
uptime # load averages
uname -a # kernel and system info
whoami # current user
date # current date and time
How do I check the network?
ping -c 4 example.com # test reachability
curl -I https://example.com # fetch headers
curl -o file.zip https://example.com/file.zip
ip addr # IP addresses
ss -tulpn # listening ports
ssh user@host # remote login
scp file.txt user@host:/tmp/ # copy over SSH
How do I install software?
Debian and Ubuntu use sudo apt update and sudo apt install package. Red Hat family systems use sudo dnf install package. Check what a package does before installing, and prefer official repositories.
Which shell shortcuts save time?
Tab completes names, the up arrow recalls history, Ctrl+R searches history, Ctrl+C stops a command, Ctrl+L clears the screen, !! repeats the last command and history lists past commands.
What common mistakes should I avoid?
Running rm -rf with a wrong path or variable, using sudo when it is not needed, editing system files without a backup, forgetting quotes around names with spaces and pasting commands from the internet without reading them.
What small practice tasks help?
Create a folder with three text files, copy them, rename one, search for a word across all of them with grep, count the lines of each with wc, change a file's permission and list the result. Then write a short script that prints today's date and the disk space and make it executable. Repeating tasks like these builds speed more than reading the list. Keep a notes file of commands you forget and review it weekly.
Download Linux Commands Cheat Sheet PDF
Linux Commands Cheat Sheet PDF
The PDF carries the same content as this page in a clean, print-ready layout, so you can read it offline and keep it for revision.
4 pages · 111 KB · PDF · Updated 5 Nov 2026