System logs and configuration files

4.3 Where Data is Stored (Weight: 3)

📘Linux Essentials (LPI 010-160)


1. What are System Logs?

System logs are files where Linux records events happening on the system. They are like a diary that keeps track of everything that happens. Logs are useful to:

  • Troubleshoot problems (why a service failed)
  • Monitor system performance
  • Track security issues (like failed login attempts)
  • Keep audit records (what users did)

Where are logs stored?

  • Most system logs are stored in the /var/log/ directory.
  • Example common log files:
Log FileWhat it Records
/var/log/syslogGeneral system events (Ubuntu/Debian)
/var/log/messagesGeneral system events (Red Hat/CentOS)
/var/log/auth.logAuthentication events, like login attempts
/var/log/kern.logKernel messages
/var/log/dmesgBoot messages and hardware info
/var/log/boot.logBoot process logs
/var/log/faillogFailed login attempts
/var/log/httpd/ or /var/log/apache2/Web server logs

Tip for exams: Remember /var/log is the main location for logs. Auth logs are for security, syslog/messages are general events.


2. Viewing System Logs

Linux provides commands to read logs:

  1. cat / less / more – To read logs directly. cat /var/log/syslog
    less /var/log/syslog
    • less is preferred because it lets you scroll and search easily.
  2. tail – View the last few lines of a log (useful for recent events) tail /var/log/syslog
    tail -f /var/log/syslog # real-time monitoring
  3. journalctl – For systems using systemd (most modern Linux) journalctl # view all logs
    journalctl -u ssh # logs for SSH service only
    journalctl -b # logs since last boot
    journalctl -f # follow logs in real-time

Logs can be huge, so filtering and searching is important:

grep "error" /var/log/syslog

3. What are Configuration Files?

Configuration files tell programs and the system how to behave. They are like instruction manuals for Linux and applications.

  • Usually, configuration files are plain text.
  • Most are stored in the /etc/ directory.
  • Changing them requires administrative rights (root).

Common Configuration Files in Linux

File / DirectoryPurpose
/etc/passwdStores user accounts info
/etc/shadowStores user passwords securely
/etc/groupStores user group info
/etc/hostnameSystem hostname
/etc/hostsMaps IP addresses to hostnames locally
/etc/resolv.confDNS resolver configuration
/etc/fstabFilesystem mount points (disks, partitions)
/etc/network/interfaces (Debian) or /etc/sysconfig/network-scripts/ (RHEL)Network configuration
/etc/ssh/sshd_configSSH server configuration
/etc/sudoersUser permissions for sudo

Tip for exams: /etc/ is where system and service configuration files live.


4. Editing Configuration Files

To modify configuration files:

  • Use text editors like: nano /etc/hostname
    vi /etc/ssh/sshd_config
  • After changing some files, you may need to restart services to apply changes: systemctl restart sshd
    systemctl restart networking

5. Differences Between Logs and Configuration Files

AspectLogsConfiguration Files
PurposeRecord eventsDefine system/application behavior
Location/var/log//etc/
EditableGenerally read-onlyEditable by admin
Exam FocusMonitoring, troubleshootingSystem setup, network, services

6. Real IT Examples

  • Server Monitoring: A sysadmin checks /var/log/auth.log to see failed SSH logins, helping prevent security breaches.
  • Web Server Setup: Edit /etc/apache2/apache2.conf to change server settings. Logs are in /var/log/apache2/ for errors or access reports.
  • Network Troubleshooting: Check /var/log/syslog or /var/log/messages to see network interface errors after a reboot.

Exam Key Points

  1. Logs = /var/log/, used for monitoring, security, troubleshooting.
  2. Configuration files = /etc/, define system or service behavior.
  3. Commands:
    • cat, less, tail, journalctl for logs
    • nano, vi, systemctl for configs
  4. Security-related logs = /var/log/auth.log
  5. Network configuration = /etc/network/ or /etc/sysconfig/network-scripts/
  6. Always distinguish logs (record of events) from configs (instructions).
Buy Me a Coffee