0
0
Linux CLIscripting~5 mins

History command and search in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the history command do in Linux?
The history command shows a list of commands you have typed before in the terminal. It helps you see past commands to reuse or review them.
Click to reveal answer
beginner
How do you search your command history interactively in Linux?
Press Ctrl + R to start a reverse search. Then type part of the command you want to find. The terminal will show matching commands from your history.
Click to reveal answer
intermediate
What does the command !123 do in the Linux shell?
It runs the command numbered 123 from your history list. This lets you quickly repeat a past command by its history number.
Click to reveal answer
beginner
Explain the use of !! in the Linux shell.
!! repeats the last command you typed. It is a quick way to run the previous command again without retyping it.
Click to reveal answer
intermediate
How can you limit the number of commands shown by the history command?
Use history | tail -n N where N is the number of recent commands you want to see. For example, history | tail -n 10 shows the last 10 commands.
Click to reveal answer
Which key combination starts a reverse search in the Linux command history?
ACtrl + R
BCtrl + S
CCtrl + H
DCtrl + L
What does the command !ls do?
ARuns the last command starting with 'ls'
BLists files in the current directory
CShows the history of 'ls' commands
DDeletes the last 'ls' command from history
How do you repeat the last command you typed?
ACtrl + C
B!!
Chistory
D!1
What does history 5 show?
AThe first 5 commands typed
BAll commands except the last 5
CThe last 5 commands typed
DThe 5th command in history
Which command lets you run a command from history by its number?
Arepeat number
Bhistory number
Crun number
D!number
Describe how to search and reuse a previous command using the Linux history feature.
Think about interactive search and shortcuts to rerun commands.
You got /5 concepts.
    Explain the purpose and basic usage of the history command in Linux.
    Focus on how history helps with command reuse.
    You got /4 concepts.