Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.✗ Incorrect
The
tail -n 10 shows the last 10 lines from the end of the file.2fill in blank
mediumComplete 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'
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.✗ Incorrect
The
-i option makes grep ignore case, so it finds 'error', 'Error', or 'ERROR'.3fill in blank
hardFix 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'
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.✗ Incorrect
The
-f option makes tail follow the file and show new lines as they are added.4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
grep -l which lists filenames, not matches.Using
wc -c which counts bytes, not lines.✗ Incorrect
Use
grep -i to find 'failed' ignoring case, then wc -l to count the matching lines.5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Using a variable not defined in the loop.
✗ Incorrect
Use the variable
log as the key and value source in the comprehension. It represents each filename in the logs list.