devops-notes/07_Linux_Logs_Disk_Management.md
2026-01-09 18:14:04 +05:30

1.6 KiB
Raw Blame History

Linux Logs & Disk Management (Day 7)

Why Logs Are Important in DevOps?

Logs tell you:

  • what happened
  • when it happened
  • why something failed

In production, logs are the FIRST place to check.


Log Directory

Most Linux logs are stored here:

/var/log

List log files:

ls /var/log

Common logs:

  • syslog
  • auth.log
  • kern.log
  • boot.log

View Log Files

cat (small files)

cat /var/log/syslog
less /var/log/syslog

Navigation:

  • Up / Down arrows
  • q → quit

Live Log Monitoring

tail -f /var/log/syslog

Very useful when debugging live issues.


Search Inside Logs

grep error /var/log/syslog

Case-insensitive:

grep -i error /var/log/syslog

Disk Space Management

Check Disk Usage

df -h

Check Folder Size

du -sh /var/log

Find Large Files

du -ah / | sort -rh | head -10

⚠️ Use carefully (may need sudo)


Clear Log Files (Safe Method)

sudo truncate -s 0 /var/log/syslog

Do NOT delete system log files blindly.


Real DevOps Scenario

Problem: Server disk full

Steps:

  1. Check disk usage
  2. Identify large directories
  3. Clear old logs safely

Commands:

df -h
du -sh
tail -f

Common Mistakes

  • Deleting log files directly
  • Ignoring disk alerts
  • Not monitoring log growth

DevOps Rule

Monitor logs regularly
Ignore disk usage


Summary

Today I learned Linux log monitoring and disk management. These skills are critical for production troubleshooting.