How to get password for sudo

Allen picture Allen · Feb 9, 2015 · Viewed 17.7k times · Source

I'm trying to use the command sudo -i -u postgres for PostgreSQL, and the Google Compute Engine VM is asking me for my password for my account (not root).

As I never issued a password, and I always login to my server via SSH key, I'm not sure what the password is, how I can reset it, or where it can be found.

Please tell me where I can get my password?

Answer

Misha Brukman picture Misha Brukman · Apr 19, 2015

To become another non-root user on a GCE VM, first become root via password-less sudo (since that's how sudo is configured on GCE VM images):

sudo su -

and then switch to the user you want to become or run a command as another use, e.g., in your case, that's:

sudo -i -u postgres