KandZ – Tuts

We like to help…!

Linux CLI 16 – history 🐧

cli has a history feature that remembers the previous commands
It is helpful to speed up your work
history → shows all the previous entered commands
history | less → shows all the previous commands but a page at a time
use Pd Dn, Pd Up, Up and Down arrows to navigate. Q to quit
a number after history commands specifies the commands to show
history 10 → shows the last 10 commands
history -c → clears the history of the current terminal session

!! → executes the last command
!5 → executes the command at the position 5
Pressing Ctrl + R on the terminal starts the history search
type the charactes you want to search
press Ctrl + R to go to the next found item
press Ctrl + J to copy the command back to the terminal
or press Enter to execute the command you found

!alias → will repeat the last command in history that starts with 'alias'
!?alias → will repeat the last command in history that contains 'alias'
You can modify your history settings by editing ~/.bashrc
specifies the size of the history
specifies the max size of the history file
displays date and time for each command
appends new commands instead of overwriting them
Ctrl + X → Y to save the file. source ~/.bashrc to apply the changes

Leave a Reply