Click a topic below to jump to that section


File Operations

Essential commands for working with files in Linux.

Basic File Commands

  • ls — List directory contents
  • ls -l — List with detailed information (long format)
  • ls -a — List all files including hidden files
  • ls -lh — List with human-readable file sizes
  • cat FILE — Display file contents
  • less FILE — View file contents page by page
  • head FILE — Display first 10 lines of a file
  • tail FILE — Display last 10 lines of a file
  • tail -f FILE — Follow file updates in real-time
  • cp SOURCE DEST — Copy files or directories
  • cp -r SOURCE DEST — Copy directories recursively
  • mv SOURCE DEST — Move or rename files/directories
  • rm FILE — Remove files
  • rm -r DIRECTORY — Remove directories recursively
  • rm -f FILE — Force remove without confirmation
  • touch FILE — Create empty file or update timestamp
  • mkdir DIRECTORY — Create directory
  • mkdir -p PATH — Create directory and parent directories
  • rmdir DIRECTORY — Remove empty directory

Directory Navigation

Commands for navigating the filesystem.

Navigation Commands

  • pwd — Print working directory (show current path)
  • cd DIRECTORY — Change directory
  • cd ~ — Change to home directory
  • cd .. — Move up one directory level
  • cd - — Return to previous directory
  • cd / — Change to root directory

File Permissions

Managing file and directory permissions.

Permission Commands

  • chmod PERMISSIONS FILE — Change file permissions
  • chmod 755 FILE — Set permissions: owner read/write/execute, group/others read/execute
  • chmod +x FILE — Add execute permission
  • chmod -w FILE — Remove write permission
  • chown USER:GROUP FILE — Change file owner and group
  • chown -R USER:GROUP DIRECTORY — Change ownership recursively
  • chgrp GROUP FILE — Change file group

Text Processing

Commands for viewing, searching, and manipulating text.

Text Commands

  • grep PATTERN FILE — Search for patterns in files
  • grep -r PATTERN DIRECTORY — Search recursively in directories
  • grep -i PATTERN FILE — Case-insensitive search
  • sed 's/OLD/NEW/g' FILE — Find and replace text
  • awk '{print $1}' FILE — Print first column of each line
  • sort FILE — Sort lines alphabetically
  • sort -n FILE — Sort numerically
  • wc FILE — Count lines, words, and characters
  • wc -l FILE — Count lines only

System Information

Commands to view system status and information.

System Commands

  • uname -a — Display system information
  • whoami — Display current username
  • id — Display user and group IDs
  • uptime — Show system uptime and load average
  • df -h — Display disk space usage in human-readable format
  • du -h DIRECTORY — Show directory size in human-readable format
  • free -h — Display memory usage
  • top — Display running processes (interactive)
  • htop — Enhanced process viewer (if installed)
  • history — Display command history
  • date — Display current date and time
  • cal — Display calendar

Process Management

Commands for managing running processes.

Process Commands

  • ps — Display running processes
  • ps aux — Display all processes with details
  • ps -ef — Display all processes in full format
  • kill PID — Terminate process by ID
  • kill -9 PID — Force kill process
  • killall PROCESS_NAME — Kill all processes by name
  • pkill PATTERN — Kill processes matching pattern
  • jobs — List background jobs
  • fg — Bring background job to foreground
  • bg — Resume suspended job in background

Networking

Commands for network configuration and troubleshooting.

Network Commands

  • ifconfig — Display network interface configuration
  • ip addr — Display IP addresses (modern alternative)
  • ip a — Short form of ip addr
  • ping HOST — Test network connectivity
  • ping -c 4 HOST — Send 4 ping packets
  • netstat -tulpn — Display network connections and listening ports
  • ss -tulpn — Modern alternative to netstat
  • curl URL — Transfer data from server
  • wget URL — Download files from web
  • ssh USER@HOST — Connect to remote host via SSH
  • scp FILE USER@HOST:PATH — Copy file over SSH
  • traceroute HOST — Trace route to host
  • dig DOMAIN — DNS lookup tool
  • host DOMAIN — DNS lookup (simpler than dig)

Search & Find

Commands for locating files and content.

Search Commands

  • find DIRECTORY -name "PATTERN" — Find files by name
  • find DIRECTORY -type f -name "*.txt" — Find all .txt files
  • find DIRECTORY -type d — Find all directories
  • find DIRECTORY -size +100M — Find files larger than 100MB
  • find DIRECTORY -mtime -7 — Find files modified in last 7 days