lots of tech info here

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 HISTSIZE 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.

Posted on 23 Jun 2010

TAGS: unix, linux, bash, shell

If you liked this article, subscribe to our Feed, follow us on Twitter (@aruljohn) and/or join our Facebook Page.

Share this with Others

Subscribe

Tags