zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

Bash history timestamps

June 3, 2011 by Igor Drobot Leave a Comment


Maybe you know this problem, if more than one user has root access to a server you have very little chances to control who was it. The only hook could be date and time. Default if you issue the “history” command you see a command number and the operation.

Put the next line in your .bashrc and you will see date and time in your history:

1
2
# Bash Timestamps
export HISTTIMEFORMAT="%F %T "

# Bash Timestamps export HISTTIMEFORMAT="%F %T "

Finely to make it work execute:

1
source .bashrc

source .bashrc

Your new history format:

1
2
3
4
5
536  2011-05-31 22:06:44 less /var/log/syslog
537  2011-05-31 22:06:46 ll
538  2011-05-31 22:06:54 vim rssh.pl
539  2011-05-31 22:07:07 perl rssh.pl
540  2011-05-31 22:07:16 ss -lnp

536 2011-05-31 22:06:44 less /var/log/syslog 537 2011-05-31 22:06:46 ll 538 2011-05-31 22:06:54 vim rssh.pl 539 2011-05-31 22:07:07 perl rssh.pl 540 2011-05-31 22:07:16 ss -lnp

Filed Under: Linux Tagged With: bash, Debian, history

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok