The “historical past” command finds the checklist of the command that the present person has been invoked. The command accepts passing a trend as a controversy to kind particular instructions from the historical past.

Basic syntax for historical past command:

historical past [OPTIONS...]
Display used instructions
historical past [number]

This command presentations a restricted selection of in the past achieved instructions.

Instance: To print the ultimate 5 instructions you have got used, kind historical past 5.

show used commandsshow used commands
Delete instructions from historical past checklist
historical past -d [number]

Use the -d strategy to delete instructions from the historical past checklist.

Instance: Taking out the 5th (5) command from the historical past checklist.

delete commands from historydelete commands from history
Seek used command inside historical past
historical past | grep [text]

The historical past | grep command is helping you in finding instructions that fit a textual content trend.

Instance: On the lookout for a command that makes use of the phrase “cat.”

search within historysearch within history
Clearing the historical past checklist
historical past -c

The -c (transparent) possibility is used to transparent all instructions from the historical past checklist.

Instance: Listed below are 5 instructions that had been used ahead of, use historical past -c to transparent the checklist.

clear historyclear history
Execute the command with match quantity
!quantity

This command permits you to execute instructions with an match quantity from the historical past checklist. There’s no want to write an entire command.

Instance: Let’s use the 10th command (!10) from the historical past checklist.

execute commands eent numbersexecute commands eent numbers
Write adjustments to bash_history report
historical past -w [filename]

Use this strategy to write all adjustments made within the present consultation to the bash_history report.

Instance: Writing 5 in the past used instructions to the history-list report.

write to bash_historywrite to bash_history

The put up How to Use History Command in Linux gave the impression first on Hongkiat.

WordPress Website Development

[ continue ]