Config Server Firewall

Environment Variables That Control Linux Command History

The history function, a feature in the Bash Shell, maintains a list of recently issued commands. There are a couple of important shell variables that control Linux Command History.

HISTFILE

Name of text file in which the command history is saved. The default is ~/.bash_history.

When echoed, it returns the full path and name of the user’s history file:

echo $HISTFILE

By default history is saved into the ~/.bash_history file in the user's home directory.

HISTFILESIZE

The HISTFILESIZE variable determines the number of commands saved in HISTFILE. The default is 2000 on Ubuntu Server, 1000 in CentOS.

HISTSIZE

The maximum number of commands to keep in memory for the current bash session. The default is 1000 on Ubuntu Server and CentOS.

Every bash interactive session maintains its own list of commands and When you exit from the shell, the most recently executed commands are saved in the HISTFILE (~/.bash_history).

You can change history variables in the ~/.bashrc file in the home directory.

export HISTSIZE=1000