LC
Back to Tutorials
devopsbeginnerOctober 15, 2024

Linux Commands Cheat Sheet for Developers

Essential Linux commands for process monitoring, file searching, archiving, and system troubleshooting.

linuxbashclisysadmin

Frequently used Linux commands for day-to-day development and server administration.

Process Monitoring

bash
      # Real-time process viewer
top

# Interactive process monitor (better UI)
htop

# Monitor disk I/O per process
iotop

    

Finding Files

bash
      # Find by name (case-sensitive)
find ~ -name "foo"

# Find by name (case-insensitive)
find ~ -iname "foo"

# Find only directories
find . -type d -name "Doc*"

# Find only files
find . -type f -name "*.log"

# Find files containing a string
find . -type f -exec grep -l "search_term" {} +

# Find PHP files by extension
find /search/dir/ -type f -name "*.php" -print0 | xargs -I {} -0 grep "foo" "{}"

    

File Type Flags for find

FlagType
dDirectory
fFile
lSymbolic link
sSocket
pNamed pipe (FIFO)
bBlock special

Searching File Content

bash
      # Recursively find PHP files NOT starting with a comment
grep -rvlz $'^[[:space:]]*<?php\n/\*' --include='*.php'

    

Archiving

bash
      # Create tar.gz archive
tar -czf backup.tar.gz /path/to/dir

# Extract tar.gz
tar -xzf backup.tar.gz

# Zip multiple files
zip archive.zip file1 file2 file3

    

Journal Logs

bash
      # View system logs
journalctl -xe

# Follow logs in real-time
journalctl -f

# Filter by service
journalctl -u nginx.service --since "1 hour ago"