Dude Engineering

View Original

Advanced Commands for System Administrators

Navigating the tech world's twists and turns, system admins are the real MVPs keeping our digital life in check. But hey, even heroes need an upgrade. This post is all about beefing up your command line skills with some advanced tricks. Whether you're aiming to speed things up, get those tasks running on autopilot, or lock down your system like Fort Knox, I've got you covered. Ready to level up? Let's dive into the advanced commands that every tech wizard should have up their sleeve.

  1. grep: Search for patterns in files or output

    • Example: Search for a specific string in a file

      grep "pattern" filename
  1. sed: Stream editor for text manipulation

    • Example: Replace a specific word in a file

      sed 's/old_word/new_word/g' filename
  1. awk: Text processing and data extraction tool

    • Example: Print the second column of a CSV file

      awk -F ',' '{print $2}' filename.csv
  1. find: Search for files and directories

    • Example: Find all files modified in the last 7 days

      find /path/to/directory -type f -mtime -7
  1. rsync: Remote file synchronization and transfer

    • Example: Synchronize local and remote directories

      rsync -avz /path/to/source/ user@remote:/path/to/destination/
  1. netstat: Network statistics and connection monitoring

    • Example: List all open network connections

      netstat -tuln
  1. top: Monitor system processes and resource usage

    • Example: Display real-time CPU and memory usage

      top
  1. lsof: List open files and associated processes

    • Example: List all processes that have a particular file open

      lsof /path/to/file
  1. nc: Network utility for reading or writing data across network connections

    • Example: Test connectivity to a specific port

      nc -zv example.com 80
  1. iptables: Firewall management tool

    • Example: Allow incoming traffic on a specific port

      iptables -A INPUT -p tcp --dport 22 -j ACCEPT
        iptables-save > /etc/iptables/rules.v4