T
DataToolings

Linux Commands Cheat Sheet

A searchable Linux commands reference covering file management, permissions, networking, processes, and more. Copy any command instantly.

106 commands

pwd
navigation

Print current working directory

cd <dir>
navigation

Change directory

cd ..
navigation

Go up one directory

cd ~
navigation

Go to home directory

cd -
navigation

Go to previous directory

ls
navigation

List directory contents

ls -la
navigation

List all files with details (including hidden)

ls -lh
navigation

List files with human-readable sizes

tree
navigation

Display directory tree structure

touch <file>
files

Create an empty file or update timestamp

cp <src> <dest>
files

Copy file or directory

cp -r <src> <dest>
files

Copy directory recursively

mv <src> <dest>
files

Move or rename a file

rm <file>
files

Remove a file

rm -rf <dir>
files

Remove a directory and its contents recursively

mkdir <dir>
files

Create a new directory

mkdir -p <path>
files

Create nested directories

ln -s <target> <link>
files

Create a symbolic link

find <dir> -name "<pattern>"
files

Find files by name pattern

find <dir> -type f -newer <file>
files

Find files newer than a reference file

du -sh <dir>
files

Show directory size (human-readable)

df -h
files

Show disk space usage

stat <file>
files

Show detailed file metadata

file <file>
files

Determine file type

cat <file>
text

Print file contents

less <file>
text

View file with paging (q to quit)

head -n <n> <file>
text

Show first N lines of a file

tail -n <n> <file>
text

Show last N lines of a file

tail -f <file>
text

Follow file output in real time

grep "<pattern>" <file>
text

Search for pattern in file

grep -r "<pattern>" <dir>
text

Recursively search in directory

grep -i "<pattern>" <file>
text

Case-insensitive search

sed "s/<old>/<new>/g" <file>
text

Replace text in file output

awk "{print $1}" <file>
text

Print first field of each line

sort <file>
text

Sort lines in a file

sort -u <file>
text

Sort and remove duplicate lines

uniq <file>
text

Remove consecutive duplicate lines

wc -l <file>
text

Count lines in a file

diff <file1> <file2>
text

Compare two files line by line

cut -d "," -f 1 <file>
text

Cut fields by delimiter

tr "a-z" "A-Z"
text

Translate (convert) characters

chmod 755 <file>
permissions

Set permissions (rwxr-xr-x)

chmod +x <file>
permissions

Make file executable

chmod -R 644 <dir>
permissions

Set permissions recursively

chown <user>:<group> <file>
permissions

Change file owner and group

chown -R <user> <dir>
permissions

Change ownership recursively

umask 022
permissions

Set default permission mask

sudo <command>
permissions

Run command as superuser

su - <user>
permissions

Switch to another user

ps aux
processes

List all running processes

ps aux | grep <name>
processes

Find a specific process

top
processes

Interactive process viewer

htop
processes

Enhanced interactive process viewer

kill <pid>
processes

Terminate a process by PID

kill -9 <pid>
processes

Force-kill a process

pkill <name>
processes

Kill processes by name

killall <name>
processes

Kill all processes with given name

jobs
processes

List background jobs

bg %<n>
processes

Resume job N in background

fg %<n>
processes

Bring job N to foreground

nohup <cmd> &
processes

Run command immune to hangups

nice -n 10 <cmd>
processes

Run command with lower priority

ping <host>
networking

Check connectivity to a host

curl <url>
networking

Transfer data from/to a URL

curl -I <url>
networking

Fetch only HTTP headers

wget <url>
networking

Download a file from a URL

ssh <user>@<host>
networking

Connect to a remote host via SSH

scp <src> <user>@<host>:<dest>
networking

Copy file to remote host via SSH

rsync -avz <src> <dest>
networking

Sync files locally or remotely

netstat -tulnp
networking

List open ports and listening services

ss -tulnp
networking

Socket statistics (modern netstat)

ip addr
networking

Show network interfaces and IP addresses

ip route
networking

Show routing table

dig <domain>
networking

DNS lookup for a domain

nslookup <domain>
networking

Query DNS name server

traceroute <host>
networking

Trace packet route to host

nmap -p- <host>
networking

Scan all ports on a host

tar -czf <out.tar.gz> <dir>
archives

Create gzip-compressed tar archive

tar -xzf <file.tar.gz>
archives

Extract gzip tar archive

tar -cjf <out.tar.bz2> <dir>
archives

Create bzip2 tar archive

tar -xjf <file.tar.bz2>
archives

Extract bzip2 tar archive

tar -tf <file.tar.gz>
archives

List contents of tar archive

zip -r <out.zip> <dir>
archives

Create a zip archive

unzip <file.zip>
archives

Extract a zip archive

gzip <file>
archives

Compress a file with gzip

gunzip <file.gz>
archives

Decompress a gzip file

uname -a
system

Show system information

hostname
system

Show or set system hostname

uptime
system

Show system uptime and load average

free -h
system

Show memory usage (human-readable)

lscpu
system

Show CPU information

lsblk
system

List block devices (disks)

dmesg | tail
system

Show recent kernel messages

journalctl -xe
system

View systemd journal logs

systemctl status <service>
system

Check status of a service

systemctl start <service>
system

Start a systemd service

systemctl stop <service>
system

Stop a systemd service

systemctl enable <service>
system

Enable service to start on boot

crontab -e
system

Edit current user crontab

env
system

Print all environment variables

export VAR=value
system

Set an environment variable

echo $VAR
system

Print value of a variable

history
system

Show command history

alias ll="ls -la"
system

Create a command alias

which <cmd>
system

Show path of a command

man <cmd>
system

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

  1. Search for a command by name or description
  2. Filter by category using the buttons above the list
  3. Click the copy button to copy the command to your clipboard
  4. 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.