Skip to main content

Command Palette

Search for a command to run...

πŸ“ Linux Log Files – Where to Find What (Complete Guide with Best Practices)

Published
β€’3 min read
πŸ“ Linux Log Files – Where to Find What (Complete Guide with Best Practices)

When troubleshooting a Linux system, logs are your most valuable source of truth. They record everything happening under the hood β€” from system events and authentication attempts to application crashes and kernel messages.

But with so many log files scattered across /var/log/, it’s easy to feel overwhelmed. This guide will help you understand:

βœ… What Linux log files are and why they matter
βœ… Where to find specific logs
βœ… Best practices for managing logs
βœ… Tricks and tips for troubleshooting faster


πŸ“š Understanding Linux Log Files

In Linux, most system events are logged through syslog or systemd journal (depending on your distribution). These logs help:

  • System Administrators β†’ track performance and issues

  • Security Engineers β†’ detect intrusion attempts

  • Developers β†’ debug application errors

  • DevOps / SRE teams β†’ monitor uptime and reliability

By default, logs are stored in plain text files under /var/log/, making them easy to read, filter, and automate.


πŸ“‚ Common Linux Log Files and Their Purposes

Here’s a breakdown of the most commonly used logs:

Log FilePurposeExample Usage
/var/log/syslog (Debian/Ubuntu) / /var/log/messages (RHEL/CentOS)General system events, daemons, kernel messagesSystem-wide troubleshooting
/var/log/auth.log (Debian/Ubuntu) / /var/log/secure (RHEL/CentOS)Authentication attempts (logins, sudo, ssh)Check for brute-force attacks
/var/log/dmesgKernel ring buffer (hardware, drivers)Debug boot issues or hardware problems
/var/log/kern.logKernel-specific messagesDetect kernel crashes or warnings
/var/log/cron.logCron jobs and their executionVerify scheduled tasks
/var/log/httpd/ or /var/log/nginx/Web server access/error logsDebugging website errors
/var/log/maillog or /var/log/mail.logMail server activityMonitor email delivery
/var/log/boot.logBoot sequence informationDebug startup issues
/var/log/faillogFailed login attemptsSecurity auditing

πŸ› οΈ Tricks & Tips for Working with Logs

  • Follow logs in real-time:

      tail -f /var/log/syslog
    
  • Search for errors quickly:

      grep "ERROR" /var/log/syslog
    
  • Check SSH login attempts:

      sudo grep "Failed password" /var/log/auth.log
    
  • Use journalctl for systemd logs:

      journalctl -xe
    
  • Monitor last 100 boot messages:

      dmesg | tail -100
    

βœ… Best Practices for Linux Log Management

  1. Centralize Logs
    Use ELK Stack, Splunk, or AWS CloudWatch for better visibility across servers.

  2. Secure Access
    Restrict sensitive logs like /var/log/auth.log since they may expose login attempts.

  3. Set Up Monitoring & Alerts
    Integrate with Prometheus/Grafana or use tools like logwatch to catch issues proactively.

  4. Rotate Logs Regularly
    Configure logrotate to archive and compress old logs. Example config:

     /var/log/syslog {
         daily
         rotate 7
         compress
         missingok
     }
    
  5. Balance Retention & Compliance
    Keep logs long enough for audits, but avoid unlimited storage growth.

  6. Proactive Log Review
    Don’t just look at logs when something breaks β€” review them periodically to catch early warnings.


πŸ’‘ Pro Tips

  • Combine tail -f with grep for live filtered logs:

      tail -f /var/log/syslog | grep "ERROR"
    
  • Use colored output tools like ccze or lnav for better readability.

  • Automate log parsing with Python or shell scripts for recurring issues.

  • Keep an eye on disk space β€” logs can grow quickly if left unchecked.


πŸš€ Conclusion

Linux log files are the heartbeat of your system. Mastering them means you can troubleshoot faster, strengthen security, and ensure smooth operations.

Instead of treating logs as a last resort, think of them as your early warning system β€” they can help you spot issues before they become outages.


πŸ‘‰ What’s your go-to log file when troubleshooting Linux? Share your experience in the comments!

#Linux #DevOps #SysAdmin #Cloud #Logs #SRE

DevOps

Part 1 of 50

πŸš€ Kicking off my DevOps Series on Hashnode! I’ll share notes, best practices, tips, demos & interview prep on AWS, Docker, K8s, CI/CD, Terraform & more. Follow along to learn & grow together! #DevOps #Hashnode #LearningInPublic

More from this blog

Cloud Enthusiast

116 posts