public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* Re: [gentoo-user] Questions about History file
  @ 2014-01-08 15:56 99% ` Alan McKinnon
  0 siblings, 0 replies; 1+ results
From: Alan McKinnon @ 2014-01-08 15:56 UTC (permalink / raw
  To: gentoo-user

On 08/01/2014 14:10, Tanstaafl wrote:
> Hi all,
> 
> I routinely am logged into a server with multiple consoles (I log in
> with one (the same) regular user, then su - to root).
> 
> This morning I tried to grep roots .bash_history for a command I ran
> some time ago, and it wasn't there. I know I ran it, so I'd like to
> configure my bash history so this doesn't happen again.
> 
> Thinking about it a bit, the first issue I see is... when I am running
> multiple consoles, each one having been started by first logging in as
> my normal user, then su - to root, how does this affect the
> .bash_history file? It seems like there would be a collision of some
> kind, maybe result in the last one to log out 'winning' (that
> .bash_history is the one that is saved/stored) or something?
> 
> Maybe... would it be possible to use different regular users, then when
> each one does the su - to root, have it create a separate .bash_history
> file based on the original username? That would be perfect.
> 
> I was also considering something like setting HISTSIZE=###, then adding
> something to the logrotate.conf file to start rotating the history file,
> so I don't lose anything - but I'm not sure if that would even work.
> 
> So, I'm interested in how others do this... especially on a system that
> has multiple users managing it.
> 
> Thx... Charles
> 
> 
> 


Most important thing is to understand that a shell history file is
intended as a nice convenience for users. When the shell runs, it keep a
history of that session in RAM, and when the shell exits properly it
simple appends the list to the history file. It is just that simple, but
of course there's no guarantees at all. Two sessions don't exit at
exactly the same time, so as far as I know it's simple fs mechanisms
that prevent clobbering.

If a command that should be in history isn't, then it's that the session
has not yet closed, it does without exiting properly, or the command was
run >500 commands ago.

I don't know of any bash mechanism to easily create and use different
history files depending on which user did the su. You would probably
have to concoct a custom wrapper script for this.

I do know that once, long ago, I tried to get bash to do proper command
logging for our general-purpose gateway hosts that have 500+ users. It
was a nightmare and I eventually concluded that history, logging and
such things are 100% the province of the user and not the sysadmin. It
just caused way more trouble than it solved. I suspect what you are
looking for is very much in the same category.



-- 
Alan McKinnon
alan.mckinnon@gmail.com



^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2014-01-08 12:10     [gentoo-user] Questions about History file Tanstaafl
2014-01-08 15:56 99% ` Alan McKinnon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox