How to copy bash history?
what command do i use to copy .bash_history to /tmp location?
|
Greetingz!
"cp ~/.bash_history /tmp" or if you want to do that automatically, put that command in a ".bash_logout" for the user in question. If this post (or any other) is helpful, click "Yes" on the bottom right-corner of this post. If this post (or any other) also solves your problem, click "Thread Tools" at the top of the page and mark this as "[SOLVED]". |
Quote:
|
What's the point of doing it when they log in? There'd be no history....
If you really wanted to copy the "old" history on login, just add that line to the top of their .bashrc or .bash_profile (one of those should be in their home dir). |
Quote:
|
Quote:
|
Quote:
|
Okay, let's take this from the top;
How to Copy Bash History to /tmp If any of the files listed here do not exist, create them. They can just have the one command in them, that's okay. On Login: Add the following to the user's .bashrc and/or .bash_profile Code:
cp ~/.bash_history /tmp Add the following to the user's .bash_logout Code:
cp ~/.bash_history /tmp Caveat #2: If you do either of copy-on-login and/or copy-on-logout for more than one user, they will all clobber the /tmp/.bash_history file on each login and logout. Work-Around: Use the following command instead; Code:
cp ~/.bash_history /tmp/`logname`-bash_history-`date +%Y_%m_%d-%H%M` If you're trying to get time/date information of when a certain user runs a certain command, then you need to read the bash manpage. |
All times are GMT -5. The time now is 05:20 PM. |