Saturday 10 December 2011

Unix History files.

Have you ever thought about where and how the history of commands used in the UNIX server is logged?
I thought of it today and that’s the reason why I share this article with you.
So by this time many people would have guessed that it should be in some file because in UNIX everything is based on file system. Now the next question is what file it is?
Here it is “.sh_history” and “.bash_history” – These are the hidden files which stores the commands what you use. Again the name and location of the files depends on how the configuration set up is. One more point to add is you need to use “ls –a” to list out these hidden files.
Let’s assume the file names are default file names (As mentioned above). The storage of commands and number of commands to be stored in these files are again configuration based. By default its 500 commands/lines.
In most of the cases the default location of these files would be your home directory and in some rare cases I have also seen these files in /etc directory (That again configuration based). So you need to take the pain of locating the directory.               
Don’t get panicked. It’s again very simple to locate the directory. Use the environment variable HISTFILE to find the file name of bash history file.
$ echo $HISTFILE
 As simple as that isn’t it? The below listed are some of the common bash history related variables. Please take the pain of googling to know more about these variables.
HISTFILESIZE, HISTSIZE, HISTTIMEFORMAT, HISTCONTROL, TMOUT and HISTIGNORE  
Hope the information is informative to my readers…

No comments:

Post a Comment