0% found this document useful (0 votes)
47 views

Logs Linux

Logging is crucial for managing computer systems and applications, with different levels and categories providing important information. Key commands and files are used to access system logs containing kernel messages, authentication logs recording login attempts, and application-specific activity logs. System performance is monitored through commands that generate metrics on resources like CPU and memory usage. Security logs record auditing events, while common log commands allow viewing, searching, rotating, and analyzing log files across Unix/Linux systems.

Uploaded by

Akshat Negi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Logs Linux

Logging is crucial for managing computer systems and applications, with different levels and categories providing important information. Key commands and files are used to access system logs containing kernel messages, authentication logs recording login attempts, and application-specific activity logs. System performance is monitored through commands that generate metrics on resources like CPU and memory usage. Security logs record auditing events, while common log commands allow viewing, searching, rotating, and analyzing log files across Unix/Linux systems.

Uploaded by

Akshat Negi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Logging is a crucial aspect of managing and troubleshooting computer systems, applications, and

networks. Different levels and categories of logs help you track events, errors, and activities. Here's
an overview of important commands and log details for various levels and categories of logs,
primarily focusing on Unix/Linux systems:
Logging Levels:

DEBUG: Detailed information, typically used for debugging purposes.

INFO: General information about the system or application.

WARNING: Indicates potential issues or anomalies that should be monitored.

ERROR: Denotes errors that need attention but don't cause system failure.

CRITICAL: Severe errors that may lead to system failure.

Log Categories:

System Logs:

Command: dmesg - Display kernel ring buffer.

Log File: /var/log/syslog (Ubuntu) or /var/log/messages (Red Hat).

Description: Contains kernel and system-related messages.

Authentication Logs:

Command: auth.log (Ubuntu) or secure (Red Hat).

Log File: /var/log/auth.log (Ubuntu) or /var/log/secure (Red Hat).

Description: Records authentication-related events like login attempts.

Application Logs:

Command: Varies by application (e.g., Apache, Nginx, MySQL).

Log Files: Typically in /var/log or specified in application configuration.

Description: Contains information about specific applications' activities.

System Performance Logs:

Command: vmstat, iostat, top, sar.

Log Files: Typically not stored as logs but generated on-demand.

Description: Provides system performance metrics like CPU, memory, and disk usage.

Security Logs:

Command: auditd (Audit daemon).

Log File: /var/log/audit/audit.log.


Description: Records security-related events for auditing purposes.

Common Log Commands:

View Log Contents:

cat, less, more, tail, head.

Example: tail -f /var/log/syslog (real-time log updates).

Search for Specific Entries:

grep, egrep.

Example: grep "ERROR" /var/log/application.log.

Rotate and Archive Logs:

logrotate.

Configuration files located in /etc/logrotate.conf and /etc/logrotate.d/.

Monitor Logs in Real-Time:

tail -f, journalctl -f.

Clear Log Files (Be cautious):

echo > /var/log/file.log (Truncates the file).

truncate -s 0 /var/log/file.log (Zeroes the file).

Analyze Log Files:

Tools like awk, sed, and log analysis software (e.g., ELK Stack).

Log Format:

Logs typically follow a common format, which may include the following information:

Timestamp: When the event occurred.

Hostname: The name of the system generating the log.

Application/Process Name: The source of the log entry.

Log Level: The severity level (e.g., INFO, ERROR).


Message: A description of the event or error.

Remember to consult documentation and specific log sources for more details and customization
options. Proper log management is essential for system troubleshooting, security analysis, and
performance optimization.

You might also like