0

I use a shared Ubuntu computer at the local Makerspace. looking at history I can see some times where I sshd into a remote host... I kinda wish I hadn't done that from here. I am able to run history -c and clear the history, but then everyone else's history is gone too. without going on about creating multiple user accounts, or overt security issues, is there a way to run the terminal without logging activity temporarily, or to use a terminal that doesnt create new history but maintains the old history, or to delete certain history from a point in time? Or is there a command to launch the terminal such that history will not be recorded in that terminal?

The OS is Ubuntu Mate 20.04

4
  • Just edit your .bash_history and remove the lines you don't like. It's only a text file. If the machine is local (ie. you're not accessing it remotely via ssh etc) you can place spaces in front of the command and the command won't be stored in bash history (varies on shell/profiles etc; evidenced in most examples I use on here in my answers; as I don't want examples/support stuff appearing in my command history). I also have my history record dates & times, but that's not the default.
    – guiverc
    Nov 27, 2020 at 1:29
  • yeah I could do that, I has hoping for an argument to the terminal command that could do it automagicaly.
    – j0h
    Nov 27, 2020 at 1:34
  • Just put a space at the start of the command and it doesn't get placed in the history. Copy/paste this to test it yourself: " ls | grep a" - be sure to copy the space at the start of it. Then, push the up arrow (or check your history file) and you'll see that it's not included. I'm not sure that this needs a full answer? It is also probably a duplicate. Someone has to have asked this before.
    – KGIII
    Nov 27, 2020 at 1:51
  • maybe clear history and make .bash_history immutable, also maybe watch command on that file to make sure and alert if altered. chattr -i- <filename> and auditctl -w /path/to/that/file -p wa ... see askubuntu.com/search?q=auditctl
    – pierrely
    Nov 27, 2020 at 5:00

1 Answer 1

6

History is a feature of the shell, not of the terminal.

If you are using the bash shell, then the default $HISTCONTROL=ignoreboth means that commands preceded by whitespace will not be written to history. So if instead of

$ ssh you@host

you wrote

$   ssh you@host

it likely would not be recorded. More generally, you could use the HISTIGNORE variable to ignore commands based on pattern matching ex. HISTIGNORE='ssh *' or even (to ignore all commands) HISTIGNORE='*'. You can unset HISTIGNORE when you're done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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