November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Add date to bash history

Need to add date to bash history, knowing when some commands were fired.

Before the change:

root@host# history
1 ifconfig
2 ifup eth0
3 ifconfig
4 shutdown -r now

root@host# history
1 ifconfig
2 ifup eth0
3 ifconfig
4 shutdown -r now

Now, make appripriate changes in your bash profile:

echo ‘export HISTTIMEFORMAT=”%d/%m/%y %T “‘ >> ~/.bash_profile
echo ‘export HISTTIMEFORMAT=”%d/%m/%y %T “‘ >> ~/.bash_profile

Open another SSH session and check

Shell

1 Dec/28 – 12:22:13 ifconfig
2 Dec/28 – 12:23:37 ifup eth0
3 Dec/28 – 12:24:51 ifconfig
4 Dec/28 – 12:25:45 shutdown -r now

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>