Back to Home
    LinuxLinux Kernel 6.xBeginner

    Linux

    Essential Linux commands for file management, permissions, processes, networking, and system administration.

    10 min read
    linuxclishellsysadmin

    File Management

    3 topics

    Navigate & List

    bash
    pwd               # Print working directory
    ls -la            # List all files with details
    ls -lh            # Human-readable sizes
    cd /path/to/dir   # Change directory
    cd ~              # Go home
    cd -              # Go back to previous dir
    tree              # Visual directory tree

    💡 Use tab for autocomplete

    ⚡ cd - is great for toggling between two dirs

    Create, Copy, Move, Delete

    bash
    touch file.txt            # Create empty file
    mkdir -p a/b/c            # Create nested dirs
    cp file.txt backup.txt    # Copy file
    cp -r dir/ backup/        # Copy directory
    mv old.txt new.txt        # Move/rename
    rm file.txt               # Delete file
    rm -rf dir/               # Delete directory (careful!)
    ln -s /path/to/file link  # Symbolic link

    ⚠️ rm -rf is irreversible — double check paths

    💡 Use mv to rename files

    Find Files

    bash
    find / -name '*.log'          # Find by name
    find . -type f -mtime -7      # Files modified in last 7 days
    find . -size +100M            # Files larger than 100MB
    locate filename               # Fast search using index
    which python3                 # Find command location
    whereis bash                  # Find binary, source, man page

    ⚡ locate is faster than find but needs updatedb to be current

    Permissions & Ownership

    1 topic

    chmod & chown

    bash
    # chmod: change mode
    chmod 755 script.sh      # rwxr-xr-x
    chmod +x script.sh       # Add execute
    chmod -w file.txt        # Remove write
    chmod -R 644 dir/        # Recursive
    
    # chown: change owner
    chown user:group file
    chown -R www-data /var/www
    
    # Permission bits: 4=read, 2=write, 1=execute
    # 7=rwx  6=rw-  5=r-x  4=r--

    💡 755 for scripts, 644 for data files is the common pattern

    ⚡ Use chmod +x to make scripts executable

    Process Management

    1 topic

    View & Kill Processes

    bash
    ps aux                    # All running processes
    top                       # Live process monitor
    htop                      # Interactive monitor
    kill PID                  # Send SIGTERM
    kill -9 PID               # Force kill (SIGKILL)
    pkill nginx               # Kill by name
    jobs                      # List background jobs
    bg %1                     # Resume job in background
    fg %1                     # Bring job to foreground
    nohup cmd &               # Run immune to hangup

    ⚠️ kill -9 doesn't allow cleanup — use sparingly

    💡 Use & to run processes in background

    Text Processing

    2 topics

    grep, sed, awk

    bash
    # grep: search
    grep 'error' app.log
    grep -r 'TODO' ./src          # Recursive
    grep -i 'warning' file        # Case-insensitive
    grep -n 'pattern' file        # Show line numbers
    
    # sed: stream editor
    sed 's/old/new/g' file.txt    # Replace all
    sed -i 's/foo/bar/g' file     # In-place edit
    
    # awk: field processing
    awk '{print $1, $3}' file     # Print columns 1 and 3
    awk -F: '{print $1}' /etc/passwd  # Custom delimiter

    💡 Pipe commands together: cat file | grep error | wc -l

    View File Contents

    bash
    cat file.txt              # Print entire file
    less file.txt             # Paginate (q to quit)
    head -20 file.txt         # First 20 lines
    tail -20 file.txt         # Last 20 lines
    tail -f app.log           # Follow log in real-time
    wc -l file.txt            # Count lines
    sort file.txt             # Sort lines
    uniq -c sorted.txt        # Count unique lines

    ⚡ tail -f is indispensable for watching logs live

    Networking

    1 topic

    Network Commands

    bash
    ip addr                   # Show IP addresses
    ifconfig                  # Legacy: network interfaces
    ping google.com           # Test connectivity
    curl -I https://site.com  # HTTP headers
    wget https://file.com/f   # Download file
    ss -tulnp                 # Show open ports
    netstat -tulnp            # Legacy: open ports
    ssh user@host             # Connect via SSH
    scp file user@host:/path  # Copy file over SSH
    rsync -av src/ user@h:/d  # Sync directories

    💡 ss is the modern replacement for netstat

    Disk & System

    1 topic

    Disk Usage

    bash
    df -h                     # Disk space by filesystem
    du -sh /var/log           # Size of a directory
    du -sh * | sort -rh       # Sort dirs by size
    free -h                   # Memory usage
    uname -a                  # Kernel & system info
    uptime                    # System uptime & load
    lscpu                     # CPU info
    lsblk                     # Block devices

    ⚡ du -sh * | sort -rh is great for finding what's eating disk space

    Related Articles

    Background reading and deeper explanations for this sheet.

    Event-Driven Agents with Kafka Streams: A Practical Guide for Building Real-Time AI Workflows

    Event-driven agents let you move from slow, request/response automation to responsive systems that react in milliseconds to real-world signals. In this hands-on guide, you’ll learn how to design, build, and operate agentic workflows using Apache Kafka and Kafka Streams, with practical patterns, code snippets, and production-ready advice.

    keyword overlap

    Prompt Engineering Is Dead? What Actually Matters Now in Building Reliable AI Apps

    Prompt engineering isn’t dead—but it’s no longer the main differentiator for teams shipping real AI products. What matters now is system design: context pipelines, evals, guardrails, and feedback loops. This practical guide shows beginners and experienced builders exactly how to move from clever prompts to dependable outcomes.

    keyword overlap

    GenAI SaaS Architecture: A Practical Blueprint for Building, Scaling, and Securing AI Products

    Designing a SaaS product on top of GenAI is more than calling an LLM API—it requires thoughtful architecture across product, data, safety, and operations. This practical guide walks you through a beginner-friendly yet deep system blueprint, with real-world patterns, code snippets, and deployment strategies you can use immediately.

    keyword overlap

    Generative AI Roadmap: A Practical, Beginner-Friendly Guide to Learning and Building Real Projects

    Generative AI can feel overwhelming, but you don’t need a PhD to get started and create useful applications. This roadmap breaks down what to learn, when to learn it, and how to apply each skill in real-world projects—from prompt engineering and APIs to RAG, evaluation, and production deployment.

    keyword overlap