Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there any way I can see at what time the commands were executed from the bash history ? we can see the order but is there any way I can get the time also ?

Bottom-Line : Execution time in the Bash history

share|improve this question

3 Answers 3

up vote 8 down vote accepted

Try this, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

HISTTIMEFORMAT="%d/%m/%y %T "

or

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile ; bash 

Then

history

For more info see man bash or An A-Z Index of the Bash command line for Linux.

share|improve this answer
    
Thank you for answering , just added bash to apply the changes. –  Raja Dec 15 '13 at 12:06
1  
Thanks for the correction :) –  Mitch Dec 15 '13 at 12:06

Open terminalCtrl+Alt+T and run,

HISTTIMEFORMAT="%d/%m/%y %T "

then,

history

To make the changes permanent follow the below steps,

gedit ~/.bashrc

you need to add the below line to .bashrc file and then save it,

export HISTTIMEFORMAT="%d/%m/%y %T "

run the below command to source .bashrc file,

source ~/.bashrc

After that run history command.

enter image description here

source:http://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/

share|improve this answer
    
Thanks for answering , \will it be permanent change ? –  Raja Dec 15 '13 at 12:06

Yes, you can: if you set $HISTTIMEFORMAT, the .bash-history will be properly timestamped. That doesn't help with existing .bash-history content, but will help in the future.

share|improve this answer
1  
can you expand it for more clarity ? –  Raja Dec 15 '13 at 12:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.