Separating Sudoers History


Posted on: Dec 27th, 2009

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.

  1. su into the root account.
  2. Open the ‘.bash_profile’ file in a text editor.
  3. Add the following code to it.

export HISTSIZE=3000
export HISTFILESIZE=5000
export HISTFILE=/root/.bash_hist-$(who am i | awk '{print $1}'; exit)

  1. Save the file.
  2. 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.


About the author


Aditya is a Linux fanatic, a nature photographer, a music fiend... He spends most of his time these days listening to Music while browsing the Internet about various topics of his interest ranging from Electronics to coffee recipes.


http://www.noob2geek.com/wp-content/plugins/sociofluid/images/digg_48.png http://www.noob2geek.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://www.noob2geek.com/wp-content/plugins/sociofluid/images/delicious_48.png http://www.noob2geek.com/wp-content/plugins/sociofluid/images/technorati_48.png http://www.noob2geek.com/wp-content/plugins/sociofluid/images/google_48.png http://www.noob2geek.com/wp-content/plugins/sociofluid/images/myspace_48.png http://www.noob2geek.com/wp-content/plugins/sociofluid/images/facebook_48.png http://www.noob2geek.com/wp-content/plugins/sociofluid/images/twitter_48.png
Leave a Reply


Latest Posts

Tags

under contruction..