{"id":1024,"date":"2010-08-05T09:33:59","date_gmt":"2010-08-05T13:33:59","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=1024"},"modified":"2013-03-20T08:43:17","modified_gmt":"2013-03-20T12:43:17","slug":"how-to-set-or-enable-timestamp-for-the-previously-executed-commands-in-linux","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/how-to-set-or-enable-timestamp-for-the-previously-executed-commands-in-linux","title":{"rendered":"How to set OR enable Timestamp for the previously executed commands in Linux?"},"content":{"rendered":"<p>Linux provides a command called &#8220;history&#8221; to view the previously executed commands on shell. By default, the &#8220;history&#8221; command display only the commands that were executed but not the date and time when they were executed. <strong><\/strong><\/p>\n<p><span style=\"color: #0000ff;\">To display the time and date of the previously executed commands, you need to set the &#8220;HISTTIMEFORMAT&#8221; variable.<\/span> The variable has to be set in the users profile file so to take effect on each session.<strong><br \/>\n<\/strong><\/p>\n<p>To set the &#8220;HISTTIMEFORMAT&#8221; variable, SSH to your server and execute:<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># export HISTTIMEFORMAT=\"[%F] [%T] \"<\/span><\/pre>\n<\/blockquote>\n<p>You can also insert the above line at the end of the .bash_profile file<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># vi \/root\/.bash_profile<\/span><\/pre>\n<\/blockquote>\n<p>Once the file is saved, open a new SSH session and execute the &#8216;history&#8217; command to view the timestamp of the previously executed commands.<\/p>\n<p>For example:<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">root@server [~]# history<\/span>\r\n 1068\u00a0 [2010-08-05] [07:17:04] ps -auxf\r\n 1069\u00a0 [2010-08-05] [07:17:06] top c\r\n 1070\u00a0 [2010-08-05] [07:17:35] ll\r\n 1071\u00a0 [2010-08-05] [07:37:51] ls -la\r\n 1072\u00a0 [2010-08-05] [07:41:37] cat \/root\/.bash_profile\r\n 1073\u00a0 [2010-08-05] [07:41:47] cd<\/pre>\n<\/blockquote>\n<p>The commands in the above output is just an example.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux provides a command called &#8220;history&#8221; to view the previously executed commands on shell. By default, the &#8220;history&#8221; command display only the commands that were executed but not the date and time when they were executed.<br \/>\nTo display the time and date of the previously executed commands, you need to set the &#8220;HISTTIMEFORMAT&#8221; variable. The variable has to be set in the users profile file so to take effect on each session.<\/p>\n<p>To set the &#8220;HISTTIMEFORMAT&#8221; variable, SSH to your server and execute:<\/p>\n<p># export HISTTIMEFORMAT=&#8221;[%F] [%T] &#8221;<\/p>\n<p>You can also [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[1015,1011,1012,1013,1014,1009,1008,1010],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1024"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=1024"}],"version-history":[{"count":7,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1024\/revisions"}],"predecessor-version":[{"id":2228,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1024\/revisions\/2228"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=1024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=1024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=1024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}