Using Linux Terminal 2.1: Logs and log rotation
Reading /var/log/auth.log and the journal, rotating a log of your own
with logrotate, and filtering the journal by priority.
Before you start
Work as root (sudo -i), and write answers to the files in
/root/lab-answers/. The lab creates user alice, who then runs four
commands with sudo, and it logs a few messages tagged webapp at
different priorities. It only checks that /var/log/webapp doesn't exist
yet; le-lab reset removes it and your logrotate file for it.
Tasks
- Find the last three commands
aliceran withsudo, from/var/log/auth.logand from the journal, and write them to/root/lab-answers/1, one per line. Both should show the same commands at the same times. - Create
/var/log/webapp/access.logwith some lines in it, and a logrotate configuration that rotates it weekly, keeps 4 compressed copies, and creates a new empty log owned byroot:admwith mode 640. Force one rotation. - Show only error messages (and worse) from the current boot, and write
the
webappmessages among them to/root/lab-answers/3.
Hints
grep 'COMMAND=' /var/log/auth.log,journalctl -t sudo;tail -n 3. Pasting whole log lines into the answer file is fine.- A file in
/etc/logrotate.d/withweekly,rotate 4,compressandcreate 0640 root adm;logrotate -dto test it,logrotate -fto force it.zcatreads the old copy. journalctl -p err -b;-t webappnarrows it to one tag.