I've read these two questions and the accepted answers on StackOverflow:
However, I still don't understand why in any bash
session I can see this
$ echo $HISTSIZE
1000000
$ echo $HISTFILESIZE
10000000
$ wc -l $HISTFILE
3822 /home/enrico/.bash_history
$ history | wc -l
1914
where the last two numbers are just... low! And indeed, the history in which I can search for past commands is that short, which means close to useless.
And this is not just now that I write the question! Basically history | wc -l
and wc -l $HISTFILE
have always been that low since I have memory of this system, which I bought in summer 2020. Probably I've misconfigured something in the early days...?
If it is of interest, these are the only lines from my ~/.bashrc
that match hist
case insensitively:
HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=1000000
HISTFILESIZE=10000000
history -a # this is in a function that is assigned to PROMPT_COMMAND
shopt -s cmdhist
shopt -s lithist
HISTTIMEFORMAT="%d/%m/%y %T "
Other info:
$ ls -l .bash_history
-rw------- 1 enrico enrico 59833 Feb 19 18:57 .bash_history
The system in question is mine personal, there's no admin but me (and I'm not knowledgeable for an admin, as you see), and I'm using this system since summer 2020. Nonetheless
$ stat -c '%w' .bash_history
2021-02-05 18:53:22.365436127 +0000
echo $HISTFILESIZE
is equal towc -l $HISTFILE
– Arkadiusz Drabczyk Feb 19 '21 at 18:06.bash_history
have a creation date? – Andrew Henle Feb 19 '21 at 18:17stat -c '%w' .bash_history
is the way to answer your second question, then I have no idea why it shows2021-02-05 18:53:22.365436127 +0000
, as I use bash everyday, and not since just 2 weeks ago. – Enlico Feb 19 '21 at 18:23.bash_history
file, and it was recreated at that date and time, probably the first time you logged out or otherwise ended abash
session after the file was deleted. Have you annoyed one of your system administrators lately? ;-) – Andrew Henle Feb 19 '21 at 18:26file mde
? – Enlico Feb 19 '21 at 18:59bash
processes is writing to the SAME file. The last one to exit, and flush its buffers wins. See my answer at https://askubuntu.com/a/80882/25618 – waltinator Feb 19 '21 at 19:00file mode
. (Sorry for thefile mde
typo; saw it too late to be able to edit.) – phunsoft Feb 19 '21 at 19:01HISTCONTROL=ignoreboth
, which means duplicates are ignored and not saved (and commands starting with a space won't be saved either). Maybe you're just not typing that many unique commands? – Kusalananda Mar 02 '21 at 19:22history
are all marked 2021, but I've been using this system much longer. The history simply is not retained as they should be, according toHISTSIZE
andHISTFILESIZE
. And I'd like to understand why. – Enlico Mar 02 '21 at 19:57