Hi developers and users, It is so exciting to have Rocku linux with great stability and performance. As a new user I am worried that if the root user can see deleted bash_history of sudo user (my). Is there any mechanism to do so? I do not want my bash history (I have sudo) be read by the root user or other sudo users. Please inform me if there is something I can do for deleting the bash_history automatically or not keeping the history in the disk at all.
Sounds sketchy lol. But yes, you can entirely disable bash history by adding the following to your
set +o history
If you only want to disable the history file (and not the ephemeral in-memory history), use this instead:
One I know of as an alternative to the above:
Another option is to set
ignorespace which will not record any line entered if it begins with a space. This is a bit sneakier in that it can lead others spying on you to believe they are successful, but it is useful because it allows you to not pollute your history with redundant cmds etc. See the bash man page or info pages for other options for HISTCONTROL. I do NOT condone hiding of information from others in general; I do condone optimizing space and search efficiency though.
I feel it is appropriate to mention that someone with root would be able to modify Bash so that it records your keystrokes whether you’ve disabled the history feature or not. Perhaps you know in your case it is unlikely that they will do so, but you should be aware that in principle you cannot guarantee privacy from users with that kind of access to a machine.
Maybe you could use like a session based history setup - meaning you’ll clear it on logout. You could try using
# # ~/.bash_logout # # clear session history -a && history -c
When an interactive login shell exits, or a non-interactive login shell executes the
exitbuiltin command, Bash reads and executes commands from the file
~/.bash_logout, if it exists. »»»