Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Log Management and Rotation | Service and Process Management
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Linux for DevOps Engineer

bookLog Management and Rotation

Linux systems generate a wide variety of log files that record events, errors, and informational messages. These logs are essential for troubleshooting, monitoring, and auditing system activity. The most important log files are located in the /var/log directory. Here are some of the most common log files you will encounter:

  • /var/log/syslog: contains general system activity logs, including messages from the kernel and various system services;
  • /var/log/auth.log: records authentication events such as successful and failed logins, sudo usage, and SSH activity;
  • /var/log/messages: similar to syslog, but on some distributions, it is the primary log for system events;
  • /var/log/kern.log: logs kernel messages, which can help diagnose hardware or kernel-level issues;
  • /var/log/dmesg: contains boot and hardware-related messages generated by the kernel ring buffer;
  • /var/log/daemon.log: tracks output from system daemons, which are background processes;
  • /var/log/apt/history.log and /var/log/apt/term.log: specific to package management activities on systems using APT;
  • /var/log/nginx/access.log and /var/log/nginx/error.log: web server access and error logs, if you are running NGINX.

Understanding the purpose of each log file helps you quickly identify where to look when investigating issues or monitoring system health.

/var/log/syslog

/var/log/syslog

/var/log/auth.log

/var/log/auth.log

copy

Because log files can grow quickly and consume disk space, Linux systems use log rotation to manage and archive old logs. The logrotate utility automates this process, compressing and removing old logs according to rules you define. logrotate is typically run as a scheduled task (cron job) and is highly configurable to suit different needs.

A logrotate configuration file specifies which logs to manage, how often to rotate them, how many backups to keep, and whether to compress old logs. You can use global settings or create per-log rules for precise control. The main configuration file is /etc/logrotate.conf, and additional configurations are often stored in /etc/logrotate.d/.

/etc/logrotate.d/nginx

/etc/logrotate.d/nginx

copy

This configuration manages Nginx log rotation. It rotates all logs in /var/log/nginx/ daily, keeps 14 old copies, compresses them, and skips empty files. New logs are created with permissions 0640 for user www-data and group adm. After rotation, it sends a USR1 signal to the Nginx master process to reopen log files.

question mark

What is the primary purpose of the logrotate utility on a Linux system?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 3

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

bookLog Management and Rotation

Veeg om het menu te tonen

Linux systems generate a wide variety of log files that record events, errors, and informational messages. These logs are essential for troubleshooting, monitoring, and auditing system activity. The most important log files are located in the /var/log directory. Here are some of the most common log files you will encounter:

  • /var/log/syslog: contains general system activity logs, including messages from the kernel and various system services;
  • /var/log/auth.log: records authentication events such as successful and failed logins, sudo usage, and SSH activity;
  • /var/log/messages: similar to syslog, but on some distributions, it is the primary log for system events;
  • /var/log/kern.log: logs kernel messages, which can help diagnose hardware or kernel-level issues;
  • /var/log/dmesg: contains boot and hardware-related messages generated by the kernel ring buffer;
  • /var/log/daemon.log: tracks output from system daemons, which are background processes;
  • /var/log/apt/history.log and /var/log/apt/term.log: specific to package management activities on systems using APT;
  • /var/log/nginx/access.log and /var/log/nginx/error.log: web server access and error logs, if you are running NGINX.

Understanding the purpose of each log file helps you quickly identify where to look when investigating issues or monitoring system health.

/var/log/syslog

/var/log/syslog

/var/log/auth.log

/var/log/auth.log

copy

Because log files can grow quickly and consume disk space, Linux systems use log rotation to manage and archive old logs. The logrotate utility automates this process, compressing and removing old logs according to rules you define. logrotate is typically run as a scheduled task (cron job) and is highly configurable to suit different needs.

A logrotate configuration file specifies which logs to manage, how often to rotate them, how many backups to keep, and whether to compress old logs. You can use global settings or create per-log rules for precise control. The main configuration file is /etc/logrotate.conf, and additional configurations are often stored in /etc/logrotate.d/.

/etc/logrotate.d/nginx

/etc/logrotate.d/nginx

copy

This configuration manages Nginx log rotation. It rotates all logs in /var/log/nginx/ daily, keeps 14 old copies, compresses them, and skips empty files. New logs are created with permissions 0640 for user www-data and group adm. After rotation, it sends a USR1 signal to the Nginx master process to reopen log files.

question mark

What is the primary purpose of the logrotate utility on a Linux system?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 3
some-alt