I don't want it to do it to my system, but I am wondering, is it possible to delete .bash_history
?
And if yes, then can you bring it up again or there will be no history ever again?
Also, is the history
command using the .bash_history
file?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI don't want it to do it to my system, but I am wondering, is it possible to delete .bash_history
?
And if yes, then can you bring it up again or there will be no history ever again?
Also, is the history
command using the .bash_history
file?
is it possible to delete .bash_history
Sure, it's a file, you can delete it!
Can I delete .bash_history without sudo?
Yes, without sudo
, assuming you are talking about deleting your own .bash_history
. It's your own file, you have permissions on your own home directory.
Then can you bring it up again or there will be no history ever again ?
ever again? Nothing that drastic! Your history up to now will be gone, yes, but new commands you enter will begin to be recorded in (a new instance of) the file.
Also, Is the history command using the .bash_history file ?
The contents are cached in memory by the shell, but yes, ultimately, that is where the history is loaded from.
set -o nohistory
. If you enter that command interactively it's only valid for your current shell; if you want to make the change permanent' you should add it to one of your shell's startup scripts (e.g., .bashrc
). I don't recommend that however, as shell history is a useful feature.
– Wouter Verhelst
Sep 12 '15 at 22:46
Yes, you can, from the login shell.
cd
exec /bin/rm .bash_history
exec
out of your shell if your shell is bash and if you want the file to stay deleted after you delete it.
– Celada
Sep 12 '15 at 19:57
bash
and he was afraid of not being able to login to shell again without this file. – jingyu9575 Sep 13 '15 at 4:17