Overview
At times you would like to audit engineers commands
executed at specific date and time on the server(s) especially wherein servers
are running critical applications and engineers don’t execute unauthorized
commands in a bash shell.
Other scenario is the view the commands that
have been executed when you have to compile an RCA document.
Applies To
Tested on RHEL 7, CentOS 7 with bash profile
Pre-Requisites
·
None
Bash History Setting
To view the currently configured setting of the bash history
run the command below;
cat .bash_profile | grep
HISTTIMEFORMAT
Note: if history not
configured nothing would displayed.
View History
To list the commands executed previously, run the command below;
in this case the date and time is not displayed.
Bash Attributes
Bash history attributes that can be configured and its purpose is as per below table.
Attribute
|
Display
|
%d
|
Day
|
%m
|
Month
|
%y
|
Year
|
%T
|
Time
|
Configure Bash
To display the date and time of this commands history, we
need to reconfigure “~/.bash_profile” with HISTTIMEFORMAT and export the environment
variable.
echo 'export
HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
After re-configuring the profile, logout and login back to
view the date and time of each command executed run command;
history
Wow! I'm basically impressed by the way you awriter.org
ReplyDeletedetailed out just about almost everything. It's definitely going to assist me a fantastic deal. Thanks for sharing your thoughts so clearly.