Saturday, May 24, 2025

Linux command line skills

 If you're looking to level up your Linux command line skills, here’s a curated list of advanced Linux commands, tools, and techniques, categorized by functionality:


🔍 File and Text Processing

  1. awk

    awk '{print $2, $1}' file.txt
    
    • Powerful for pattern scanning and processing.

  2. sed

    sed -E 's/([0-9]{3})/\1-/' file.txt
    
    • Stream editor for modifying files or inputs inline.

  3. xargs

    find . -name '*.log' | xargs grep 'ERROR'
    
    • Converts input from stdin into arguments to a command.

  4. cut, paste, tr, sort, uniq, tee

    cut -d':' -f1 /etc/passwd | sort | uniq
    

🧠 System Monitoring and Performance

  1. htop / atop / glances

    • Interactive process viewers.

  2. iotop

    • Shows disk I/O by process.

  3. strace

    strace -p <PID>
    
    • Traces system calls of a process.

  4. lsof

    lsof -i :80
    
    • Lists open files and ports.

  5. watch

    watch -n 2 df -h
    
    • Repeats a command at intervals.


📁 Disk & Filesystem Tools

  1. ncdu

    • Visual disk usage analysis.

  2. df, du

    du -sh * | sort -h
    
  3. mount, umount, lsblk, blkid


🧰 Networking & Sockets

  1. netstat / ss

    ss -tuln
    
  2. nmap

    nmap -sV 192.168.1.1
    
  3. tcpdump

    tcpdump -i eth0 port 80
    
  4. curl, wget, nc (netcat)

    curl -I https://example.com
    nc -vz google.com 80
    

🔐 Permissions, Security, & Users

  1. chmod, chown, setfacl, getfacl

  2. sudo, visudo

  3. usermod, groupadd, passwd

  4. ssh, scp, rsync

    rsync -avz /local/dir/ user@host:/remote/dir/
    

🔄 Automation and Scripting

  1. cron, at

    crontab -e
    
  2. Shell scripting:

    for i in *.log; do gzip "$i"; done
    
  3. trap, set -euo pipefail for robust scripts.


📦 Package Management

  • Debian/Ubuntu: apt, dpkg

  • Red Hat/CentOS: yum, dnf, rpm

  • Arch: pacman


🧠 Cool Pro Tips

  1. Brace expansion:

    mkdir -p project/{src,bin,doc}
    
  2. Process substitution:

    diff <(ls dir1) <(ls dir2)
    
  3. Command chaining:

    cmd1 && cmd2 || echo "cmd1 failed"
    
  4. Parallel execution with & and wait:

    cmd1 & cmd2 & wait
    

If you want a focused guide (e.g. for networking, performance tuning, or scripting), just let me know!

No comments:

Post a Comment