Context:
ssh
ed into an AWS t1.micro instance running Amazon Linux 2013.09, using the default ec2-user
. I'm trying to list the contents of the default postgresql directory:
What's in there?
$ ls /var/lib/pgsql9/
ls: cannot open directory /var/lib/pgsql9/: Permission denied
Ok. Who owns this?
$ ls -l /var/lib | grep pgsql
drwx------ 4 postgres postgres 4096 Jun 22 16:06 pgsql9
Ah. Silly me.
$ sudo -u postgres ls /var/lib/pgsql9/
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for ec2-user:
... What? ec2-user
has a password? Time for a bigger gun.
$ sudo sudo -u postgres ls /var/lib/pgsql9/
backups data
Success! Now, off to superuser.com to figure out what happened.
sudo ls /var/lib/pgsql9
would work too.root
can access stuff even if it's not in the permissions