Essential Linux Commands & System Administration Toolkit

Classified in Computers

Written on in English with a size of 7.26 KB

File Operations

  • ls — List files and directories (-a for hidden, -l for detailed)
  • cd [directory] — Change directory
  • mkdir [directory] — Create directory
  • cp [source] [destination] — Copy files/directories (-r for recursive)
  • mv [source] [destination] — Move or rename files/directories
  • rm [file] — Remove files (-r for recursive)
  • chmod [permissions] [file] — Change file permissions
  • chown [user]:[group] [file] — Change file ownership

System Monitoring

  • top / htop — Monitor system processes
  • ps — List running processes
  • df -h — Display disk space usage
  • free -m — Show memory usage

Networking Commands

  • ifconfig / ip a — Display network interfaces
  • ping [host] — Test network connectivity
  • netstat -tuln — List network connections
  • nmap [IP] — Scan networks and ports

Package Management

  • Debian-based: apt-get, apt
  • Red Hat-based: yum, dnf
  • Arch Linux: pacman
  • SUSE Linux: zypper
  • General: snap, flatpak

User Management

  • useradd [user] — Add a new user
  • usermod [user] — Modify user account
  • passwd [user] — Change user password
  • su [user] — Switch user
  • sudo [command] — Execute command as superuser

Nano Editor Commands

  • Ctrl + O — Save file
  • Ctrl + X — Exit Nano
  • Ctrl + W — Search within the file
  • Ctrl + K — Cut line
  • Ctrl + U — Paste line
  • Ctrl + G — Display help

Vim Editor Commands

  • Modes: i (Insert), Esc (Command)
  • Saving & Quitting: :w (Save), :q (Quit), :wq (Save & Quit), :q! (Quit without saving)

Vim Navigation

  • h j k l — Move cursor
  • /pattern — Search for a pattern
  • :set nu — Show line numbers

Shell Scripting: Variables

  • var_name="value" — Assign a value to a variable

Shell Scripting: Loops

  • for i in {1..5}; do echo $i; done — Loop from 1 to 5
  • while [ condition ]; do echo "looping"; done — Execute a while loop
  • for file in *.txt; do echo $file; done — Loop through .txt files

Shell Scripting: Conditionals

  • if [ condition ]; then echo "True"; elif [ condition ]; then echo "Else if"; else echo "False"; fi — If-elif-else statement
  • if [[ $var -eq 10 ]]; then echo "Equal to 10"; fi — Conditional check for equality

Wireless Network Commands

  • iwconfig — Display wireless configuration
  • airmon-ng — Enable monitor mode for Wi-Fi adapter

Port Scanning Tools

  • nmap -sS -A — Perform SYN scan with OS detection

Packet Capture

  • tcpdump — Capture network traffic

Basic SSH Commands

  • ssh user@host — Connect to a remote host
  • scp source user@host:destination — Securely copy files to/from a remote host

SSH Key Management

  • ssh-keygen — Generate SSH keys
  • ssh-copy-id user@host — Copy public key to a remote host

Git Basic Commands

  • git init — Initialize a new Git repository
  • git clone URL — Clone a repository from a URL
  • git add [file] — Stage changes for commit
  • git commit -m "message" — Commit staged changes with a message
  • git push / git pull — Push/pull changes to/from a remote repository

Git Branching

  • git branch — List all branches
  • git checkout branch_name — Switch to a different branch
  • git merge branch_name — Merge a branch into the current branch

Important Configuration Files

  • /etc/hosts — Static hostname-IP mapping
  • /etc/fstab — Disk and partition mount settings
  • /etc/network/interfaces — Network configuration (Debian-based systems)
  • ~/.bashrc, ~/.zshrc — User-specific shell startup scripts
  • /etc/systemd/system/ — Systemd service unit files

System Log Files

  • /var/log/syslog — General system log
  • /var/log/auth.log — Authentication log

Nmap Scan Options

  • -sS — TCP SYN scan
  • -A — Enable OS detection and version detection
  • -Pn — Disable ping before scanning

Wireshark Display Filters

  • ip.addr == 192.168.1.1 — Filter by IP address
  • tcp.port == 80 — Filter by TCP port

Wireless Attack Tools: Scanning

  • scan — Scan for all access points
  • scan -ch 6 — Scan on a specific channel
  • scan stations -ch 6 — Scan connected devices (stations)

Wireless Attack Tools: Selecting Targets

  • select ap 0 — Select an Access Point by ID
  • select station 2 — Select a station by ID
  • show selected aps / show selected stations — Show currently selected APs/Stations

Wireless Attack Tools: Attack Commands

  • attack deauth -ap 0 -st 2 — Perform a deauthentication attack on a specific station
  • attack beacon -b — Initiate a beacon flood attack
  • attack probe -ap 0 — Launch a probe flood attack
  • enable random 5 — Enable random SSID attack (5-second interval)
  • stop attack — Stop all active attacks

Wireless Attack Tools: Utility Commands

  • clear — Clear the console
  • sysinfo — Display system information
  • reboot — Reboot the device
  • format — Format the SPIFFS filesystem

Regular Expressions (Regex) Commands

  • grep "pattern" file.txt — Search for a pattern within a file
  • sed 's/old/new/g' file.txt — Replace text using sed

Docker Commands

  • docker run image — Run a Docker container from an image
  • docker ps — List running Docker containers
  • docker stop container_id — Stop a running Docker container

Related entries: