Write the Incident Report
Something went wrong on the servers last night, and you're writing the report. The logs are in /var/log/app. Build report.txt in your home directory without typing any number yourself: let the commands count.
How it works: the terminal below is a real Linux machine running in your browser. Click it and
type. Tasks tick themselves off as you complete them; questions are answered in the box under each task.
Press Reset any time for a fresh machine. Your password on this machine (for
sudo) is student.
Hints
Build each $( ) command on its own first and check its output, then put it inside echo "..." >> report.txt.
Solution explanation
The here-document writes the two header lines. Inside the double quotes, $(ls /var/log/app | wc -l) becomes 5, and $(cat /var/log/app/*.log | grep ERROR | wc -l) becomes the number of error lines. cd /vault fails with exit status 1, which is why || runs echo. 2>&1 puts the Permission denied error into the same file as the listing.
Show solution
cat <<EOF > report.txt
Incident report
Analyst: student
EOF
echo "Log files: $(ls /var/log/app | wc -l)" >> report.txt
echo "Errors: $(cat /var/log/app/*.log | grep ERROR | wc -l)" >> report.txt
cd /vault
echo $?
cd /vault || echo Access denied
ls /var/log/app /vault > inventory.txt 2>&1
cat report.txt