• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • View the history of commands along with time

    Generally when we try to view the history of the commands in Linux then we only see all the commands which are used but not the time when they were used. Here i will show you how you can view the time and date when the commands were used.
    # history | less
    1 service network restart
    2 ping google.com
    3 vi /etc/resolv.conf
    4 ping google.com
    5 vi /etc/sysconfig/network-scripts/ifcfg-eth0
    6 service network restart
    7 ping google.com
    8 yum -y install samba
    9 yum -y install quota
    10 service iptables stop

    Here above you can see that you are only able to view the commands which were run

    Now to view the history along with time and date
    # export HISTTIMEFORMAT="%d:%m:%Y %T "

    # history | less
    1 08:10:2012 11:31:31 service network restart
    2 08:10:2012 11:31:31 ping google.com
    3 08:10:2012 11:31:31 vi /etc/resolv.conf
    4 08:10:2012 11:31:31 ping google.com
    5 08:10:2012 11:31:31 vi /etc/sysconfig/network-scripts/ifcfg-eth0
    6 08:10:2012 11:31:31 service network restart
    7 08:10:2012 11:31:31 ping google.com
    8 08:10:2012 11:31:31 yum -y install samba
    9 08:10:2012 11:31:31 yum -y install quota
    10 08:10:2012 11:31:31 service iptables stop

    But the export command will be session dependent so as soon as you change session or reboot the changes won't work. So add the export line in your .bash_profile file for permanent changes.
    # vi /root/.bash_profile
    export HISTTIMEFORMAT="%d:%m:%Y %T "

    Related Articles

    Follow the below links for more tutorials

    View the history of commands along with time View the history of commands along with time Reviewed by admin on Monday, October 08, 2012 Rating: 5

    1 comment:

    Powered by Blogger.