export HISTFILESIZE=99999

set history file length

set how many commands to keep in history Default is 500 Saved in /home/$USER/.bash_history Add this to /home/$USER/.bashrc HISTFILESIZE=1000000000 HISTSIZE=1000000

1
By: totti
2013-01-02 09:25:06

These Might Interest You

  • Note the space before the command; that prevents your history eliminating command from being recorded. ' history -c && rm -f ~/.bash_history' Both steps are needed. 'history -c' clears what you see in the history command. 'rm -f ~/.bash_history' deletes the history file in your home directory.


    2
    history -c && rm -f ~/.bash_history
    unixmonkey6650 · 2009-10-16 13:48:20 1
  • This could be added to .bashrc. Background: Linux usually saves history only on clean exit of shell. If shell ends unclean, history is lost. Also numerous terminals might confuse their history. With this variable set, history is immedeately written, accessible to all other open shells.


    2
    PROMPT_COMMAND="history -a"
    danam · 2009-10-21 12:33:25 0
  • eh stands for Edit History . Frequently, I'll mistype a command, and then step back through my history and correct the command. As a result, both the correct and incorrect commands are in my history file. I wanted a simple way to remove the incorrect command so I don't run it by mistake. . When running this function, first the ~/bash_history file is updated, then you edit the file in vi, and then the saved history file is loaded back into memory for current usage. . while in vi, remember that `Shift-G` sends you to the bottom of the file, and `dd` removes a line. . this command is different than bash built-in `fc` because it does not run the command after editing.


    7
    eh () { history -a ; vi ~/.bash_history ; history -r ; }
    unixmonkey8121 · 2011-03-23 18:00:20 5
  • By default bash history of a shell is appended (appended on Ubuntu by default: Look for 'shopt -s histappend' in ~/.bashrc) to history file only after that shell exits. Although after having written to the history file, other running shells do *not* inherit that history - only newly launched shells do. This pair of commands alleviate that. Show Sample Output


    10
    $ history -a #in one shell , and $ history -r #in another running shell
    b_t · 2011-11-05 01:19:30 0
  • If the HISTTIMEFORMAT is set, the time stamp information associated with each history entry is written to the history file, marked with the history comment character. Show Sample Output


    0
    echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
    99RedBalloons · 2013-09-19 03:25:14 0
  • On systems where your home directory is shared across different machines, your bash history will be global, rather than being a separate history per machine. This setting in your .bashrc file will ensure that each machine has its own history file.


    4
    export HISTFILE="$HOME/.bash_history-$(hostname -s)"
    rdc · 2012-05-01 13:23:15 0

What Others Think

Also, for those who want unlimited history, you can leave those two (HISTFILESIZE and HISTSIZE) fields blank. source: http://superuser.com/questions/137438/how-to-unlimited-bash-shell-history
silbak04 · 280 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: