Keep logs of user after sudo su
By Anuket Jain On 19 August 2015 In Home
After executing “sudo su -” or “su – ” user will get access as root, And Generally Its difficult to track which command is executed by user in log format.
This tutorial/Commands help you to keep log/watch on the command which are executed by user.
Follow below steps to keep logs of user:
Step 1:
First we need to create an directory where we save the log.
# mkdir -p /var/log/historylogs
Step 2:
Paste the following content in “.bashrc” file.
# vim /root/.bashrc
export HISTSIZE=10000 export HISTTIMEFORMAT="%F %T " export HISTFILE=/var/log/historylogs/history-$(who am i | awk '{print $1}';exit) export PROMPT_COMMAND='history -a'
Step 3:
After coping the content in “.bashrc” file run following command:
# source /root/.bashrc
Now you must have history of commands in this logs.