|
|
|
|
|
by logic
5751 days ago
|
|
Since everyone's sharing their bash history tips here, I thought I'd throw one out. I've taken to tossing the following lines in my root user's .bashrc over the last few years (which I adapted from a colleague years ago): [ ! -d $HOME/.history ] && mkdir $HOME/.history
set -- `/usr/bin/who -m`
HISTFILE="$HOME/.history/`/bin/date +%Y-%m-%d.%T`.`/bin/hostname -s`.$$.$1"
You end up with a filename something like: 2010-09-17.13:53:27.foohost.14379.logic
The idea is that each shell session gets it's own history file, and the files are kept "indefinitely"; ie. whenever I manually get around to cleaning them up. Keeping that history around is cheap (we're talking about a few megabytes over the life of a given system), and can be invaluable in figuring out the how and why of a particular change even months later.It also serves the purpose of making a best-effort attempt at gathering who "owned" that session (ie. who su'd to root); with multiple admins, this can be pretty handy. It's easily bypassed (and console logins will just show up as "root"), so using this as any kind of audit system would be ridiculous; it's just a useful way of going back in time to see who did what (usually looking of work I did myself, to see how/why I might have made a particular change months ago). The one downside: you lose cross-session history. In practice, especially with multiple users accessing a shared account (multiple admins, etc), this hasn't really bothered me much, as getting someone else's history is annoying anyway. But, some people lean pretty hard on their bash history, and I definitely wouldn't do this for a personal account. (There, I'd just do "shopt -s histappend".) |
|