Linux Commands Cheatsheet
NEWLinux commands cheatsheet for the terminal: files, grep, find, permissions, processes, disk, network, tar, users and apt or dnf. Searchable with one-click copy.
Runs 100% in your browser — your input is never uploaded or stored on our servers.
105 entries in 12 sections
Navigation
pwdPrint the current directory.
ls -lahList files with details, hidden files and human-readable sizes.
cd <dir>Change directory.
cd ~Go to your home directory.
cd -Go back to the previous directory.
cd ..Go up one directory.
Files & folders
touch <file>Create an empty file or update its modified time.
mkdir -p a/b/cCreate a folder and any missing parent folders.
cp <src> <dest>Copy a file.
cp -r <dir> <dest>Copy a folder with its contents.
mv <src> <dest>Move or rename a file or folder.
rm <file>Delete a file.
rm -r <dir>Delete a folder and everything in it. There is no trash, so double-check the path.
ln -s <target> <link>Create a symbolic link.
file <name>Show what type of file something is.
View & search
cat <file>Print a file.
less <file>Page through a file (q to quit, / to search).
head -n 20 <file>Show the first 20 lines.
tail -n 20 <file>Show the last 20 lines.
tail -f <file>Follow a file as new lines are added, handy for logs.
wc -l <file>Count lines in a file.
grep "text" <file>Print lines that contain text.
grep -rn "text" .Search recursively and show line numbers.
grep -i "text" <file>Search ignoring case.
find . -name "*.log"Find files by name under the current folder.
find . -type f -mtime -1Find files modified in the last 24 hours.
awk '{print $1}' <file>Print the first column of each line.
sed 's/old/new/g' <file>Replace text and print the result (the file is not changed).
sed -i 's/old/new/g' <file>Replace text in the file itself (GNU sed).
sort <file> | uniq -cCount how often each distinct line appears.
Permissions
Numbers: r=4, w=2, x=1, added per owner, group, others.
chmod 644 <file>Owner can read and write, everyone else can only read.
chmod 755 <file>Owner can read, write and run; others can read and run.
chmod +x <file>Make a file executable.
chmod u+rw,go-w <file>Symbolic form: add read/write for owner, remove write for group and others.
chown user:group <file>Change the owner and group of a file.
chown -R user:group <dir>Change owner and group recursively.
ls -lShow permissions as strings like -rwxr-xr-x.
Processes
ps auxList all running processes.
ps aux | grep <name>Find a process by name.
topLive view of processes and resource use.
htopFriendlier live process viewer (often needs to be installed).
kill <pid>Ask a process to stop (sends SIGTERM).
kill -9 <pid>Force a process to stop (SIGKILL). Use only if a normal kill fails.
pkill <name>Stop processes by name.
command &Run a command in the background.
jobsList background jobs of the current shell.
nohup <command> &Keep a command running after you close the terminal.
Disk
df -hShow free and used space for each mounted disk.
du -sh <dir>Show the total size of a folder.
du -sh * | sort -hSize of each item here, sorted from smallest to largest.
lsblkList disks and partitions.
mountShow mounted file systems.
free -hShow used and free memory.
Network
ping -c 4 <host>Send 4 echo requests to check a host is reachable.
curl -I <url>Fetch only the response headers of a URL.
curl -O <url>Download a file and keep its name.
wget <url>Download a file.
ip addrShow network interfaces and IP addresses.
ss -tulpnList listening TCP and UDP ports with the owning process (may need sudo).
dig <domain>Look up DNS records for a domain.
traceroute <host>Show the route packets take to a host.
ssh user@hostOpen a secure shell on a remote machine.
scp <file> user@host:/pathCopy a file to a remote machine over SSH.
Archive & compress
tar -czf archive.tar.gz <dir>Create a gzip-compressed tar archive.
tar -xzf archive.tar.gzExtract a .tar.gz archive here.
tar -xzf archive.tar.gz -C <dir>Extract into a specific folder.
tar -tf archive.tar.gzList the contents of an archive without extracting.
zip -r archive.zip <dir>Create a zip file from a folder.
unzip archive.zipExtract a zip file.
gzip <file>Compress a file to file.gz (the original is replaced).
Users & sudo
whoamiPrint your user name.
idShow your user id and groups.
sudo <command>Run a command as the administrator (root).
su - <user>Switch to another user with their environment.
sudo adduser <name>Create a user (Debian and Ubuntu).
sudo usermod -aG <group> <user>Add a user to a group without removing existing groups.
passwdChange your password.
System info
uname -aShow kernel and system information.
cat /etc/os-releaseShow the Linux distribution name and version.
uptimeShow how long the system has been running and the load.
datePrint the current date and time.
lscpuShow CPU details.
envList environment variables.
historyList commands you ran before.
man <command>Open the manual page of a command.
Package managers
sudo apt updateRefresh the package list (Debian, Ubuntu).
sudo apt upgradeInstall available updates (Debian, Ubuntu).
sudo apt install <package>Install a package with apt.
sudo apt remove <package>Remove a package with apt.
apt search <term>Search packages with apt.
sudo dnf install <package>Install a package with dnf (Fedora, RHEL, Rocky, Alma).
sudo dnf remove <package>Remove a package with dnf.
sudo dnf upgradeUpdate all packages with dnf.
dnf search <term>Search packages with dnf.
Pipes & redirection
cmd1 | cmd2Send the output of cmd1 into cmd2.
cmd > fileWrite output to a file, replacing it.
cmd >> fileAppend output to a file.
cmd < fileRead input from a file.
cmd 2> errors.txtWrite only error messages to a file.
cmd > out.txt 2>&1Write both normal output and errors to one file.
cmd > /dev/null 2>&1Throw away all output.
cmd1 && cmd2Run cmd2 only if cmd1 succeeded.
cmd1 || cmd2Run cmd2 only if cmd1 failed.
cmd | tee fileShow output and save it to a file at the same time.
xargsTurn input lines into arguments, e.g. find . -name "*.tmp" | xargs rm.
Quick Examples
Typical inputs and the results this tool produces.
Overview
The Linux command line is powerful, but the right flags are easy to forget. This Linux commands cheatsheet lists the everyday commands for navigation, files, viewing and searching text with grep, find, awk and sed, permissions, processes, disk, network, archives, users and system information.
It also covers the apt and dnf package managers and the pipes and redirection operators that let you chain commands together. Commands that delete data, such as rm -r and kill -9, are described plainly so you know what they do before you run them.
Use the filter to narrow the list, then copy a command and replace placeholders like <file>. Everything runs in your browser and nothing you type is sent anywhere.
Why use this tool?
- Recall the right flags in seconds
- Covers files, network, disk and processes
- apt and dnf side by side
- Plain explanations, no jargon
- Copy any command with one click
Features
Files and navigation
ls, cd, cp, mv, rm, ln and mkdir -p with common options.
Search and text
grep, find, awk, sed, sort and uniq for working with output.
Permissions
chmod numbers and symbolic forms, plus chown.
Network tools
curl, wget, ip, ss, dig, ssh and scp.
apt and dnf
Install, remove, update and search packages on both families.
Pipes and redirection
Operators like |, >, >>, 2>&1, && and tee.
How to Use
Choose a section
Scroll to Files, Processes, Network or the topic you need.
Or filter
Type a word such as "port" or "tar" in the "Filter this cheatsheet" box.
Read what it does
Check the one-line description, especially for commands that delete data.
Copy and adapt
Press Copy, paste into your terminal and replace placeholders like <file>.