LinuxAdminToolkitLinuxAdminToolkit
Home
Guide
About Me
GitHub
Home
Guide
About Me
GitHub
  • Administrator's Manual

    • Commands
      • Basic Commands
      • File Management
      • Process Management
      • User and Group Management
      • System Information
      • Disk Usage
    • Networking
      • IP Address
      • Subnetting
      • Routing
      • Firewall
      • Network Tools
    • Services
      • Service Management
      • Service Configuration
      • Common Services
    • Monitoring and Logging
      • System Monitoring
      • Log Management
      • Monitoring Tools
      • Log Analysis Tools
    • Shell Scripting
      • Basic Shell Script Structure
      • Variables
      • Control Structures
      • Functions
      • Input and Output
      • Debugging and Error Handling
      • Advanced Topics
    • Configurations Files
      • System Configuration Files
      • Network Configuration Files
      • Service Configuration Files
      • Application Configuration Files
      • Editing Configuration Files
      • Backup and Restore Configuration Files

Log Management

System Log Files

  • System log files are stored in the /var/log directory.

  • Common log files include:

    • General system logs: /var/log/syslog
    • Authentication logs: /var/log/auth.log
    • Kernel logs: /var/log.kern.log
    • Boot and kernel-related message: /var/log/dmesg

Viewing Log Files

cat

  • It displays the entire contents of the log file.
cat /var/log/syslog

less

  • It is used to view file contents with pagination.
  • It allows scrolling through a log file.
less /var/log/syslog

tail

  • It is used to view the end of the log file.
  • It displays the last few lines of a log file.
  • -f is used to follow the file as it grows.
tail /var/log/syslog
tail -f /var/log/syslog

Rotating Log Files

logrotate

  • It is used to manage the log rotation.

  • It is a utility designed to manage the automatic rotation and compression of log files.

  • The configuration files are located in /etc/logrotate.d/

  • Example configuration:

/var/log/syslog {
  daily
  rotate 7
  compress
  missingok
  notifempty
  create 0640 root utmp
  postrotate
    /usr/lib/rsyslog/rsyslog-rotate
  endscript
}
Edit this page on GitHub
Last Updated:
Contributors: Jenil Gajjar, jenilgajjar20
Prev
System Monitoring
Next
Monitoring Tools