Daily Linux Administration Guide
🛠️ Daily Linux Administration Guide
1. User and Group Management
sudo adduser john
sudo usermod -aG sudo john
sudo deluser john --remove-home
sudo groupadd developers
sudo usermod -aG developers john
2. Filesystem & Storage Monitoring
df -hT
du -sh /var/log/*
mount /dev/sdb1 /mnt/mydrive
lsblk
find / -type f -exec du -h {{}} + | sort -rh | head -n 20
3. System Performance & Resource Usage
uptime
free -h
top
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
iostat -xz 1
4. Security & Updates
sudo apt update && sudo apt upgrade
sudo dnf update
lastlog
who
grep "sshd" /var/log/auth.log | grep "Failed"
sudo fail2ban-client status
5. Package Management
# Debian/Ubuntu
apt install nginx
apt remove apache2
# RedHat/CentOS
dnf install nginx
dnf remove httpd
# List packages
dpkg -l # Debian
rpm -qa # RedHat
6. System Services & Processes
systemctl status nginx
systemctl start nginx
systemctl enable nginx
systemctl restart ssh
systemctl list-units --type=service
7. Network Monitoring & Configuration
ip a
sudo ss -tuln
ping google.com
dig jeffmdoyle.com
ip route
8. Firewall (UFW / Firewalld)
# UFW
sudo ufw enable
sudo ufw allow 22/tcp
sudo ufw status verbose
# Firewalld
sudo firewall-cmd --add-port=22/tcp --permanent
sudo firewall-cmd --reload
9. System Logging & Audit
journalctl -xe
sudo tail -f /var/log/syslog
journalctl -u nginx
10. Backups & Scheduled Jobs
crontab -e
crontab -l
# Example: daily at 2am
0 2 * * * /usr/local/bin/backup.sh
rsync -avz /etc /backup/etc/
11. Diagnostic & Troubleshooting Tools
traceroute google.com
netstat -tulpen
inotifywait -m /etc
dmesg | less
12. Useful Admin Utilities
Tool | Use Case | Install |
htop | Process viewer | sudo apt install htop |
ncdu | Disk usage analyzer | sudo apt install ncdu |
iotop | Disk I/O activity | sudo apt install iotop |
nmap | Port scanning | sudo apt install nmap |
glances | System monitor | sudo apt install glances |
fail2ban | SSH brute-force protection | sudo apt install fail2ban |
13. Filesystem & Permissions
ls -l /path/to/file
sudo chown user:group file
sudo chmod 755 script.sh
14. Cleanup & Maintenance
sudo apt autoremove
sudo apt clean
find /var/log -type f -size +50M