Unix - Interview Troubleshooting Questions
(Logging, logrotate, journalctl)
1. Disk is full due to logs. How will you troubleshoot?
Answer:
-
Check disk usage:
df -h
-
Find large logs:
du -sh /var/log/*
-
Identify log type (syslog or journal)
-
Rotate logs:
logrotate -f /etc/logrotate.conf
-
Vacuum journal logs:
journalctl --vacuum-size=200M
2. Logs are not rotating automatically. What could be the reason?
Possible Causes:
-
logrotate cron job not running
-
Syntax error in config
-
Incorrect log file path
-
Permission issues
Check:
logrotate -d /etc/logrotate.conf
3. After log rotation, the application stops logging. Why?
Reason:
-
Application still writing to old file descriptor
Fix:
Add postrotate script:
postrotate
systemctl reload rsyslog
endscript
4. journalctl logs disappear after reboot. Why?
Reason:
-
Journal stored in volatile memory
Solution:
mkdir -p /var/log/journal
systemctl restart systemd-journald
5. How do you limit journalctl disk usage?
Answer:
Temporary:
journalctl --vacuum-size=300M
Permanent:
SystemMaxUse=500M
(/etc/systemd/journald.conf)
6. Logs are visible in journalctl but not in /var/log. Why?
Reason:
-
journald not forwarding logs to syslog
Fix:
ForwardToSyslog=yes
Restart:
systemctl restart systemd-journald rsyslog
7. How do you check logs for a failed service?
Answer:
journalctl -u servicename
Example:
journalctl -u ssh
8. How do you debug logrotate configuration before applying it?
Answer:
logrotate -d /etc/logrotate.conf
9. What is the difference between logrotate and journalctl rotation?
Answer:
-
logrotate manages text log files
-
journalctl manages binary journal logs
-
logrotate is rule-based
-
journalctl is space-based
10. How do you find logs between specific times?
Answer:
journalctl --since "2025-12-16 09:00" --until "2025-12-16 10:00"
11. A service is running but not generating logs. How will you debug?
Answer:
-
Check service status
systemctl status service
-
Check journal logs
journalctl -u service
-
Verify log configuration
-
Check permissions on log directory
12. How do you find which process is writing to a log file?
Answer:
lsof /var/log/syslog
13. How do you prevent logs from filling disk permanently?
Answer:
-
Configure logrotate
-
Enable compression
-
Limit journal size
-
Monitor disk usage
14. What happens if logrotate fails?
Answer:
-
Logs keep growing
-
Disk may become full
-
Services may crash
-
System may become unstable
15. Explain a real-time log monitoring command.
Answer:
journalctl -f
or
tail -f /var/log/syslog
16. What log files are important for security incidents?
Answer:
-
/var/log/auth.log -
/var/log/secure -
audit logs
-
journal logs
17. Can journalctl logs be deleted manually?
Answer:
No. They should be removed using:
journalctl --vacuum-time=7d
18. How do you troubleshoot high CPU caused by logging?
Answer:
-
Identify noisy services
-
Reduce log level
-
Adjust rotation frequency
-
Enable compression
19. What is your first step when logs are missing?
Answer:
-
Check journald status
-
Verify persistent storage
-
Check permissions