A couple of years ago, I did the automatic distribution update from 14.04 to 16.04. For the first time in my life, I was able to continue to use the computer after the automatic distribution update. As usual, the software repositories are all muntered, so system updates don't work properly, but I've gotten by.
I am going to do a clean installation of 18.04, however. In order to be able to configure my system more easily after the installation, I exported my command history to a text file.
$ history > /.../20180915_Command_history.txt
Beautifully, the resulting text file contains line numbers. Somewhat mysteriously, the first line number is 76. After looking at the first few lines, it looks like there were probably some previous commands.
- Do the line numbers just start at 76 for some reason?
- If not, is there any way that I can see lines 1 to 75?
First of all, If you need to get a backup of your command line history, then just copy this file:
Remember that you have to close all your terminals or run
history -a
to append all commands from those history sessions to the history file.Every command that has been saved in your history is available at
~/.bash_history
file, to see all of them open a terminal and run:To get an output similar to
history
command with numbering run:Run this command:
You have to get an output similar to:
As I said before
~/.bash_history
keeps command-line's history.The
HISTFILESIZE
show how many command should~/.bash_history
keeps track of, for mine it's 2000.And
HISTSIZE
is the number of commands thathistory
command (shell built-in actually) keeps track of.When you open a terminal and run
history
, it will picks the lastHISTSIZE
number of commands from~/.bash_history
and shows that to you.If you run new commands it will remove the older ones from session and append the new ones at the end of its list so the number of commands will match
HISTSIZE
.I guess while asking the question you had 74 command more than of
HISTSIZE
in your.bash_history
and that's the reason why it starts at 75.From
man bash
:HISTSIZE
HISTFILESIZE