LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2013, 10:30 AM   #1
sujithspillai90
Member
 
Registered: Jun 2011
Location: India
Posts: 31

Rep: Reputation: Disabled
Question How to view the history with the actual timestamp for the commands?


Hello Friends,

Please could anyone help me to get the actual timestamp using history for the commands typed as user or root.

I have tried using export HISTTIMEFORMAT="%F %T "
and then the history does not give me the actual timestamp, it is showing the current timestamp for all the commands in the history. SO I would like to understnad if it is possible to get the actual timestamp for the history command. It will help me to identify who did/what did/ and when did on my servers.

Aprreciate your help in this.
 
Old 04-29-2013, 10:54 AM   #2
rosehosting.com
Member
 
Registered: Jun 2012
Posts: 222

Rep: Reputation: 62
You can try with 'export HISTTIMEFORMAT="%d/%m/%y %T "'.

Just add the 'export' command to your '.bash_profile':

Code:
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
and execute:

Code:
source ~/.bash_profile
 
1 members found this post helpful.
Old 04-29-2013, 11:13 AM   #3
sujithspillai90
Member
 
Registered: Jun 2011
Location: India
Posts: 31

Original Poster
Rep: Reputation: Disabled
You are great. Thank you very much for the help.
 
Old 05-02-2013, 11:18 AM   #4
sujithspillai90
Member
 
Registered: Jun 2011
Location: India
Posts: 31

Original Poster
Rep: Reputation: Disabled
Dear Friends,

I have tried it in bash and its working superb. But what should I do for C-shells and K-shells. I have tried a bit but nothing worked.please could anyone suggest.
 
Old 05-02-2013, 11:56 AM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
In C-shell use setenv command instead of export cmd.
Code:
~$ setenv HISTTIMEFORMAT "%d/%m/%y %T "
Or, add it to your .cshrc or .profile file:
Code:
~$ echo 'setenv HISTTIMEFORMAT "%d/%m/%y %T "' >> ~/.cshrc
 
Old 05-02-2013, 10:34 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
ksh:

1. try http://www.howtoguides.com/computers.../history.xhtml as referenced in http://h30499.www3.hp.com/t5/Languag...e/td-p/4763299

2. alternately (if that won't work) go to the latter thread and just after that ref (2 posts down) see another option using trap cmd.
 
Old 05-03-2013, 07:39 AM   #7
sujithspillai90
Member
 
Registered: Jun 2011
Location: India
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thank you.

It didnt helped me...still I am seeing the history output with time only. Is there any other options.


Also for k-shell also nothing helped me as of now. Please any advise.
 
Old 05-03-2013, 09:22 AM   #8
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by sujithspillai90 View Post
It didnt helped me...still I am seeing the history output with time only. Is there any other options.
I am sorry if I misunderstood it, but we've just suggested you that how can you set a variable in C and K shells. However, let's know what exactly you want to do?

If your concern is just to check the history of commands for a particular user, then check that user's /home/username/.bash_history file. On the other hand, you can check your systems various logs (i.e. /var/log/... files) to find out who and what a user did on your server.

The command:
Code:
~$ setenv HISTTIMEFORMAT "%d/%m/%y %T "
Will just save a string (i.e. %d/%m/%y %T) in HISTTIMEFORMAT variable, and nothing else. Also using the history command in C shell you will be able to see what command was run at what time.
Code:
~$ history
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh sending commands to actual terminal fatalerror0x00 Slackware 6 10-24-2012 12:59 AM
[SOLVED] How to view 10 lines from history command smilemukul Linux - Newbie 9 06-08-2012 05:52 AM
[SOLVED] How can I view history logs of terminal usage? chinho Linux - Server 3 12-23-2010 11:49 AM
BASH commands include timestamp in filename smudge|lala Linux - General 10 03-23-2006 10:48 PM
View konqueror history???? cmsustud19 Linux - Newbie 4 03-27-2004 04:57 AM


All times are GMT -5. The time now is 09:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration