Linux Commands Cheat Sheet
A searchable Linux commands reference covering file management, permissions, networking, processes, and more. Copy any command instantly.
106 commands
pwdPrint current working directory
cd <dir>Change directory
cd ..Go up one directory
cd ~Go to home directory
cd -Go to previous directory
lsList directory contents
ls -laList all files with details (including hidden)
ls -lhList files with human-readable sizes
treeDisplay directory tree structure
touch <file>Create an empty file or update timestamp
cp <src> <dest>Copy file or directory
cp -r <src> <dest>Copy directory recursively
mv <src> <dest>Move or rename a file
rm <file>Remove a file
rm -rf <dir>Remove a directory and its contents recursively
mkdir <dir>Create a new directory
mkdir -p <path>Create nested directories
ln -s <target> <link>Create a symbolic link
find <dir> -name "<pattern>"Find files by name pattern
find <dir> -type f -newer <file>Find files newer than a reference file
du -sh <dir>Show directory size (human-readable)
df -hShow disk space usage
stat <file>Show detailed file metadata
file <file>Determine file type
cat <file>Print file contents
less <file>View file with paging (q to quit)
head -n <n> <file>Show first N lines of a file
tail -n <n> <file>Show last N lines of a file
tail -f <file>Follow file output in real time
grep "<pattern>" <file>Search for pattern in file
grep -r "<pattern>" <dir>Recursively search in directory
grep -i "<pattern>" <file>Case-insensitive search
sed "s/<old>/<new>/g" <file>Replace text in file output
awk "{print $1}" <file>Print first field of each line
sort <file>Sort lines in a file
sort -u <file>Sort and remove duplicate lines
uniq <file>Remove consecutive duplicate lines
wc -l <file>Count lines in a file
diff <file1> <file2>Compare two files line by line
cut -d "," -f 1 <file>Cut fields by delimiter
tr "a-z" "A-Z"Translate (convert) characters
chmod 755 <file>Set permissions (rwxr-xr-x)
chmod +x <file>Make file executable
chmod -R 644 <dir>Set permissions recursively
chown <user>:<group> <file>Change file owner and group
chown -R <user> <dir>Change ownership recursively
umask 022Set default permission mask
sudo <command>Run command as superuser
su - <user>Switch to another user
ps auxList all running processes
ps aux | grep <name>Find a specific process
topInteractive process viewer
htopEnhanced interactive process viewer
kill <pid>Terminate a process by PID
kill -9 <pid>Force-kill a process
pkill <name>Kill processes by name
killall <name>Kill all processes with given name
jobsList background jobs
bg %<n>Resume job N in background
fg %<n>Bring job N to foreground
nohup <cmd> &Run command immune to hangups
nice -n 10 <cmd>Run command with lower priority
ping <host>Check connectivity to a host
curl <url>Transfer data from/to a URL
curl -I <url>Fetch only HTTP headers
wget <url>Download a file from a URL
ssh <user>@<host>Connect to a remote host via SSH
scp <src> <user>@<host>:<dest>Copy file to remote host via SSH
rsync -avz <src> <dest>Sync files locally or remotely
netstat -tulnpList open ports and listening services
ss -tulnpSocket statistics (modern netstat)
ip addrShow network interfaces and IP addresses
ip routeShow routing table
dig <domain>DNS lookup for a domain
nslookup <domain>Query DNS name server
traceroute <host>Trace packet route to host
nmap -p- <host>Scan all ports on a host
tar -czf <out.tar.gz> <dir>Create gzip-compressed tar archive
tar -xzf <file.tar.gz>Extract gzip tar archive
tar -cjf <out.tar.bz2> <dir>Create bzip2 tar archive
tar -xjf <file.tar.bz2>Extract bzip2 tar archive
tar -tf <file.tar.gz>List contents of tar archive
zip -r <out.zip> <dir>Create a zip archive
unzip <file.zip>Extract a zip archive
gzip <file>Compress a file with gzip
gunzip <file.gz>Decompress a gzip file
uname -aShow system information
hostnameShow or set system hostname
uptimeShow system uptime and load average
free -hShow memory usage (human-readable)
lscpuShow CPU information
lsblkList block devices (disks)
dmesg | tailShow recent kernel messages
journalctl -xeView systemd journal logs
systemctl status <service>Check status of a service
systemctl start <service>Start a systemd service
systemctl stop <service>Stop a systemd service
systemctl enable <service>Enable service to start on boot
crontab -eEdit current user crontab
envPrint all environment variables
export VAR=valueSet an environment variable
echo $VARPrint value of a variable
historyShow command history
alias ll="ls -la"Create a command alias
which <cmd>Show path of a command
man <cmd>Show manual page for a command
Related Developer Tools
What is Linux Commands Cheat Sheet?
Linux Commands Cheat Sheet is a free, searchable reference of the most commonly used Linux shell commands. Browse by category — navigation, files, text, permissions, processes, networking, archives, and system — and copy any command with a single click. Whether you are a beginner learning the terminal or an experienced developer who needs a quick reminder, this reference has you covered.
How to Use
- Search for a command by name or description
- Filter by category using the buttons above the list
- Click the copy button to copy the command to your clipboard
- Replace placeholders like
<file>with your actual values before running
Features
- 106 commands across 8 categories
- Search by command name or description keyword
- Filter by category: navigation, files, text, permissions, processes, networking, archives, system
- One-click copy for each command
FAQ
What do the angle brackets mean?
Angle brackets like <file> are placeholders. Replace them with your actual value, e.g. rm myfile.txt. Never include the brackets themselves when running the command.
Are these commands compatible with macOS?
Most commands work on macOS as well, since macOS uses a BSD-based Unix shell. However, some flags differ (e.g., sed on macOS requires -i '' instead of -i). Install GNU coreutils via Homebrew for Linux-compatible behavior on macOS.
What is the difference between kill and kill -9?
kill <pid> sends a SIGTERM signal, giving the process a chance to clean up before exiting.kill -9 <pid> sends SIGKILL, which immediately terminates the process without cleanup. Use SIGKILL as a last resort.
How do I run a command in the background?
Append & to the command: my-script.sh &. Use nohup my-script.sh & to keep it running after you log out. Use jobs to list background jobs and fg to bring one to the foreground.