🐧 Complete Linux Commands with Examples

📁 Filesystem Commands

ls -al          # List all files with permissions
cd /path        # Change directory
pwd             # Print working directory
mkdir dir       # Make directory
rm file         # Remove file
rm -rf dir      # Remove directory recursively
cp file1 file2  # Copy file
mv file1 file2  # Move/rename file
find / -name "file.txt"     # Find file by name
locate file.txt              # Faster file location using database
stat file.txt               # Show file status
tree                       # Show directory tree
file filename              # Determine file type

⚙️ Process Management

ps aux                      # Show all running processes
top                        # Dynamic real-time process viewer
htop                       # Interactive process viewer
kill -9 PID                # Force kill a process
pkill firefox              # Kill by process name
nice -n 10 process         # Start process with priority
renice -n -5 -p PID        # Change priority of running process
jobs                       # Show background jobs
fg %1                      # Bring job to foreground
bg %1                      # Resume job in background
nohup command &            # Run command immune to hangups

🌐 Networking

ip a                        # Show interfaces
ping 8.8.8.8               # Send ICMP packets
traceroute google.com      # Trace path
netstat -tulnp             # List listening ports
ss -tulwn                  # Faster netstat
curl http://example.com    # Transfer data with URL syntax
wget http://example.com    # Download from web
nmap -sS 192.168.1.1       # Network scan
host google.com            # DNS lookup
dig google.com             # Detailed DNS info
nmcli device status        # NetworkManager status

👥 User & Group Management

whoami                     # Current user
id                         # UID, GID
useradd user               # Add user
passwd user                # Set password
usermod -aG group user     # Add user to group
deluser user               # Delete user
groupadd devs              # Create group
groupdel devs              # Delete group
su - user                  # Switch user
sudo command               # Run as superuser

🔐 File Permissions

chmod 755 file             # Set execute permission
chmod +x script.sh        # Make executable
chown user:group file     # Change ownership
umask                     # Default permission mask
ls -l                     # View permissions
getfacl file              # View ACLs
setfacl -m u:john:rw file # Set ACL

📦 Package Management

# Debian/Ubuntu
apt update
apt upgrade -y
apt install nginx
apt remove nginx
apt search apache

# RHEL/CentOS
yum install httpd
dnf install git
rpm -qa | grep nginx

# Snap
snap find vlc
snap install vlc

💽 Disk & Storage

df -h                     # Disk space
lsblk                    # Block devices
du -sh *                 # Directory sizes
mount /dev/sdX /mnt      # Mount device
umount /mnt              # Unmount
mkfs.ext4 /dev/sdX       # Format disk
fsck /dev/sdX            # Check disk errors
tune2fs -l /dev/sdX      # Filesystem info
parted /dev/sdX          # Partition tool

🔧 System Services (systemd)

systemctl start nginx     # Start service
systemctl stop nginx      # Stop
systemctl restart nginx   # Restart
systemctl status nginx    # Status
systemctl enable nginx    # Enable on boot
systemctl disable nginx   # Disable
journalctl -u nginx       # View logs
systemctl list-units --type=service

📜 Shell Scripting

#!/bin/bash
# hello.sh
echo "Hello, World!"

# If-Else
if [ $USER == root ]; then
  echo "Root user"
else
  echo "Not root"
fi

# For loop
for i in {1..5}; do echo $i; done

# Read input
read -p "Enter name: " name
echo "Hi $name"

📊 Monitoring & Performance

uptime                     # System uptime
free -h                   # Memory usage
vmstat                    # Virtual memory
sar -u 1 3                # CPU usage (sysstat)
watch -n 1 df -h          # Periodic disk check
top / htop                # Processes
pidstat -p PID            # Per-process stats
iostat                    # I/O stats
lsof                      # List open files

🛠️ System Administration

crontab -e                 # Edit user cron jobs
at now + 1 min            # Schedule one-time job
hostnamectl               # Change hostname
timedatectl set-timezone Asia/Kolkata
reboot                    # Reboot
shutdown now              # Power off
alias l='ls -la'          # Create alias

📚 Others & Utilities

echo "text" > file         # Write to file
echo $HOME                # Show environment var
export VAR=value          # Set variable
tar -czf archive.tar.gz dir
unzip file.zip
xargs rm < files.txt
history                   # Show command history
man ls                    # Manual page
which bash                # Show path to binary
whereis bash              # Binary + source + man

✅ This complete Linux command reference covers most commands used in daily, professional, and advanced use cases with examples. Ideal for interviews, scripting, automation, and certification labs.