Linux Commands Cheat Sheet
06/03/2025
A comprehensive reference guide to essential Linux commands for system administration and everyday use
Note: Some commands may require sudo privileges depending on your system configuration. Commands are organized by category for easy reference.
System Information
Display Linux system information
uname -a
Display kernel release information
uname -r
Show OS information (distribution and version)
cat /etc/os-release
Show system uptime and load
uptime
Show system hostname
hostname
Display all local IP addresses
hostname -I
Show system reboot history
last reboot
Show current date and time
date
Show this month's calendar
cal
Show who is currently logged in
w
Show your current username
whoami
Hardware Information
Display messages in kernel ring buffer
dmesg
Display CPU information
cat /proc/cpuinfo
Display memory information
cat /proc/meminfo
Display free and used memory (human readable)
free -h
Display PCI devices
lspci -tv
Display USB devices
lsusb -tv
Display hardware info from BIOS
dmidecode
Show info about disk sda
hdparm -i /dev/sda
Perform read speed test on disk sda
hdparm -tT /dev/sda
Performance Monitoring
Display and manage top processes
top
Interactive process viewer (top alternative)
htop
Display processor related statistics
mpstat 1
Display virtual memory statistics
vmstat 1
Display I/O statistics
iostat 1
Display the last 100 syslog messages
tail -100 /var/log/messages
Monitor all traffic on port 80 (HTTP)
tcpdump -i eth0 'port 80'
List all open files on the system
lsof
Execute "df -h", showing periodic updates
watch df -h
User Management
Display user and group IDs
id
Display last logged in users
last
Show who is logged into the system
who
Show who is logged in and what they're doing
w
Create a group named "test"
groupadd test
Create a user account with home directory
useradd -c "John Smith" -m john
Delete the user account "john"
userdel john
Add user to a group
usermod -aG sales john
File and Directory Commands
List all files in long format
ls -al
Display present working directory
pwd
Create a directory
mkdir directory
Remove (delete) file
rm file
Remove directory recursively
rm -r directory
Force removal without prompting
rm -f file
Copy file1 to file2
cp file1 file2
Copy directory recursively
cp -r source_dir destination
Rename or move file
mv file1 file2
Create symbolic link
ln -s /path/to/file linkname
Create an empty file or update timestamp
touch file
File Content Commands
View the contents of a file
cat file
Browse through a text file
less file
Display the first 10 lines of file
head file
Display the last 10 lines of file
tail file
Display the last 10 lines and follow updates
tail -f file
Search for pattern in file
grep pattern file
Search recursively for pattern in directory
grep -r pattern directory
Find files and directories by name
find /path -name filename
Find files larger than 100MB
find /path -size +100M
Process Management
Display your currently running processes
ps
Display all running processes
ps -ef
Display process information for processname
ps -ef | grep processname
Kill process with process ID of pid
kill pid
Kill all processes named processname
killall processname
Start program in the background
program &
Display stopped or background jobs
bg
Bring most recent background job to foreground
fg
Bring job n to the foreground
fg n
File Permissions
Change file permissions (full access)
chmod 777 filename
Change file permissions (rwx for owner, rx for group/world)
chmod 755 filename
Change file permissions (rw for owner, r for group/world)
chmod 644 filename
Change file owner
chown user:group filename
Change file permissions recursively
chmod -R 755 directory
Change file owner recursively
chown -R user:group directory
Networking
Display all network interfaces and IP address
ip a
Display eth0 address and details
ip addr show dev eth0
Send ICMP echo request to host
ping host
Display whois information for domain
whois domain
Display DNS information for domain
dig domain
Reverse lookup of IP_ADDRESS
dig -x IP_ADDRESS
Download file from URL
wget http://domain.com/file
Display listening ports and programs
netstat -nutlp
Archives (TAR Files)
Create tar archive
tar cf archive.tar directory
Extract the contents from archive
tar xf archive.tar
Create a gzip compressed tar file
tar czf archive.tar.gz directory
Extract a gzip compressed tar file
tar xzf archive.tar.gz
Create a tar file with bzip2 compression
tar cjf archive.tar.bz2 directory
Extract a bzip2 compressed tar file
tar xjf archive.tar.bz2
Package Installation
Update package lists (Debian/Ubuntu)
apt update
Install package (Debian/Ubuntu)
apt install package
Remove package (Debian/Ubuntu)
apt remove package
Search for package (Red Hat/CentOS)
yum search keyword
Install package (Red Hat/CentOS)
yum install package
Remove package (Red Hat/CentOS)
yum remove package
SSH and File Transfer
Connect to host as your local username
ssh host
Connect to host as user
ssh user@host
Connect to host using port
ssh -p port user@host
Secure copy file to remote host
scp file.txt server:/path
Copy files from remote host to local
scp server:/path/file.txt /local/path
Synchronize local to remote
rsync -avz /local/ server:/remote/
Disk Usage
Show free and used space on mounted filesystems
df -h
Show free and used inodes on mounted filesystems
df -i
Display disk usage for all files and directories
du -ah
Display total disk usage off the current directory
du -sh
Shell Shortcuts
Clear the terminal screen
Ctrl+L
Stop the current command
Ctrl+C
Sleep the current command
Ctrl+Z
End of file (EOF)
Ctrl+D
Cut from cursor to start of line
Ctrl+U
Cut from cursor to end of line
Ctrl+K
Paste from clipboard
Ctrl+Y
Search command history
Ctrl+R