0
0
Linux CLIscripting~20 mins

System logs (/var/log) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Log Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this command?
You run the command tail -n 3 /var/log/syslog on a Linux system. What does this command do?
Linux CLI
tail -n 3 /var/log/syslog
AShows the first 3 lines of the syslog file
BShows the last 3 lines of the syslog file
CDeletes the last 3 lines of the syslog file
DShows all lines except the last 3 lines of the syslog file
Attempts:
2 left
💡 Hint
Think about what the 'tail' command does with the '-n' option.
💻 Command Output
intermediate
1:30remaining
What does this command output?
You run grep -i error /var/log/auth.log | wc -l. What does this command do?
Linux CLI
grep -i error /var/log/auth.log | wc -l
AShows all lines with the word 'error' in auth.log
BDeletes lines containing 'error' from auth.log
CCounts all lines in auth.log
DCounts how many lines contain the word 'error' (case insensitive) in auth.log
Attempts:
2 left
💡 Hint
Remember what grep and wc -l do.
🔧 Debug
advanced
2:00remaining
Why does this command fail?
You try to run cat /var/log/secure | grep 'Failed password' but get a permission denied error. Why?
Linux CLI
cat /var/log/secure | grep 'Failed password'
AThe grep command syntax is wrong
BThe file /var/log/secure does not exist
CYou need root permissions to read /var/log/secure
DThe pipe symbol '|' is not supported in this shell
Attempts:
2 left
💡 Hint
Check file permissions for /var/log/secure.
🚀 Application
advanced
2:00remaining
Create a command to monitor new log entries
Which command will continuously show new lines added to /var/log/messages in real time?
Atail -f /var/log/messages
Bhead -n 10 /var/log/messages
Ccat /var/log/messages
Dgrep 'new' /var/log/messages
Attempts:
2 left
💡 Hint
Think about commands that follow file changes live.
🧠 Conceptual
expert
2:30remaining
What is the purpose of log rotation in /var/log?
Why do Linux systems use log rotation for files in /var/log?
ATo prevent log files from growing too large and consuming disk space
BTo delete all logs automatically after one day
CTo merge all logs into one big file
DTo encrypt log files for security
Attempts:
2 left
💡 Hint
Think about disk space and file management.