Search code examples
linuxgnome-terminal

bash history truncated after sudo su


I modified the .bashrc file to make the .bash_history file with "infinite" size and its working only when I sudo su to use root on teriminal, the history file is truncated back to the default 2000 line size any suggestions to solve this please ?

from my .bashrc file :

 export HISTFILESIZE=
 export HISTSIZE=
 export HISTFILE=~/.bash_infinite_history
 PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

Solution

  • When you sudo su (or sudo -i), you are switching users.

    Your personal user has HISTSIZE set, but the user you are becoming (in this case, root) does not.

    If you want, you can set the HISTSIZE for root in his config file (for example, /root/.bashrc), but the histories will be separate.