How to view bash_history for root?

I have a linux box on amazon aws EC2. I can view the bash_history user here:

/home/ec2-user/.bash_history 

However, when I root in:

 sudo -s 

I do not get root bash_history. How can I browse / find bash_history for admin user?

Thanks Brett

+7
source share
4 answers

You can run the history command to view the current user history.

+4
source

Here is a quick way:

 sudo less /root/.bash_history 
+8
source

When you "sudo -s", you apparently get the .bash_history of the original account because $ HOME does not change.

Try setting $ HOME to ~ root before you sudo -s.

+1
source

Enable logging in sudo by inserting it with visudo

 Defaults logfile=/var/log/sudo.log 
+1
source

All Articles