Ubuntu Security ยท 4.5
๐ System Logs & Audit
Ubuntu's equivalent of Windows Event Viewerโฑ ~3 min
Linux stores logs as text files in /var/log/. Unlike Windows Event Viewer (which has a GUI), you read Linux logs with cat, less, grep, and tail.
Key Log Files in Ubuntu
| File | What It Logs | Competition Use |
|---|---|---|
| /var/log/auth.log | Authentication events: logins, sudo use, SSH attempts, user additions | Most important โ find unauthorized access |
| /var/log/syslog | General operating system events | Service start/stop, kernel messages |
| /var/log/dpkg.log | Software installs, removals, updates | Find unauthorized package changes |
| /var/log/ufw.log | Firewall allow/block events | Active only after ufw is enabled |
| /var/log/btmp | Failed login attempts (view with: sudo lastb) | Detect brute-force targets |
Reading Logs Effectively
bash
# View all of auth.logsudo cat /var/log/auth.log # View last 50 lines (most recent events)sudo tail -50 /var/log/auth.log # Follow log in real-time as events happensudo tail -f /var/log/auth.log # Search for failed loginssudo grep 'Failed password' /var/log/auth.log # Search for sudo usagesudo grep 'sudo' /var/log/auth.log # Search for a specific user's activitysudo grep 'alice' /var/log/auth.logSetting Up auditd โ Advanced Audit Logging
bash
# Install audit daemonsudo apt install auditd # Enable auditingsudo auditctl -e 1 # Start audit service automatically at bootsudo systemctl enable auditdsudo systemctl start auditd # View audit logssudo ausearch -m LOGIN # Login eventssudo ausearch -m USER_CMD # sudo commandsServices โ Modern Ubuntu (systemctl)
bash
# List all services and their statussystemctl list-units --type=service # Check if a service is runningsystemctl status ssh # Stop a servicesudo systemctl stop apache2 # Disable (don't start at boot)sudo systemctl disable apache2 # Enable (start at boot)sudo systemctl enable ssh # Common services to disable if not needed:# telnet, rsh, rlogin, ftp, avahi-daemon, cups (if no printer)๐ก TipNote: The older Boot-Up Manager (bum) shown in some CyberPatriot materials is deprecated. Modern Ubuntu uses systemctl to manage services at boot. If bum is mentioned in an old guide, use systemctl enable/disable instead.
๐ง Quick Checkfirst try = +5 XP
Which log file shows SSH logins and sudo usage on Ubuntu?
๐ฎ Practice what you learned
โญ 0 XP๐ฅ 0 days