Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 1367  / 1 Year ago, fri, december 16, 2022, 12:07:52

I seem to have discovered that the ~/.bash_history file doesn't contain what is displayed when you use the up arrow. I found this by doing a command like so



smbclient -L 10.2.10.240 -umyuser -p"mypassword on the command line is bad" 


This command is actually wrong, it has a mistake, the -u is actually supposed to be a -U and so this command failed.



However I also realized that that was bad to do, because it puts your password into the history, I went into .bash_history and what was interesting was that it doesn't have the mistake. It only has



smbclient -L 10.2.10.240 


and that's it. But this is were it gets weird, if you use the up arrow the whole command including mistakes is there for you to edit.



So the question is, why is there a difference between what is in .bash_history and what the up arrow displays? Where does the up arrow data live?



Before you point it out; it's quite convenient in this case because it prevents my password from being saved, but, that's not why it's doing this, I also tested it with correct options and then it does save the whole command including passwords and all.


More From » bash

 Answers
2

The ~/.bash_history file is only updated when you close/exit from the terminal. While you are in the terminal you can browse backwards in commands which was entered in that session. So if you exit from that terminal session your history will be updated with the missing command.



Also if you put a space at the beginning of a line, before the command, that command won't be saved in the history. This is a good practice if you issue a command which you don't want to be included in the history.


[#27985] Saturday, December 17, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bblerest

Total Points: 240
Total Questions: 119
Total Answers: 113

Location: Wallis and Futuna
Member since Mon, May 18, 2020
4 Years ago
;