HISTORY shell variable management in Unix/Linux
To recall a previous command, we use the history command. There are many options you can set depending on how you want to manage your history.
Set the number of lines to store in history
Use the HISTSIZE variable. Edit ~/.bashrc or ~/.bash_profile and add this:
HISTSIZE=1000 HISTFILESIZE=1000
Log out of the terminal session and login. You will see the changes.
Change the history filename to arulhistory
Use the HISTFILE variable. Edit ~/.bashrc or ~/.bash_profile and add this:
HISTFILE=~/.arulhistory
Log out of the terminal session and login. You will see the changes.
Prevent repeated commands from piling up in history
Sometimes you enter several repeated commands like ls -al and clear. To prevent the duplicate commands from getting stored in history, use the HISTCONTROL variable. Edit ~/.bashrc or ~/.bash_profile and add this:
export HISTCONTROL=ignoredups
Now type history and you won't find previous commands duplicated.
Last Updated on 23 June 2010
Info Home
General
Windows
Linux/Unix
Debian
Mac OS
Apache
Nginx
iPhone/iPod Touch