0
0
Linux CLIscripting~10 mins

History command and search 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 code to show the last 10 commands from your history.

Linux CLI
history [1]
Drag options to blanks, or click blank then click option'
A| tail -10
B-10
C-n 10
D-c 10
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.
2fill in blank
medium

Complete 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'
A'git'
B'grep'
C"git"
Dgit
Attempts:
3 left
💡 Hint
Common Mistakes
Including quotes that may cause grep to look for literal quotes.
Searching for 'grep' instead of 'git'.
3fill in blank
hard

Fix 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'
Ass
Bssh
Csh
Dssh -p
Attempts:
3 left
💡 Hint
Common Mistakes
Typing incomplete command start like 'ss' or 'sh'.
Adding extra options after the bang which is invalid.
4fill in blank
hard

Fill 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'
Adocker
B10
C-5
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-5' with tail which is invalid.
Searching for wrong keyword in grep.
5fill in blank
hard

Fill 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'
Aline.split()[0]
B'python'
C' '.join(line.split()[1:])
Dline
Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole line as key or value without splitting.
Checking for wrong keyword in the if condition.