0

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
Enlico
  • 1,471
  • 16
  • 35
  • Is it a new system? Have you modified the parameters recently? On my system `echo $HISTFILESIZE` is equal to `wc -l $HISTFILE` – Arkadiusz Drabczyk Feb 19 '21 at 18:06
  • No, I've been using this system everyday for one year at least :/ – Enlico Feb 19 '21 at 18:07
  • What OS? Does your `.bash_history` have a creation date? – Andrew Henle Feb 19 '21 at 18:17
  • @AndrewHenle, Archlinux. If [`stat -c '%w' .bash_history`](https://unix.stackexchange.com/a/91200/164309) is the way to answer your second question, then I have no idea why it shows `2021-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
  • Something deleted your `.bash_history` file, and it was recreated at that date and time, probably the first time you logged out or otherwise ended a `bash` session after the file was deleted. [Have you annoyed one of your system administrators lately?](https://en.wikipedia.org/wiki/Bastard_Operator_From_Hell) ;-) – Andrew Henle Feb 19 '21 at 18:26
  • @AndrewHenle, I've updated the question. – Enlico Feb 19 '21 at 18:37
  • @phunsoft, what is _its `file mde`_? – Enlico Feb 19 '21 at 18:59
  • Every one of your `bash` 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:00
  • Who owns your .bash_history and what is its```file mode```. (Sorry for the ```file mde``` typo; saw it too late to be able to edit.) – phunsoft Feb 19 '21 at 19:01
  • You have `HISTCONTROL=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:22
  • @Kusalananda, it's simply not possible, as the commands in `history` are all marked 2021, but I've been using this system much longer. The history simply is not retained as they should be, according to `HISTSIZE` and `HISTFILESIZE`. And I'd like to understand why. – Enlico Mar 02 '21 at 19:57

0 Answers0