Understanding `history` for bash -


yesterday ssh-d remotefs , performed commands.

today not appear in history. frustrating, took time @ commands used.

i problem. suspect using same login multiple simultaneous terminal sessions maybe results in separate history each. , changing user (e.g. elevating superuser) opens different set of histories.

could explain scientifically life-cycle of history? when new 1 created? how access/view existing ones? , under circumstances history destroyed? ever amalgamated?

depends on variable settings, default there 1 history file per user, not per terminal session.

the history nowadays held in in-memory buffer , written out history file when buffer full or on logout. therefore multiple terminal sessions under same user can overwrite each other's history. history system not suitable multiple sessions under same user id.

if want keep sessions separate, modify variable histfile.

it might seem neat set:

histfile="$home/.bash_history$$" 

where $$ gives current pid. while gives each terminal session own history, becomes maintenance nightmare history files floating around.

there other variables control history, see man bash description. can also:

set | grep '^hist' 

which might instructive.

don't tempted edit history file text editor. binary file (contains non-text fields) , can trashed.

when new 1 created? first time history filename used.

how access/view existing ones? depends name have given them.

and under circumstances history destroyed? when histsize exceeded (default 500 lines). histsize lines stored. remember file overwritten when in-memory buffer full, or on logout. have histappend option:

shopt -s histappend 

which append session rather overwrite. careful using this, end-up huge history file.

do ever amalgamated? no, not unless write script it, or set histappend.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -