Daily system admin commands

🗂️ CATEGORIES:

  1. System Monitoring & Info
  2. 🔐 Security & Access
  3. 📁 Log Management
  4. 📡 Network & Firewall
  5. ⚙️ Automation & Backup
  6. 📦 Package & Service Management
  7. 🧠 Custom Scripts / Misc

✅ 1. SYSTEM MONITORING & INFO

CommandDescription
uptimeShows how long the system has been running and load average.
whoShows who is logged in.
wDisplays who is logged in and what they are doing.
topReal-time view of CPU/memory usage.
df -hShows disk usage in human-readable format.
free -mShows memory usage in MB.
hostname -IDisplays local IP address.
ps auxLists all running processes.
lsofLists open files, often used to trace processes using a file.

🔐 2. SECURITY & ACCESS

CommandDescription
lastLists login history.
lastbLists failed login attempts (uses /var/log/btmp).
whoamiShows current logged-in user.
idShows user ID and groups.
sudo ufw statusDisplays current UFW firewall rules.
sudo ufw allow 5000/tcpAllows incoming traffic on port 5000.
sudo ufw allow from YOUR.IP.ADDRESS to any port 5000Allows only your IP to access port 5000.
sudo ufw deny from IP_ADDRESSBlocks specific IP address.
sudo fail2ban-client statusChecks fail2ban status.
journalctl -u sshView logs for SSH service.

📁 3. LOG MANAGEMENT

CommandDescription
cat /var/log/auth.logView authentication-related logs.
cat /var/log/syslogGeneral system activity logs.
zcat /var/log/syslog.1.gzView compressed logs (rotated).
logrotateTool for automatic log rotation.
tar -czf logs-YYYY-MM-DD.tar.gz /var/logArchive logs manually.
sha256sum logs-*.tar.gzCreate checksum to verify archive integrity.

📡 4. NETWORK & FIREWALL

CommandDescription
curl http://127.0.0.1:5000/Test local Flask server access.
curl http://checkip.amazonaws.comGet public IP address from AWS.
netstat -tulnShow listening ports.
ss -tulnModern alternative to netstat.
sudo ufw enable/disableTurn UFW firewall on or off.
iptables -LView current iptables rules.

⚙️ 5. AUTOMATION & BACKUP

CommandDescription
crontab -eEdit crontab for scheduling tasks.
mkdir -p /mnt/secure-logsCreate archive directory.
tar -czf /mnt/secure-logs/logs-YYYY-MM-DD.tar.gz /var/logArchive logs with compression.
bash check-secure.shRun a custom security audit script.
python3 app.pyRun your Flask dashboard.

📦 6. PACKAGE & SERVICE MANAGEMENT

CommandDescription
pip install flaskInstall Flask (Python package).
sudo apt update && sudo apt upgradeUpdate system packages.
systemctl status sshCheck SSH service status.
systemctl restart sshRestart SSH service.
sudo systemctl enable fail2banEnable fail2ban at boot.
sudo apt install fail2banInstall fail2ban.

🧠 7. CUSTOM / OTHER

CommandDescription
ls -lList files with details.
chmod +x script.shMake script executable.
./script.shRun a shell script in the current directory.
echo "hello"Print text to terminal.
Scroll to Top