Searchable reference of common Linux/Unix shell commands grouped by task.
52 of 52 commands — click any row to copy
ls -la
List all files (including hidden) in long format
cd <dir>
Change the current working directory
pwd
Print the current working directory
mkdir -p <dir>
Create a directory, including any missing parent directories
cp -r <src> <dst>
Copy files/directories recursively
mv <src> <dst>
Move or rename a file or directory
rm -rf <path>
Recursively and forcibly remove files/directories — use with care
find . -name "*.log"
Recursively search for files matching a pattern
ln -s <target> <link>
Create a symbolic link
tree
Display directory structure as a tree
chmod 755 <file>
Set read/write/execute permissions (rwxr-xr-x)
chmod +x <file>
Make a file executable
chown user:group <file>
Change the owner and group of a file
sudo <command>
Run a command with superuser (root) privileges
cat <file>
Print the contents of a file to stdout
less <file>
View a file's contents page by page
head -n 20 <file>
Show the first 20 lines of a file
tail -f <file>
Continuously stream new lines appended to a file (e.g. logs)
grep -ri "text" <path>
Recursively, case-insensitively search for text in files
sed -i 's/old/new/g' <file>
Find and replace text in a file in-place
awk '{print $1}' <file>
Extract and print the first column of each line
wc -l <file>
Count the number of lines in a file
diff file1 file2
Show line-by-line differences between two files
ps aux
List all running processes with detailed info
top
Display real-time view of running processes and resource usage
htop
Interactive process viewer (improved top)
kill -9 <pid>
Forcibly terminate a process by PID (SIGKILL)
killall <name>
Terminate all processes matching a name
jobs
List background jobs running in the current shell
nohup <command> &
Run a command immune to hangups, in the background
ping <host>
Send ICMP echo requests to test connectivity to a host
curl -I <url>
Fetch only the HTTP headers of a URL
wget <url>
Download a file from a URL
ssh user@host
Connect to a remote machine via SSH
scp file user@host:/path
Securely copy a file to a remote machine
netstat -tulpn
List listening ports and the processes using them
dig <domain>
Query DNS records for a domain
df -h
Show disk space usage in human-readable form
du -sh <dir>
Show the total size of a directory
free -h
Show memory (RAM) usage in human-readable form
uname -a
Print system/kernel information
uptime
Show how long the system has been running and load averages
whoami
Print the current user's username
history
Show command history for the current shell
tar -czvf out.tar.gz <dir>
Create a gzip-compressed tarball from a directory
tar -xzvf file.tar.gz
Extract a gzip-compressed tarball
zip -r out.zip <dir>
Create a zip archive from a directory
unzip file.zip
Extract a zip archive
export VAR=value
Set an environment variable for the current shell session
echo $PATH
Print the value of the PATH environment variable
alias ll='ls -la'
Create a shorthand alias for a command
which <command>
Show the full path of a command