Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 208
AnApprentice Avatar asked Oct 30 '12 22:10

AnApprentice


People also ask

Where is the bash_history file located?

In Bash, your command history is stored in a file ( . bash_history ) in your home directory.

What is root bash_history?

The /root/. bash_history file consists of entries including commands run from Bash by user root or any remotely authenticated user who has Advanced Shell privilege.

How do I find root command history in Linux?

In Linux, there is a very useful command to show you all of the last commands that have been recently used. The command is simply called history, but can also be accessed by looking at your . bash_history in your home folder. By default, the history command will show you the last five hundred commands you have entered.

Does Root have a Bash history?

bash_history located in the home directory of that user. I'm used to using the shortcut list via the up key on the keyboard which shows the last used command for that user. If you log in as root then you will be shown the history for the root user.


1 Answers

Here's the quick way:

sudo less /root/.bash_history
like image 110
Steve Avatar answered Oct 01 '22 09:10

Steve