How do I delete the shell history?

Hey folks.

I can't remove the history of the default shell on FreeBSD 14.1-RELEASE


# history -c
fc: Illegal option -c


Removing the .sh_history file does not help either. It is created again with the same content after the reboot.

Any idea?
thx
 
Unless you have changed to sh as your default shell, the default shell for root is sh and tcsh for regular users. The history for the latter is stored in ~/.history and can be cleared with history -c.

Check what shell you are currently using with echo $0.



[edit]: I had the change of the default shell for 14.0-RELEASE mixed up
 
In ~/.shrc set HISTFILE to an empty string does the job.
Bash:
HISTFILE=
HISTSIZE=50
FCEDIT=vi

You can then delete your old history file ~/sh_history, it won't be created anymore.

From man sh(1):
HISTFILE File used for persistent history storage. If unset ~/.sh_history will be used.
If set but empty or HISTSIZE is set to 0 the shell will not load and save the
history.

HISTSIZE The number of previous commands that are accessible.


With the setting above you still can access your current session history with history command(which isn't really a command see below) defined by HISTSIZE but those commands won't remain once you logged out, if HISTSIZE is set to 0 of course they won't be accessible through the history command.

Note that history command is only an alias to fc -l (I figured this out in that thread)
Code:
root@fbsd:~ # grep fc /usr/share/skel/dot.shrc
alias h='fc -l'
alias history='fc -l'
root@fbsd:~ #
 
Back
Top