Solved Linux History: Not clearing between -
-
History is a great tool to have - But it has gotten a bit long on the Ubuntu system I have running.
Accessing from Windows - it's aver 180 lines now,.. and I've cleared it via
history -c
. Yet when I access the same system from Termius all 180(+) lines are there. Runninghistory -c
clears, but then on Windows - it's still there.This is using the same sign-on, just a different device in which the system is accessed.
To not make assumptions - am I interrupting how the
-c
works incorrectly? Or should it indeed clear it regardless of access source? -
@gjacobse I don't remember about -c specifically but I am pretty sure you can go to your bash profile and set the amount of history you want to keep.
-
@gjacobse said in Linux History: Not clearing between -:
But it has gotten a bit long on the Ubuntu system I have running.
Is this causing some kind of problem?
-
@EddieJennings said in Linux History: Not clearing between -:
@gjacobse said in Linux History: Not clearing between -:
But it has gotten a bit long on the Ubuntu system I have running.
Is this causing some kind of problem?
Only in the sense that as I have been learning - I've made errors,.. and to prevent continuing those errors, if I clear the hsitory, I can then re-enforce the correct commands. Not to mention I copied some content, and made the mistake of pasting it back into the terminal... resulting in about 20-30 lines of meaningless junk.
-
@jmoore said in Linux History: Not clearing between -:
@gjacobse I don't remember about -c specifically but I am pretty sure you can go to your bash profile and set the amount of history you want to keep.
I haven't spent any time in the bash profile. so I will look into this. Right after this call should have been an email
-
@gjacobse said in Linux History: Not clearing between -:
@EddieJennings said in Linux History: Not clearing between -:
@gjacobse said in Linux History: Not clearing between -:
But it has gotten a bit long on the Ubuntu system I have running.
Is this causing some kind of problem?
Only in the sense that as I have been learning - I've made errors,.. and to prevent continuing those errors, if I clear the hsitory, I can then re-enforce the correct commands. Not to mention I copied some content, and made the mistake of pasting it back into the terminal... resulting in about 20-30 lines of meaningless junk.
I see. The environment variable you're wanting to look for is HISTSIZE, I believe.
-
https://eshlox.net/2017/08/01/bash-increase-command-history-size
You'll be decreasing the size instead
-
@gjacobse said in Linux History: Not clearing between -:
History is a great tool to have - But it has gotten a bit long on the Ubuntu system I have running.
Accessing from Windows - it's aver 180 lines now,.. and I've cleared it via
history -c
. Yet when I access the same system from Termius all 180(+) lines are there. Runninghistory -c
clears, but then on Windows - it's still there.This is using the same sign-on, just a different device in which the system is accessed.
To not make assumptions - am I interrupting how the
-c
works incorrectly? Or should it indeed clear it regardless of access source?which Ubuntu? There was a bug in older ones (maybe current too not sure) that it didn't clear the history.
You can try
history -cw
but if that doesn't work justecho "" > ~/.bash_history
-
@EddieJennings said in Linux History: Not clearing between -:
https://eshlox.net/2017/08/01/bash-increase-command-history-size
You'll be decreasing the size instead
I don't know that the size is so much of an issue as the inability of deleting it. Having 200 lines is fine -
-
So - this is my confusion now:
root@TuDallasNC:~# echo "$HISTFILE" /root/.bash_history root@TuDallasNC:~# sudo vi /root/bash_history ~ ~ ~ ~
The listed history file is - well - blank. But obviously - it isn't as it's now 202 lines (default seems to be set to 1000)
Incidently - when I do execute the
history -c
it clears - but when i re-connect it is still there. -
@gjacobse wouldn't the . be part of the filename though? So it would be "sudo vi /root/.bash_history"
-
@jmoore said in Linux History: Not clearing between -:
@gjacobse wouldn't the . be part of the filename though? So it would be "sudo vi /root/.bash_history"
Quite true indeed - so I missed i there,.. but didn't here:
190 sudo nano ~/.bash.history
-
This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.
-
You also could've run
history -d linenumber
to have removed things that were incorrect or frivolous. -
@gjacobse said in Linux History: Not clearing between -:
History is a great tool to have - But it has gotten a bit long on the Ubuntu system I have running.
A bit long would be like.... 100,000 lines?
-
@gjacobse said in Linux History: Not clearing between -:
This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.
It's a history, clearing stuff out doesn't really make sense.
-
@DustinB3403 said in Linux History: Not clearing between -:
You also could've run
history -d linenumber
to have removed things that were incorrect or frivolous.Done that also - didn't do anymore than
history -c
did. -
@scottalanmiller said in Linux History: Not clearing between -:
@gjacobse said in Linux History: Not clearing between -:
This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.
It's a history, clearing stuff out doesn't really make sense.
It does if he wants to document a process to getting something to work and only having valid commands visible.
If he had a typo or whatever else, leaving that in the history could cause issues later.
-
@scottalanmiller said in Linux History: Not clearing between -:
@gjacobse said in Linux History: Not clearing between -:
This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.
It's a history, clearing stuff out doesn't really make sense.
And could possibly be seen as malicious intent.
-
@DustinB3403 said in Linux History: Not clearing between -:
@scottalanmiller said in Linux History: Not clearing between -:
@gjacobse said in Linux History: Not clearing between -:
This has been helpful - I've managed to edit the file, and after making a backup, and editing it down to clear out the garbage.
It's a history, clearing stuff out doesn't really make sense.
It does if he wants to document a process to getting something to work and only having valid commands visible.
If he had a typo or whatever else, leaving that in the history could cause issues later.
Still doesnt make sense, because if you know which line is incorrect, just dont copy that line. You still have to know which line is incorrect to delete