Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to show the last 10 commands from your history.
Linux CLI
history [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'history -10' which is not a valid option.
Using 'history -n 10' which reads new history lines, not last 10 commands.
✗ Incorrect
The command 'history | tail -10' shows the last 10 commands from the history list.
2fill in blank
mediumComplete the code to search your command history for the word 'git'.
Linux CLI
history | grep [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including quotes that may cause grep to look for literal quotes.
Searching for 'grep' instead of 'git'.
✗ Incorrect
Using 'history | grep git' searches the history output for the word git.
3fill in blank
hardFix the error in the command to recall the last command starting with 'ssh'.
Linux CLI
![1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Typing incomplete command start like 'ss' or 'sh'.
Adding extra options after the bang which is invalid.
✗ Incorrect
Using '!ssh' recalls the last command starting with 'ssh'.
4fill in blank
hardFill both blanks to create a command that searches history for 'docker' and shows only the last 5 results.
Linux CLI
history | grep [1] | tail [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-5' with tail which is invalid.
Searching for wrong keyword in grep.
✗ Incorrect
The command 'history | grep docker | tail 5' shows the last 5 history entries containing 'docker'.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps command numbers to commands containing 'python' from history output.
Linux CLI
commands = [1]: [2] for line in history_output if '[3]' in line}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole line as key or value without splitting.
Checking for wrong keyword in the if condition.
✗ Incorrect
This comprehension maps the command number (first word) to the command text (rest of the line) for lines containing 'python'.