Essential Linux Commands
ITComplete guide to the most used Linux commands for system administration, networking, file and process management. Interactive cheatsheet with practical examples.
File Viewing & Editing
cat
Display file contents
cat /etc/passwd
less
View file with pagination
less /var/log/syslog
more
View file with pagination
more file.txt
head
Show first lines
head -n 20 file.txt
tail
Show last lines
tail -f /var/log/syslog
nano
Simple text editor
nano config.php
vim
Advanced text editor
vim script.sh
grep
Search pattern in text
grep -r "error" /var/log/
sed
Stream editor
sed -i "s/old/new/g" file.txt
awk
Text processing
awk '{print $1}' file.txt
wc
Count lines/words/chars
wc -l file.txt
diff
Compare files
diff file1.txt file2.txt
Permissions & Ownership
chmod
Change permissions
chmod 755 script.sh
chown
Change owner
chown user:group file
chgrp
Change group
chgrp www-data file
umask
Set default permissions
umask 022
stat
Show detailed file info
stat file.txt
getfacl
Show ACL
getfacl file.txt
setfacl
Set ACL
setfacl -m u:user:rwx file
Process Management
ps
Show processes
ps aux
top
Real-time process monitor
top
htop
Interactive process monitor
htop
kill
Terminate process
kill -9 1234
killall
Kill processes by name
killall nginx
pkill
Kill processes by pattern
pkill -f "python"
bg
Send process to background
bg %1
fg
Bring process to foreground
fg %1
jobs
List background jobs
jobs
nohup
Run immune to hangup
nohup script.sh &
screen
Terminal multiplexer
screen -S session
tmux
Advanced terminal multiplexer
tmux new -s name
Networking
ip
Configure network interfaces
ip addr show
ifconfig
Configure interfaces (legacy)
ifconfig eth0
ping
Test connectivity
ping -c 4 google.com
traceroute
Trace packet route
traceroute google.com
netstat
Network statistics
netstat -tulpn
ss
Socket statistics
ss -tulpn
curl
URL transfer
curl -I https://example.com
wget
Download files
wget https://example.com/file
scp
Secure copy via SSH
scp file user@host:/path
rsync
Sync files/directories
rsync -avz src/ dest/
ssh
SSH connection
ssh user@192.168.1.1
nslookup
DNS query
nslookup google.com
dig
Advanced DNS query
dig +short google.com
host
DNS lookup
host google.com
iptables
Firewall rules
iptables -L -n
ufw
Simplified firewall
ufw status
System Information
uname
System info
uname -a
hostname
Host name
hostname
uptime
System uptime
uptime
whoami
Current user
whoami
id
User/group info
id
df
Disk space
df -h
du
Directory disk usage
du -sh *
free
Available memory
free -h
lscpu
CPU info
lscpu
lsblk
List block devices
lsblk
lsusb
List USB devices
lsusb
dmesg
Kernel messages
dmesg | tail
journalctl
Systemd logs
journalctl -xe
User Management
useradd
Create user
useradd -m username
userdel
Delete user
userdel -r username
usermod
Modify user
usermod -aG sudo user
passwd
Change password
passwd username
groupadd
Create group
groupadd developers
groupdel
Delete group
groupdel developers
groups
Show user groups
groups username
su
Switch user
su - root
sudo
Execute as superuser
sudo apt update
visudo
Edit sudoers
visudo
Compression & Archives
tar
Archive files
tar -czvf archive.tar.gz dir/
tar -x
Extract archive
tar -xzvf archive.tar.gz
gzip
Compress file
gzip file.txt
gunzip
Decompress .gz
gunzip file.txt.gz
zip
Create zip archive
zip -r archive.zip dir/
unzip
Extract zip archive
unzip archive.zip
bzip2
Compress with bzip2
bzip2 file.txt
xz
Compress with xz
xz file.txt
Services & Systemd
systemctl start
Start service
systemctl start nginx
systemctl stop
Stop service
systemctl stop nginx
systemctl restart
Restart service
systemctl restart nginx
systemctl status
Service status
systemctl status nginx
systemctl enable
Enable auto-start
systemctl enable nginx
systemctl disable
Disable auto-start
systemctl disable nginx
systemctl list-units
List active services
systemctl list-units --type=service
service
Manage services (legacy)
service nginx status
Package Management
apt update
Update package list (Debian)
sudo apt update
apt upgrade
Upgrade packages (Debian)
sudo apt upgrade
apt install
Install package (Debian)
sudo apt install nginx
apt remove
Remove package (Debian)
sudo apt remove nginx
apt search
Search package (Debian)
apt search nginx
yum install
Install package (RHEL)
sudo yum install nginx
dnf install
Install package (Fedora)
sudo dnf install nginx
pacman -S
Install package (Arch)
sudo pacman -S nginx
No commands found for your search.