We help IT Professionals succeed at work.

How to remove the entries in the "history" file from the command line

Ou company allows several users access to the root user on our systems.  The problem I am havong is they are "experimenting" with commands that I have had to use to correct errors.  How can I either 1) prevent logging from specific users or 2) erase the history log.  I prefer option 1.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007

Commented:
Do the users login directly as root or do su -

To remove the bash history, just do

rm -f ~/.bash_history

You can have separate history files based on whatever criteria you come up with (eg: login name, terminal name, IP address etc).

For example, to have a separate history file based on the tty name, put the following in ~/.bash_profile

export HISTFILE=$HOME/.bash_history-$(tty|sed #/#-#g)

Author

Commented:
Everyone su to root

What if I just want a separate history file for myself BUT still want the ability to view what other users have done while logged in as root.
CERTIFIED EXPERT
Top Expert 2007
Commented:
In that case, put:

export HISTFILE=$HOME/.bash_history-$LOGNAME

in the root .bash_profile

then everyone will have their own history file based on their login name.  The bash history file is a simple text file, so you view it as per any other text file.

Author

Commented:
Great help!!!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.