Is there a way to seperate the history for all the admin user accounts who ultimately make use of the command ‘su’? Instead of having all the history dumped into a single history file, why not have multiple history files, each corresponding to the particular user in question? Using a simple bash script you can have different history files for all different users. There are a few simple steps to do this.
- su into the root account.
- Open the ‘.bash_profile’ file in a text editor.
- Add the following code to it.
export HISTSIZE=3000
export HISTFILESIZE=5000
export HISTFILE=/root/.bash_hist-$(who am i | awk '{print $1}'; exit)
- Save the file.
- You are done.
What this code does is that it creates a different file for each user logging in as su. If your user ID is 1004, then a file called ‘.bash_history-1004′ will be created that will hold the history for your account.


