🐧 Daily Linux Commands

Frequently used Linux commands for daily operations

📂 File and Directory Commands

📑 Viewing and Editing Files

🔍 Searching & Filtering

  • grep "text" filename - Search for text in file
  • grep -r "text" /path - Recursive search in directories
  • find /path -name "file.txt" - Find files by name
  • find /path -type f -size +10M - Find large files
  • sort filename - Sort file content
  • uniq filename - Remove duplicate lines

📊 Disk and System Info

  • df -h - Disk space usage
  • du -sh * - Size of each file/folder
  • free -h - Memory usage
  • uptime - System load and uptime
  • uname -a - Kernel and system info
  • top or htop - Running processes
  • who / w - Logged-in users

🛠️ Permissions & Ownership

  • chmod +x script.sh - Make a script executable
  • chown user:group file - Change file owner
  • chmod 755 file - Set permissions (rwxr-xr-x)
  • umask - View default permissions mask

🌐 Network Commands

  • ping google.com - Test connectivity
  • curl -I http://example.com - Fetch HTTP headers
  • wget http://example.com/file - Download file
  • ss -tuln or netstat -tuln - Show listening ports
  • ip a - Show network interfaces

📦 Package Management

Debian / Ubuntu (APT)

  • sudo apt update - Refresh package database
  • sudo apt upgrade - Install available updates
  • sudo apt install pkg - Install a package
  • sudo apt remove pkg - Remove package
  • dpkg -l - List all installed packages
  • sudo dpkg -i file.deb - Install a downloaded .deb package

RHEL / CentOS / Fedora (YUM / DNF)

  • sudo yum update - Update packages
  • sudo yum install pkg or sudo dnf install pkg - Install
  • sudo yum remove pkg - Remove package
  • sudo rpm -ivh file.rpm - Install a local .rpm file
  • rpm -qa - List installed packages
  • rpm -ql packagename - Show installed files of a package

⚙️ Process Management

  • ps aux - List all running processes
  • kill PID - Kill process by PID
  • kill -9 PID - Force kill a process by PID
  • jobs / bg / fg - Manage background jobs
  • htop - Interactive process viewer (if installed)

⏲️ Scheduling Jobs

  • crontab -e - Edit scheduled tasks
  • crontab -l - List user cron jobs
  • at 10:00 - Run command at specific time

💡 Tips

  • Use man command to get help on any command.
  • Use --help with most commands for quick reference.
  • Always double-check before using rm -rf or sudo.