Linux Essentials: Files, Filters & Permissions
Preview~10 min3 steps
You are on a fresh Alpine Linux box. In this lab you will build a small log folder, extract the errors from a noisy log file and protect the result so only you can read it.
Everything happens in ~/workspace. A file called sample.log is already waiting there.
Steps
The sandbox is not running. Launch it to insert commands and verify steps; reading and predicting work without it.
01Create the log folder
Create the folder
app/logsinside~/workspace(the-pflag also creates missing parent folders), then create an emptyserver.login it withtouch.cd ~/workspacemkdir -p app/logstouch app/logs/server.logls -R app
02Filter the errors
sample.logmixes INFO, WARN and ERROR lines. Usegrepto keep only the ERROR lines and redirect (>) the result intoapp/logs/errors.txt.cat sample.loggrep ERROR sample.log > app/logs/errors.txtcat app/logs/errors.txt
03Lock down the file
Error logs can leak secrets. Use
chmod 600so only the owner can read and writeerrors.txt, then check it withls -l(you should see-rw-------).chmod 600 app/logs/errors.txtls -l app/logs
Private sandbox
Alpine · 64MB, no internet, deleted after 30 minutes. Your lesson progress is saved in this browser even when the sandbox ends.
Complete the human check to enable launch.