Linux: enable history for user (howto)

Example: enable history for root user.
Edit ‘bash_profile’:

sudo vi /root/.bash_profile

And add the following two lines:

 HISTFILE='/root/.bash_hystory'
 export HISTFILE

Notes
.bash_profile is executed for login shells (via console, either sitting at the machine, or remotely via ssh).
.bashrc is executed for interactive non-login shells (ie: you’ve already logged into your machine and open a new terminal window inside Gnome or KDE)

Leave a Comment