LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   URGENT! Is there any command to get a history command lines and time in SUSE Linux.? (https://www.linuxquestions.org/questions/linux-software-2/urgent-is-there-any-command-to-get-a-history-command-lines-and-time-in-suse-linux-735144/)

igsoper 06-23-2009 09:55 PM

URGENT! Is there any command to get a history command lines and time in SUSE Linux.?
 
I have to trace back what command and when it is used for the last 3 months. It is quite urgent as I have trouble with the system configuration... Please help me.

Thank you in advance.

Uncle_Theodore 06-23-2009 10:02 PM

What shell do you use? If it's bash, then
You can find the last 500 commands in your ~/.bash_history file
(that is, unless you set the variables $HISTFILE and $HISTFILESIZE to some other values). The file does NOT keep the dates. I don't know any other location that would save the commands you enter by default.

GrapefruiTgirl 06-23-2009 10:07 PM

Exactly as Uncle_Theodore says; I too don't know/believe that the history is preserved anywhere other than its usual place (wherever that is-- inside .bash_history I think) but: FWIW, it goes by number of commands, not time/date, and while I have my bash history set in the thousands of commands, it sometimes *still* isn't enough, even over a several-day period, :confused: so for your future reference, perhaps you should consider setting your history to a very large number.

Sasha

igsoper 06-23-2009 11:29 PM

Thank you so much Uncle_Theodore and GrapefruiTgirl for the advice.

Have a very good day.

IGSoper

colucix 06-24-2009 01:19 AM

To keep the dates you have to set the environment variable HISTTIMEFORMAT. You can assign a format similar to that ones of the command date. For example:
Code:

export HISTTIMEFORMAT="%Y%m%d %H:%M:%S "
will print history as
Code:

20090623 08:19:13 date
20090623 08:19:14 whoami
20090623 08:19:15 make coffee


igsoper 06-25-2009 02:14 AM

Colucix, Thank you so much for the advice. I shall try it. :)


All times are GMT -5. The time now is 11:10 PM.