DEV Community

Alex Chen
Alex Chen

Posted on

Linux Command Line: The 25 Commands I Use Every Day (2026)

Linux Command Line: The 25 Commands I Use Every Day (2026)

You don't need to memorize hundreds of commands. These 25 cover 90% of what I do daily in the terminal.

Navigation & Files

# 1. cd - Go back to previous directory
cd -                    # Toggle between last two directories
cd ~                    # Home directory
cd ..                   # Up one level
cd ../..                # Up two levels

# 2. ls — List files (my most-used alias: l)
ls                     # Basic list
ls -la                 # Detailed with hidden files
ls -lt                 # Sorted by time (newest first)
ls -lh                 # Human-readable sizes
ls -R                  # Recursive

# 3. find — Find anything, anywhere
find . -name "*.js"     # Find by name
find . -mtime -1        # Modified in last 24 hours
find . -size +100M      # Larger than 100MB
find . -type d -empty    # Find empty directories
find . -name "node_modules" -type d -prune -exec rm -rf {} +  # Delete all node_modules!

# 4. cat / head / tail — View file contents
cat config.json         # Print entire file
head -20 app.log        # First 20 lines
tail -f app.log         # Follow log in real-time (Ctrl+C to stop)
tail -n +50 file.txt    # From line 50 to end

# 5. grep — Search inside files
grep "error" *.log       # Find "error" in all log files
grep -r "TODO" src/      # Recursively search directory
grep -i "warning" app.js # Case insensitive
grep -n "function" *.js  # Show line numbers
grep -A5 "error" log.txt # 5 lines after match
grep --include="*.ts" "import" .  # Only TypeScript files
Enter fullscreen mode Exit fullscreen mode

Text Processing

# 6. sed — Stream editor (find & replace)
sed 's/old/new/g' file.txt          # Replace all occurrences
sed -i 's/foo/bar/g' config.json   # In-place replace
sed -n '10,20p' file.txt            # Print lines 10-20
sed '/^$/d' file.txt               # Delete empty lines
sed 's/^[ \t]*//' file.txt         # Trim leading whitespace

# 7. awk — Column processing
awk '{print $1, $3}' data.csv        # Columns 1 and 3
awk -F',' '{sum += $4} END {print sum}' data.csv  # Sum column 4
awk 'NR > 1 {print $2}' data.csv    # Skip header row
awk '$3 > 100' data.csv            # Filter rows where col 3 > 100
awk '{count++} END {print count}' file.txt  # Count lines

# 8. sort / uniq — Sort and deduplicate
sort names.txt           # Alphabetical sort
sort -rn numbers.txt     # Reverse numeric sort
sort -u names.txt        # Unique values only
uniq -c access.log       # Count duplicates (must sort first!)
sort | uniq -c | sort -rn | head -10  # Top 10 most common

# 9. wc — Word/line/char count
wc -l file.txt           # Line count
wc -w file.txt           # Word count
du -sh * | sort -rh      # Directory sizes sorted
Enter fullscreen mode Exit fullscreen mode

System Monitoring

# 10. htop / top — Process viewer
htop                     # Interactive process monitor (install it!)
top -o %CPU             # Sort by CPU usage
top -o %MEM             # Sort by memory usage

# 11. ps — Process listing
ps aux | grep node       # Find Node processes
ps aux --sort=-%mem | head -10  # Top 10 memory consumers
ps -ef | grep nginx       # Alternative format

# 12. kill — End processes
kill 12345               # Graceful terminate (SIGTERM)
kill -9 12345            # Force kill (SIGKILL)
pkill -f "node server"   # Kill by pattern
killall node             # Kill all processes named "node"

# 13. free / df — Memory and disk
free -h                  # Human-readable memory
df -h                    # Disk space per filesystem
du -sh * | sort -rh | head -10  # Largest items in current dir
ncdu /                   # Interactive disk usage analyzer (amazing tool!)

# 14. uptime / w — System status
uptime                   # Uptime + load average
w                        # Who's logged in + what they're doing
whoami                   # Current user
hostname                 # Server name
Enter fullscreen mode Exit fullscreen mode

Network

# 15. curl — HTTP requests
curl https://api.example.com/data           # GET request
curl -X POST -H "Content-Type: application/json" \
  -d '{"key":"value"}' https://api.example.com  # POST JSON
curl -I https://example.com                 # Headers only
curl -o output.zip https://example.com/file.zip  # Download file
curl -s > /dev/null -w "%{http_code}" URL   # Status code only

# 16. ss / netstat — Network connections
ss -tlnp                 # Listening ports (who's listening?)
ss -tlnp | grep :80     # What's on port 80?
ss -s                    # Connection summary

# 17. ping / dig — Network diagnostics
ping google.com           # Connectivity test
dig example.com           # DNS lookup
nslookup example.com      # Alternative DNS lookup
curl ifconfig.me          # Your public IP address
Enter fullscreen mode Exit fullscreen mode

File Operations

# 18. cp / mv — Copy and move
cp file.txt backup/       # Copy to directory
cp -r folder/ backup/     # Copy directory recursively
mv old.txt new.txt         # Rename
mv file.txt ~/Documents/  # Move

# 19. mkdir / rm — Create and remove
mkdir -p a/b/c            # Create nested directories
rm file.txt              # Delete file
rm -r folder/             # Delete directory
rm -rf folder/            # Force delete (no confirmation!)

# ⚠️ NEVER run: rm -rf / or sudo rm -rf /*

# 20. chmod / chown — Permissions and ownership
chmod +x script.sh        # Make executable
chmod 644 file.txt        # rw-r--r--
chmod 755 script.sh        # rwxr-xr-x
chown user:group file.txt  # Change owner and group
chown -R www-data:www-data /var/www  # Recursive ownership change

# 21. ln — Symbolic links
ln -s /path/to/target link-name  # Create symlink
readlink link-name        # Where does the link point?
Enter fullscreen mode Exit fullscreen mode

Git Essentials (in terminal)

# 22. git — The essentials
git status               # Current state
git diff                  # Unstaged changes
git add -p                # Stage interactively (review each change!)
git commit -m "message"  # Commit
git push                  # Push to remote
git pull --rebase        # Pull and rebase (clean history)
git log --oneline -10    # Recent commits
git stash                 # Temporarily save changes
git checkout -b feature   # New branch
Enter fullscreen mode Exit fullscreen mode

Process Management

# 23. nohup / bg / jobs — Background tasks
nohup npm start &         # Run in background, survives logout
npm start &               # Background (but dies on logout without nohup)
jobs                     # List background jobs
fg %1                    # Bring job 1 to foreground
bg %1                    # Resume suspended job in background
Ctrl+Z                   # Suspend current job

# 24. watch — Repeat command
watch -n 5 'free -h'      # Run every 5 seconds
watch -n 1 'kubectl get pods'  # Monitor K8s pods
watch -d -n 60 'ls -la'  # Highlight differences between runs

# 25. history / ! — Command history
history | grep curl       # Find past curl commands
!!                       # Repeat last command
!23                      # Run command number 23 from history
sudo !!                  # Repeat last command as root
Enter fullscreen mode Exit fullscreen mode

My Essential Aliases

# Add these to ~/.bashrc or ~/.zshrc:
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ../..'
alias gs='git status'
alias gp='git pull'
alias gc='git commit -m'
alias gd='git diff'
alias gl='git log --oneline --graph -15'
alias port='ss -tlnp'
alias myip='curl -s ifconfig.me'
alias cls=clear
alias q=exit
alias dfh='df -h'
alias duh='du -sh'
alias grep='grep --color=auto'

# Function aliases:
mkcd() { mkdir -p "$1" && cd "$1"; }
extract() {
  if [ -f "$1" ]; then
    case "$1" in
      *.tar.bz2) tar xjf "$1" ;;
      *.tar.gz) tar xzf "$1" ;;
      *.bz2) bunzip2 "$1" ;;
      *.rar) unrar x "$1" ;;
      *.gz) gunzip "$1" ;;
      *.tar) tar xf "$1" ;;
      *.tbz2) tar xjf "$1" ;;
      *.tgz) tar xzf "$1" ;;
      *.zip) unzip "$1" ;;
      *.Z) uncompress "$1" ;;
      *) echo "'$1' cannot be extracted via extract()" ;;
    esac
  fi
}
Enter fullscreen mode Exit fullscreen mode

What's your #1 daily command? Which one here is new to you?

Follow @armorbreak for more practical developer guides.

Top comments (0)