3

This is a little embarrassing but I'm unable to delete the root user shell history from a FreeBSD 10.0 server. The root user is using the default csh.

I've tried the classic history -c command to clean up the history and it works... until I logout and login on the server again.

Tried to remove the ~/.history file without success too.

Any ideias of what to do?

5 Answers 5

6

If you are looking to clear your history (On FreeBSD 10.1 w/ (t)csh).

echo > /root/.history && history -c

3

This command:

rm /root/.history

should do what you're after, though it may be getting written back out when you logout. If you simply want history never stored, you could do this:

echo > /root/.history
chflags schg /root/.history

which empties the file then sets it immutable.

2
  • I'm voting up your answer, but I've already done the rm option and it was no effect, which is insane to me. I've tried even rewriting the history file with not effect. Jul 4, 2014 at 2:51
  • 2
    You must remove the history file and clear your shell's history; otherwise the shell will write out to the history file everything it read in when it initialized. Making the file immutable is overkill. Additionally, the variable histsize can be set to zero to disable history. Dec 30, 2014 at 0:50
1

Not 100% sure if HISTSIZE variable exists in (t)csh, but it might.

So try with

setenv HISTSIZE 0
rm -f /root/.history

And see if it helps.

1

This might works for you too not sure for (t)csh shell

history -w

OR

rm .bash_history
0

To disable history for tcsh/csh type the following:

unset history; unset savehist

or you can also do the following:

set history = 0; set savehist = 0

Either one will disable history from being saved.

You can also edit the ~.cshrc file and change the following:

set history = 1000 
set histsave = 1000

to

set history = 0 
set histsave = 0

Then everytime you login to your server it will keep history commands from being saved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .