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

FileWhat It LogsCompetition Use
/var/log/auth.logAuthentication events: logins, sudo use, SSH attempts, user additionsMost important โ€” find unauthorized access
/var/log/syslogGeneral operating system eventsService start/stop, kernel messages
/var/log/dpkg.logSoftware installs, removals, updatesFind unauthorized package changes
/var/log/ufw.logFirewall allow/block eventsActive only after ufw is enabled
/var/log/btmpFailed login attempts (view with: sudo lastb)Detect brute-force targets

Reading Logs Effectively

bash
# View all of auth.log
sudo 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 happen
sudo tail -f /var/log/auth.log
# Search for failed logins
sudo grep 'Failed password' /var/log/auth.log
# Search for sudo usage
sudo grep 'sudo' /var/log/auth.log
# Search for a specific user's activity
sudo grep 'alice' /var/log/auth.log

Setting Up auditd โ€” Advanced Audit Logging

bash
# Install audit daemon
sudo apt install auditd
# Enable auditing
sudo auditctl -e 1
# Start audit service automatically at boot
sudo systemctl enable auditd
sudo systemctl start auditd
# View audit logs
sudo ausearch -m LOGIN # Login events
sudo ausearch -m USER_CMD # sudo commands

Services โ€” Modern Ubuntu (systemctl)

bash
# List all services and their status
systemctl list-units --type=service
# Check if a service is running
systemctl status ssh
# Stop a service
sudo 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?

โญ 0 XP๐Ÿ”ฅ 0 days