mirror of
https://github.com/thecyberlearn/devops-notes.git
synced 2026-08-18 07:32:51 +00:00
1.6 KiB
1.6 KiB
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 (recommended)
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:
- Check disk usage
- Identify large directories
- 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.