why deleting bash history is not enough?
I used to think deleting my bash history was enough to clear my bash history, but yesterday my cat was messing around the right side of my keyboard and when I got back into my computer I saw something I typed a month ago, then I started to press all the keys like crazy looking for what could've triggered it. Turns out UPARROW key shows my bash history even after deleting .bash_history.
How can I delete my bash history for real?
linux bash bashrc
|
show 1 more comment
I used to think deleting my bash history was enough to clear my bash history, but yesterday my cat was messing around the right side of my keyboard and when I got back into my computer I saw something I typed a month ago, then I started to press all the keys like crazy looking for what could've triggered it. Turns out UPARROW key shows my bash history even after deleting .bash_history.
How can I delete my bash history for real?
linux bash bashrc
8
.bash_history is overwritten every time you close a bash shell. So if you start bash, delete .bash_history, and log off, you'll have accomplished exactly nothing.
– Shadur
Jan 13 '18 at 14:05
12
Your cat deserves a huge reward. You've been using bash for how long without discovering it has command-line recall and editing? Do you just retype every command line from scratch every time or something? That would make the shell very unpleasant to use.
– cas
Jan 14 '18 at 3:57
@cas ten years. Now that you say it I press Uparrow to repeat commands, but I understood it as kind of a 'short term' memory no more than a few lines long. I wasn't warned that deleting .bash_history won't delete bash history.
– bunden
Jan 14 '18 at 15:31
Deleting~/.bash_history
really does delete~/.bash_history
....but (unless you take steps to prevent it, like clearing the in-memory history by runninghistory -c
just before you logout or settingHISTFILE=/dev/null
or justunset
ing it) bash will just save its current history again when it exits. BTW, theHISTSIZE
env var tells bash how many lines of history to keep in memory, andHISTFILESIZE
tells bash the maximum number of history lines to save. both of these can be set in, e.g., your~/.bashrc
. PS: your cat deserves a 2nd reward for teaching you a valuable lesson :)
– cas
Jan 14 '18 at 16:14
@cas I think deleting .bash_history should delete bash history. It seems intuitive to me. What it doesn't seem intituive is history -c, history -w, unsetting variables.. that's nuts from the user experience perspective.
– bunden
Jan 14 '18 at 16:51
|
show 1 more comment
I used to think deleting my bash history was enough to clear my bash history, but yesterday my cat was messing around the right side of my keyboard and when I got back into my computer I saw something I typed a month ago, then I started to press all the keys like crazy looking for what could've triggered it. Turns out UPARROW key shows my bash history even after deleting .bash_history.
How can I delete my bash history for real?
linux bash bashrc
I used to think deleting my bash history was enough to clear my bash history, but yesterday my cat was messing around the right side of my keyboard and when I got back into my computer I saw something I typed a month ago, then I started to press all the keys like crazy looking for what could've triggered it. Turns out UPARROW key shows my bash history even after deleting .bash_history.
How can I delete my bash history for real?
linux bash bashrc
linux bash bashrc
asked Jan 13 '18 at 13:58
bundenbunden
8818
8818
8
.bash_history is overwritten every time you close a bash shell. So if you start bash, delete .bash_history, and log off, you'll have accomplished exactly nothing.
– Shadur
Jan 13 '18 at 14:05
12
Your cat deserves a huge reward. You've been using bash for how long without discovering it has command-line recall and editing? Do you just retype every command line from scratch every time or something? That would make the shell very unpleasant to use.
– cas
Jan 14 '18 at 3:57
@cas ten years. Now that you say it I press Uparrow to repeat commands, but I understood it as kind of a 'short term' memory no more than a few lines long. I wasn't warned that deleting .bash_history won't delete bash history.
– bunden
Jan 14 '18 at 15:31
Deleting~/.bash_history
really does delete~/.bash_history
....but (unless you take steps to prevent it, like clearing the in-memory history by runninghistory -c
just before you logout or settingHISTFILE=/dev/null
or justunset
ing it) bash will just save its current history again when it exits. BTW, theHISTSIZE
env var tells bash how many lines of history to keep in memory, andHISTFILESIZE
tells bash the maximum number of history lines to save. both of these can be set in, e.g., your~/.bashrc
. PS: your cat deserves a 2nd reward for teaching you a valuable lesson :)
– cas
Jan 14 '18 at 16:14
@cas I think deleting .bash_history should delete bash history. It seems intuitive to me. What it doesn't seem intituive is history -c, history -w, unsetting variables.. that's nuts from the user experience perspective.
– bunden
Jan 14 '18 at 16:51
|
show 1 more comment
8
.bash_history is overwritten every time you close a bash shell. So if you start bash, delete .bash_history, and log off, you'll have accomplished exactly nothing.
– Shadur
Jan 13 '18 at 14:05
12
Your cat deserves a huge reward. You've been using bash for how long without discovering it has command-line recall and editing? Do you just retype every command line from scratch every time or something? That would make the shell very unpleasant to use.
– cas
Jan 14 '18 at 3:57
@cas ten years. Now that you say it I press Uparrow to repeat commands, but I understood it as kind of a 'short term' memory no more than a few lines long. I wasn't warned that deleting .bash_history won't delete bash history.
– bunden
Jan 14 '18 at 15:31
Deleting~/.bash_history
really does delete~/.bash_history
....but (unless you take steps to prevent it, like clearing the in-memory history by runninghistory -c
just before you logout or settingHISTFILE=/dev/null
or justunset
ing it) bash will just save its current history again when it exits. BTW, theHISTSIZE
env var tells bash how many lines of history to keep in memory, andHISTFILESIZE
tells bash the maximum number of history lines to save. both of these can be set in, e.g., your~/.bashrc
. PS: your cat deserves a 2nd reward for teaching you a valuable lesson :)
– cas
Jan 14 '18 at 16:14
@cas I think deleting .bash_history should delete bash history. It seems intuitive to me. What it doesn't seem intituive is history -c, history -w, unsetting variables.. that's nuts from the user experience perspective.
– bunden
Jan 14 '18 at 16:51
8
8
.bash_history is overwritten every time you close a bash shell. So if you start bash, delete .bash_history, and log off, you'll have accomplished exactly nothing.
– Shadur
Jan 13 '18 at 14:05
.bash_history is overwritten every time you close a bash shell. So if you start bash, delete .bash_history, and log off, you'll have accomplished exactly nothing.
– Shadur
Jan 13 '18 at 14:05
12
12
Your cat deserves a huge reward. You've been using bash for how long without discovering it has command-line recall and editing? Do you just retype every command line from scratch every time or something? That would make the shell very unpleasant to use.
– cas
Jan 14 '18 at 3:57
Your cat deserves a huge reward. You've been using bash for how long without discovering it has command-line recall and editing? Do you just retype every command line from scratch every time or something? That would make the shell very unpleasant to use.
– cas
Jan 14 '18 at 3:57
@cas ten years. Now that you say it I press Uparrow to repeat commands, but I understood it as kind of a 'short term' memory no more than a few lines long. I wasn't warned that deleting .bash_history won't delete bash history.
– bunden
Jan 14 '18 at 15:31
@cas ten years. Now that you say it I press Uparrow to repeat commands, but I understood it as kind of a 'short term' memory no more than a few lines long. I wasn't warned that deleting .bash_history won't delete bash history.
– bunden
Jan 14 '18 at 15:31
Deleting
~/.bash_history
really does delete ~/.bash_history
....but (unless you take steps to prevent it, like clearing the in-memory history by running history -c
just before you logout or setting HISTFILE=/dev/null
or just unset
ing it) bash will just save its current history again when it exits. BTW, the HISTSIZE
env var tells bash how many lines of history to keep in memory, and HISTFILESIZE
tells bash the maximum number of history lines to save. both of these can be set in, e.g., your ~/.bashrc
. PS: your cat deserves a 2nd reward for teaching you a valuable lesson :)– cas
Jan 14 '18 at 16:14
Deleting
~/.bash_history
really does delete ~/.bash_history
....but (unless you take steps to prevent it, like clearing the in-memory history by running history -c
just before you logout or setting HISTFILE=/dev/null
or just unset
ing it) bash will just save its current history again when it exits. BTW, the HISTSIZE
env var tells bash how many lines of history to keep in memory, and HISTFILESIZE
tells bash the maximum number of history lines to save. both of these can be set in, e.g., your ~/.bashrc
. PS: your cat deserves a 2nd reward for teaching you a valuable lesson :)– cas
Jan 14 '18 at 16:14
@cas I think deleting .bash_history should delete bash history. It seems intuitive to me. What it doesn't seem intituive is history -c, history -w, unsetting variables.. that's nuts from the user experience perspective.
– bunden
Jan 14 '18 at 16:51
@cas I think deleting .bash_history should delete bash history. It seems intuitive to me. What it doesn't seem intituive is history -c, history -w, unsetting variables.. that's nuts from the user experience perspective.
– bunden
Jan 14 '18 at 16:51
|
show 1 more comment
4 Answers
4
active
oldest
votes
Doing a:
$ history -c; history -w
Will clear history in memory and write that to the HISTFILE file.
That will clear both memory and file history.
If it is required that nothing else of the present session would be written to the history, then, unset HISTFILE
will prevent any such logging.
And make sure tounset HISTFILE
to ensure nothing else gets written at the end of the session.
– Michael Hampton
Jan 14 '18 at 3:15
@MichaelHampton Detail added. Thanks.
– Isaac
Jan 14 '18 at 3:46
1
Editing HISTFILE and doinghistory -c && history -r
would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away.
– Mikko Rantalainen
Apr 9 '18 at 10:52
add a comment |
bash
has a session history in memory which is written to file if the shell variable HISTFILE
is set to a filename when bash
exits.
If you delete the file pointed to by HISTFILE
, unset that variable, and exit bash
, then that shell session will not leave any persistent history.
Failing to unset the HISTFILE
variable but deleting the file would just empty the persistent history, but the current session's history would be saved when the shell exits.
3
Ahistory -c; history -w
will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).
– Isaac
Jan 13 '18 at 15:20
add a comment |
While leaving the shell, do it all in once, like
echo "" > ~/.bash_history & history -c & exit
New contributor
add a comment |
"How can I delete my bash history for real?"
Exit bash, start a different shell, delete the bash history file.
or
logout, log into a different account that has write permission on the history file, delete the history file.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416820%2fwhy-deleting-bash-history-is-not-enough%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Doing a:
$ history -c; history -w
Will clear history in memory and write that to the HISTFILE file.
That will clear both memory and file history.
If it is required that nothing else of the present session would be written to the history, then, unset HISTFILE
will prevent any such logging.
And make sure tounset HISTFILE
to ensure nothing else gets written at the end of the session.
– Michael Hampton
Jan 14 '18 at 3:15
@MichaelHampton Detail added. Thanks.
– Isaac
Jan 14 '18 at 3:46
1
Editing HISTFILE and doinghistory -c && history -r
would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away.
– Mikko Rantalainen
Apr 9 '18 at 10:52
add a comment |
Doing a:
$ history -c; history -w
Will clear history in memory and write that to the HISTFILE file.
That will clear both memory and file history.
If it is required that nothing else of the present session would be written to the history, then, unset HISTFILE
will prevent any such logging.
And make sure tounset HISTFILE
to ensure nothing else gets written at the end of the session.
– Michael Hampton
Jan 14 '18 at 3:15
@MichaelHampton Detail added. Thanks.
– Isaac
Jan 14 '18 at 3:46
1
Editing HISTFILE and doinghistory -c && history -r
would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away.
– Mikko Rantalainen
Apr 9 '18 at 10:52
add a comment |
Doing a:
$ history -c; history -w
Will clear history in memory and write that to the HISTFILE file.
That will clear both memory and file history.
If it is required that nothing else of the present session would be written to the history, then, unset HISTFILE
will prevent any such logging.
Doing a:
$ history -c; history -w
Will clear history in memory and write that to the HISTFILE file.
That will clear both memory and file history.
If it is required that nothing else of the present session would be written to the history, then, unset HISTFILE
will prevent any such logging.
edited Jan 14 '18 at 3:26
answered Jan 13 '18 at 15:07
IsaacIsaac
11.9k11852
11.9k11852
And make sure tounset HISTFILE
to ensure nothing else gets written at the end of the session.
– Michael Hampton
Jan 14 '18 at 3:15
@MichaelHampton Detail added. Thanks.
– Isaac
Jan 14 '18 at 3:46
1
Editing HISTFILE and doinghistory -c && history -r
would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away.
– Mikko Rantalainen
Apr 9 '18 at 10:52
add a comment |
And make sure tounset HISTFILE
to ensure nothing else gets written at the end of the session.
– Michael Hampton
Jan 14 '18 at 3:15
@MichaelHampton Detail added. Thanks.
– Isaac
Jan 14 '18 at 3:46
1
Editing HISTFILE and doinghistory -c && history -r
would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away.
– Mikko Rantalainen
Apr 9 '18 at 10:52
And make sure to
unset HISTFILE
to ensure nothing else gets written at the end of the session.– Michael Hampton
Jan 14 '18 at 3:15
And make sure to
unset HISTFILE
to ensure nothing else gets written at the end of the session.– Michael Hampton
Jan 14 '18 at 3:15
@MichaelHampton Detail added. Thanks.
– Isaac
Jan 14 '18 at 3:46
@MichaelHampton Detail added. Thanks.
– Isaac
Jan 14 '18 at 3:46
1
1
Editing HISTFILE and doing
history -c && history -r
would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away.– Mikko Rantalainen
Apr 9 '18 at 10:52
Editing HISTFILE and doing
history -c && history -r
would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away.– Mikko Rantalainen
Apr 9 '18 at 10:52
add a comment |
bash
has a session history in memory which is written to file if the shell variable HISTFILE
is set to a filename when bash
exits.
If you delete the file pointed to by HISTFILE
, unset that variable, and exit bash
, then that shell session will not leave any persistent history.
Failing to unset the HISTFILE
variable but deleting the file would just empty the persistent history, but the current session's history would be saved when the shell exits.
3
Ahistory -c; history -w
will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).
– Isaac
Jan 13 '18 at 15:20
add a comment |
bash
has a session history in memory which is written to file if the shell variable HISTFILE
is set to a filename when bash
exits.
If you delete the file pointed to by HISTFILE
, unset that variable, and exit bash
, then that shell session will not leave any persistent history.
Failing to unset the HISTFILE
variable but deleting the file would just empty the persistent history, but the current session's history would be saved when the shell exits.
3
Ahistory -c; history -w
will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).
– Isaac
Jan 13 '18 at 15:20
add a comment |
bash
has a session history in memory which is written to file if the shell variable HISTFILE
is set to a filename when bash
exits.
If you delete the file pointed to by HISTFILE
, unset that variable, and exit bash
, then that shell session will not leave any persistent history.
Failing to unset the HISTFILE
variable but deleting the file would just empty the persistent history, but the current session's history would be saved when the shell exits.
bash
has a session history in memory which is written to file if the shell variable HISTFILE
is set to a filename when bash
exits.
If you delete the file pointed to by HISTFILE
, unset that variable, and exit bash
, then that shell session will not leave any persistent history.
Failing to unset the HISTFILE
variable but deleting the file would just empty the persistent history, but the current session's history would be saved when the shell exits.
answered Jan 13 '18 at 14:10
KusalanandaKusalananda
130k17247407
130k17247407
3
Ahistory -c; history -w
will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).
– Isaac
Jan 13 '18 at 15:20
add a comment |
3
Ahistory -c; history -w
will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).
– Isaac
Jan 13 '18 at 15:20
3
3
A
history -c; history -w
will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).– Isaac
Jan 13 '18 at 15:20
A
history -c; history -w
will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).– Isaac
Jan 13 '18 at 15:20
add a comment |
While leaving the shell, do it all in once, like
echo "" > ~/.bash_history & history -c & exit
New contributor
add a comment |
While leaving the shell, do it all in once, like
echo "" > ~/.bash_history & history -c & exit
New contributor
add a comment |
While leaving the shell, do it all in once, like
echo "" > ~/.bash_history & history -c & exit
New contributor
While leaving the shell, do it all in once, like
echo "" > ~/.bash_history & history -c & exit
New contributor
New contributor
answered 7 mins ago
user853069user853069
1
1
New contributor
New contributor
add a comment |
add a comment |
"How can I delete my bash history for real?"
Exit bash, start a different shell, delete the bash history file.
or
logout, log into a different account that has write permission on the history file, delete the history file.
add a comment |
"How can I delete my bash history for real?"
Exit bash, start a different shell, delete the bash history file.
or
logout, log into a different account that has write permission on the history file, delete the history file.
add a comment |
"How can I delete my bash history for real?"
Exit bash, start a different shell, delete the bash history file.
or
logout, log into a different account that has write permission on the history file, delete the history file.
"How can I delete my bash history for real?"
Exit bash, start a different shell, delete the bash history file.
or
logout, log into a different account that has write permission on the history file, delete the history file.
answered Jan 14 '18 at 2:07
useruser
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416820%2fwhy-deleting-bash-history-is-not-enough%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
8
.bash_history is overwritten every time you close a bash shell. So if you start bash, delete .bash_history, and log off, you'll have accomplished exactly nothing.
– Shadur
Jan 13 '18 at 14:05
12
Your cat deserves a huge reward. You've been using bash for how long without discovering it has command-line recall and editing? Do you just retype every command line from scratch every time or something? That would make the shell very unpleasant to use.
– cas
Jan 14 '18 at 3:57
@cas ten years. Now that you say it I press Uparrow to repeat commands, but I understood it as kind of a 'short term' memory no more than a few lines long. I wasn't warned that deleting .bash_history won't delete bash history.
– bunden
Jan 14 '18 at 15:31
Deleting
~/.bash_history
really does delete~/.bash_history
....but (unless you take steps to prevent it, like clearing the in-memory history by runninghistory -c
just before you logout or settingHISTFILE=/dev/null
or justunset
ing it) bash will just save its current history again when it exits. BTW, theHISTSIZE
env var tells bash how many lines of history to keep in memory, andHISTFILESIZE
tells bash the maximum number of history lines to save. both of these can be set in, e.g., your~/.bashrc
. PS: your cat deserves a 2nd reward for teaching you a valuable lesson :)– cas
Jan 14 '18 at 16:14
@cas I think deleting .bash_history should delete bash history. It seems intuitive to me. What it doesn't seem intituive is history -c, history -w, unsetting variables.. that's nuts from the user experience perspective.
– bunden
Jan 14 '18 at 16:51