AnApprentice
AnApprentice

Reputation: 110970

How to view the bash_history for root?

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

/home/ec2-user/.bash_history

However when I root in:

sudo -s

I do not get the root's bash_history. How can I view/find the bash_history for the admin user?

Thanks, Brett

Upvotes: 7

Views: 36223

Answers (4)

tombolinux
tombolinux

Reputation: 208

Enable the logging within sudo, by inserting this with visudo

Defaults logfile=/var/log/sudo.log

Upvotes: 1

Steve
Steve

Reputation: 54392

Here's the quick way:

sudo less /root/.bash_history

Upvotes: 11

Morgan O'Neal
Morgan O'Neal

Reputation: 1118

You can run the history command to see the current users history.

Upvotes: 6

user1277476
user1277476

Reputation: 2909

When you "sudo -s", you apparently get the .bash_history of the source account, because $HOME is unchanged.

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

Upvotes: 1

Related Questions