[ SRE_ARENA ]
LINUX BASICS & SHELL SCRIPTING

Linux Commands & Shell Scripting: The Administrator's toolkit

DOWNLOADING CONCEPT: 1. FILE & DIRECTORY OPERATIONS (THE FHS)...
  • ↳Linux organizes files in a unified tree (the Filesystem Hierarchy Standard).
  • ↳Critical paths include /etc (system configs), /var/log (logs), /opt (third-party software), and /proc (virtual filesystem for kernel state).
Essential Commands & Flags
  • ↳- ls (List): ls -laSh (list all files, long format, sort by Size largest first, Human readable).
  • ↳- cd (Change Directory): cd - (jump to previous directory), cd ~ (home).
  • ↳- mkdir (Make Directory): mkdir -p /a/b/c (create nested directories without erroring if they exist).
  • ↳- rm (Remove): rm -rf /dir (Force remove recursively - DANGEROUS).
  • ↳rm -i file.txt (Interactive, asks for confirmation).
  • ↳- touch (Create/Update): touch file.txt (creates empty file or updates modified timestamp to now).
  • ↳- find (Search): The ultimate file searcher.
  • ↳- find /var/log -type f -name "*.log" (Find only files ending in .log) - `find .
  • ↳-mtime +7 (Find files modified more than 7 days ago) - find .
  • ↳-size +500M (Find files larger than 500MB) - find .
  • ↳-name "*.tmp" -exec rm {} \; (Find and execute a command on every match) - **tar** (Archive): tar -czvf archive.tar.gz /folder` (Create, Zip, Verbose, File).
  • ↳Extract with tar -xzvf archive.tar.gz -C /target/dir.
  • ↳- rsync (Sync): rsync -avz --progress /src /dest (Archive mode, Verbose, Compress, show progress).
  • ↳Ideal for backups.
▲ LIVE INCIDENTA backup cron job stopped working. No errors are logged anywhere.
sre@arena:~/linux-shell
sre@arena:~$ cat backup.sh