[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: save commands history.

> >>Try adding this to your /etc/profile script. This assumes they use bash.
> >>
> >>if [ "$USER" = "whoever" ]
> >>then
> >>  mail admin yourdomain com < /home/whoever/.bash_history
> >>fi
> >
> >
> > And what prevents him from clearing the log in his logout script?
> > You'll just get a nice empty file mailed to you every time he logs
> > in....
> >
> True, I didn't know how linux savvy of a user he was dealing with. Ours
> wasn't and this worked for us.

Actually, even if he empties it on logout, it will still write the commands
from that login sessoin.  bash will write the command history as the last
step of logging out.  Try it out yourself . Put

echo "" > ~/.bash_history

in your .bash_logout file.

Logout, Login.  in your .bash_history will be listed all the commands from
your previous login session (command prevoius to that were zereoed out from
the echo "" > ~/.bash_history statement in the user's .bash_logout.

The trick is then upon logout, if you can send yourself an email after his
own ~/.bash_logout has been executed you can get a list of commands for that
session.   That I do not know how to do.  But if you figure out how to
execute commands after ~/.bash_logout, you can get his commands for that
login session.

You may also want to do a
rm ~/.bash_history
touch ~/.bash_history

before you email yourself his .bash_history file in case the savy user does
something smarter like

ln -s ~/.bash_history /dev/null

Ben Yau

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]