To increase History size, Timestamp and to eliminate repeated commands in history

Scenario:  To eliminate duplicate / repeated commands in history, Timestamp for the history commands and also to increase the history size. The default histsize will be 1000.


1. To eliminate repeated commands in history please add the following in the environment.

$ export HISTCONTROL=erasedups

This will eliminate the repeated commands used by the user. Also this will save the histsize.


2. To achieve timestamp in history the following statement should be added in the environment.

$ export HISTTIMEFORMAT=”%F %T “. This will list the history like

karthick@karthick:~$ history

1  2012-10-05 14:25:51 cat history

2  2012-10-05 14:29:10 mv .bash_history.bak .bash_history

3  2012-10-05 14:29:27 cat .bash_history

4  2012-10-05 14:29:32 ls

5  2012-10-05 14:29:57 env

6  2012-10-05 14:31:07 test

7  2012-10-05 14:31:18 setup

8  2012-10-05 14:32:14 cat .bashrc

9  2012-10-05 14:41:08 history


3. To increase the history  command length from default size 1000 to our requirement size

$export HISTSIZE=10000


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: