0
0
Linux CLIscripting~10 mins

System logs (/var/log) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to view the last 10 lines of the system log file /var/log/syslog.

Linux CLI
tail [1] 10 /var/log/syslog
Drag options to blanks, or click blank then click option'
A-f
B-r
C-n
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using -f instead of -n which follows the file continuously.
Using -r which reverses the output order.
Using -c which shows bytes instead of lines.
2fill in blank
medium

Complete the command to search for the word error in the /var/log/auth.log file, ignoring case.

Linux CLI
grep [1] error /var/log/auth.log
Drag options to blanks, or click blank then click option'
A-i
B-v
C-c
D-n
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which inverts the match.
Using -c which counts matches instead of showing them.
Using -n which shows line numbers but does not ignore case.
3fill in blank
hard

Fix the error in the command to continuously monitor the /var/log/kern.log file for new entries.

Linux CLI
tail [1] /var/log/kern.log
Drag options to blanks, or click blank then click option'
A-f
B-n 20
C-r
D-c 100
Attempts:
3 left
💡 Hint
Common Mistakes
Using -n 20 which only shows last 20 lines once.
Using -r which reverses the output order.
Using -c 100 which shows bytes, not lines.
4fill in blank
hard

Fill both blanks to create a command that counts how many times the word failed appears in /var/log/auth.log.

Linux CLI
grep [1] failed /var/log/auth.log | wc [2]
Drag options to blanks, or click blank then click option'
A-i
B-l
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using grep -l which lists filenames, not matches.
Using wc -c which counts bytes, not lines.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension in Python that maps each log filename in logs to its size in bytes, but only if the size is greater than 1000.

Linux CLI
sizes = { [1]: os.path.getsize([2]) for [3] in logs if os.path.getsize([2]) > 1000}
Drag options to blanks, or click blank then click option'
Alog
Dfilename
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Using a variable not defined in the loop.