Can I obtain full 'history' or is it flushed on reboot?

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I type history and only see the last 15 entries.
For my own benefit and less support requests from people - be lovely if I could find all my old commands so I can remember what I've done.


If this isn't written to disk (only this sessions boot) can I, enable full history?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
You know, I just shut down my FreeNAS server so in the meantime here is what I suggest you do, perform a Google search for "freebsd history command" and you will find the link. There is a file created called .sh_history but I do not know if that is created in FreeNAS nor if it is overwritten. Take a look at it, maybe you can find the answer. Please share what you find out.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I did some googling but I haven't found anything yet.
That file does not appear to exist though.

root@freenas[/]# find . -name '*sh*history*.*'
(no results)
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
If your root account is configured for csh, then the file is at /root/.history. By default, it's configured for 1000 in /root/.cshrc.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
If your root account is configured for csh, then the file is at /root/.history. By default, it's configured for 1000 in /root/.cshrc.

Apologies, for the extremely late reply.
Firstly, it looks like the file I need is ".zsh-histfile" as I'm SSH'ing in and it (seems) to have, I would speculate, maybe 1000 entries, could be a few hundred, regardless it's helpful

My bigger issue, is I'd like, when I type "history" to show me, significantly more from the histfile, it only goes back 10.
Can I type 'history 1000' or even
history set-default 1000 or something?

Honestly, I'd love a full history, of everything I ever type in there. I can't tell you how many times I've asked people something here a second or third time, because I haven't done a function in months.
 

SteveKB

Dabbler
Joined
Dec 30, 2021
Messages
17
Relatively new to the game, but I see the same thing...its like things aren't quite being sourced correctly. Typing 'history' only shows me the 15 last commands, yet there's a lot more in .zsh-histfile. If I echo $SHELL, it tells me I'm using .zsh (/usr/local/bin/zsh).
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
We're actively discussing ZSH's clear deficiencies and are thinking of vulgar terms to describe it over in another thread.


I think the correct fix is to change the shell to tcsh.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I didn't feel confident enough messing with this to fix the issue up. I wish both my Ubuntu Server and TrueNAS machines offered like

"history" (comes back with 50 entries)
or

"history -all" and it just does every command ever ever, that seems so damn useful, couldn't be more than 15MB of data.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
You should be aware that having multiple shells open simultaneously will result in one of them "winning" the history race. History is not shared between shell processes, so if you open one shell at 9AM, do a thousand commands, open another at 4PM, issue one command, close the first shell, the history file will be written (containing the thousand), and then close the second shell, the history file will be written (containing the one), and you no longer have the thousand commands in your history the next time you start a shell.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
You should be aware that having multiple shells open simultaneously will result in one of them "winning" the history race. History is not shared between shell processes, so if you open one shell at 9AM, do a thousand commands, open another at 4PM, issue one command, close the first shell, the history file will be written (containing the thousand), and then close the second shell, the history file will be written (containing the one), and you no longer have the thousand commands in your history the next time you start a shell.
I have learnt this over the years and it's 1% frustrating, it's not the issue though. I tend to stick to one shell and I get 15 entries.
Someone, smarter than me, will write a guide on how to fix this.

It baffles me in a time of having so much storage available to us and so much unnecessary data, logged, that this is the stuff that's being lost.
I only 'fiddle' with my TrueNAS shell every few months but my current install is 4 years old now, there's things I did 4 years ago I could learn from in my own history.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
I tend to stick to one shell and I get 15 entries.

So set HISTSIZE and SAVEHIST to whatever the hell makes you happy. It's a shell. It's configurable, just like everything in UNIX. What's the issue?
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
So set HISTSIZE and SAVEHIST to whatever the hell makes you happy. It's a shell. It's configurable, just like everything in UNIX. What's the issue?


man zsh
no reference to histsize in here.


I type history "1000" it returns about 20 results.
 
Top