Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What are some tricks for avoiding bash history being logged in a fascist logging environment that does not involve modifying .bash_rc or deleting content from within the history file?

share|improve this question
4  
use another shell e.g. sh –  strugee Jul 27 '13 at 2:33
1  
@strugee never thought of that... –  josten Jul 27 '13 at 2:36
3  
So that means no rm ~/.bash_history; ln -s /dev/null ~/.bash_history? –  TAFKA 'goldilocks' Jul 27 '13 at 5:27
1  
@goldilocks no plausible deniability with that one haha –  josten Jul 27 '13 at 5:49
    
Depending on how often you want to do that, see Temporarily suspend bash_history on a given shell? or How do I close a terminal without saving the history? –  Gilles Jul 27 '13 at 22:36
add comment

marked as duplicate by Gilles, jasonwryan, Mat, Anthon, manatwork Jul 28 '13 at 11:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

up vote 4 down vote accepted

I guess you have .bash_profile, and this startup file calling .bashrc? Do you have write permission on .bash_profile?

Otherwise, if you just dont want to log some commands, run

$ unset HISTFILE

then all commands afterward wont be logged within that session

share|improve this answer
add comment

One possible solution is to stop logging bash history is:

set +o history

and to reset, that is to start logging again:

set -o history
share|improve this answer
add comment

On stackoverflow they had some decent answers:

  • Add a space to your command.
  • Add [ \t]* to HISTIGNORE
  • Add ignorespace to your HISTCONTROL environment variable

Although not all of them may apply for your situation, those seems like the only options.

share|improve this answer
1  
It's important to note that HISTIGNORE/HISTCONTROL stop commands from being added to the history list. This probably keeps them from being logged, too, but it also makes them impossible to access with normal history keys (like up and down arrow, ctrl-R, etc.) So if you're used to editing and repeating previously typed commands, these settings are really annoying. –  rici Jul 27 '13 at 4:08
    
Adding a space specifically requires the first character to be a space, right? –  phs Jul 28 '13 at 0:49
add comment

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