Hack 56. Change the history file name using HISTFILE

by Ramesh

By default, history is stored in ~/.bash_history file. Add the following line to the .bash_profile and relogin to the bash shell, to store the history command in .commandline_warrior file instead of .bash_history file. I’m yet to figure out a practical use for this. I can see this getting used when you want to track commands executed from different terminals using different history file name.

# vi ~/.bash_profile
1 George January 21, 2014 at 7:29 am

This is useful for when you want to relocate your history file outside of your home directory. There’s a variety of practical applications. This is required on certain platforms like HP-UX when you’re using an NFS mounted home filesystem. Also handy when you want your history erased between reboots; mount /tmp as tmpfs in RAM, and put your bash history file on /tmp.

2 Aman February 20, 2014 at 4:18 am

This is used, when you don’t want user to access his history files and want to keep it for audit purpose.

Comments on this entry are closed.

Previous post:

Next post: