Linux Shell History Search Command description

$HISTSIZE

$HISTSIZE command helps you to determine the number of commands history in your current environment.

By default, in most distributions it is 500 or 1000.

Sample syntax of :

# echo $HISTSIZE  

See your terminal after run the command, our system has 1000 commands in command history.

Here you can also change the number of commands in command history if you want. Practice your own ability.

Sample syntax of :

# HISTSIZE=<number>  

Like example of :

# HISTSIZE=1200  

See your terminal after run the command, we have changed the number of commands in our command history.

HISTFILE

HISTFILE command points to the file that contains your history.

Its default value in bash shell is ~/.bash_history.

Sample syntax of :

# echo $HISTFILE  

See your terminal after run the command, it shows the file containing history.

$HISTFILESIZE

$HISTFILESIZE command helps to set the number of commands kept in your history file.

Sample syntax of :

# HISTFILESIZE=<number>  

Like example of :

# HISTFILESIZE=2500  

See your terminal after run the command, we have changed the HISTFILESIZE from 2200 to 2500.

!!

!! command is also pronounced as ‘bang bang’ command.

It is repeats the last typed command in your shell.

Sample syntax of :

# !!  

See your terminal after run the command, ‘ls’ command is repeated by passing ‘!!’ command.

‘echo’ command will be repeated has also repeated.

!

! command is pronounced as one bang. Last typed command will be repeated by ‘!!’.

When you want to repeat other commands then you can use ‘!’ command. you can followed by one or more characters of that command.

Sample syntax of :

# !<characters>  

See your terminal after run the command, command “!fi” repeats the above command ‘file office’.

!n

!n denotes a number.

Just type ‘!’ followed by the command line number you want to use and that command will be execute.

Sample syntax of :

# !<lineNumber>  

Like example of :

# !1043  

See your terminal after run the command, we have executed command ‘ls’ from the line number 1043.

If you understood this article then you can practice now. Thank you.