Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Having a bash history enabled is a security risk, because when you accientally enter your password into the bash the password gets stored in the bash history. To prevent this a good solution would be to configure the bash history not to save commands that were'nt found in $PATH.

So far this is how i setup the history behaviour

# Dont Save duplicated history lines
HISTIGNORE="su":"su *":"sudo *":"sudo":"his":"his *":"history":"history *":"halt":"reboot":"apt-get *":"apt-cache *":"aptitude *":"dpkg *"

# need a bigger history 
# uncomment these lines

It there a way to setup the history so it would only store commands that are in path?

share|improve this question

1 Answer 1

You could put all the commands in the variable, I suppose.

HISTIGNORE=${HISTIGNORE}:`find ${PATH//:/ } -printf %f: |sed s/:$//`
share|improve this answer
umm.. that's the opposite of what you want, isn't it? – Ярослав Рахматуллин Dec 6 '12 at 17:21
yes it is. but i think this might not be solved that easy. it seems that i need a backgroud process or something looking whether the command is in $PATH or not. but thanks anyway – l1zard Dec 6 '12 at 17:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.