-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux Log Management
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to log management on Linux, covering Arch Linux, CachyOS, and other distributions including systemd journal, journalctl usage, log rotation, log analysis, and log maintenance.
Journal files:
# Journal location
/var/log/journal/
# User journal
~/.local/share/journal/Configure journal:
# Edit config
sudo vim /etc/systemd/journald.confSettings:
[Journal]
Storage=persistent
SystemMaxUse=1G
SystemKeepFree=2G
Basic commands:
# All logs
journalctl
# Recent logs
journalctl -n 50
# Follow logs
journalctl -f
# Boot logs
journalctl -bFilter by:
# By service
journalctl -u service-name
# By priority
journalctl -p err
# By time
journalctl --since today
journalctl --since "2024-01-15 10:00" --until "2024-01-15 12:00"See Journalctl Troubleshooting for detailed guide.
Configure rotation:
# Edit journal config
sudo vim /etc/systemd/journald.confSettings:
[Journal]
SystemMaxUse=1G
SystemKeepFree=2G
MaxRetentionSec=2weeks
Rotate logs:
# Vacuum by time
sudo journalctl --vacuum-time=2weeks
# Vacuum by size
sudo journalctl --vacuum-size=1GSearch in logs:
# Search for text
journalctl | grep "error"
# Case insensitive
journalctl | grep -i "error"Export logs:
# Export to file
journalctl > logs.txt
# Export specific service
journalctl -u service-name > service-logs.txtCheck usage:
# Check journal size
journalctl --disk-usage
# List boots
journalctl --list-bootsClean old logs:
# Vacuum by time
sudo journalctl --vacuum-time=2weeks
# Vacuum by size
sudo journalctl --vacuum-size=1GClean logs:
# Check size
journalctl --disk-usage
# Clean
sudo journalctl --vacuum-time=1weekCheck journal:
# Check journal status
systemctl status systemd-journald
# Restart journal
sudo systemctl restart systemd-journaldThis guide covered log management for Arch Linux, CachyOS, and other distributions, including journalctl, log rotation, and maintenance.
- Journalctl Troubleshooting - journalctl guide
- System Monitoring - System monitoring
- ArchWiki Log Management: https://wiki.archlinux.org/title/Systemd/Journal
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.