Freebsd – “su” when the password is unknown but you’re in “wheel” with “no password”

freebsdpasswordrootsudousers

I'm on FreeBsd 11. I have a user "user123" belonging to the group wheel and wheel has %wheel ALL=(ALL) NOPASSWD: ALL in /usr/local/etc/sudoers.

I don't know the password of root. However, I'm able to run "sudo" without one.

I've installed Postgresql and run it via "service start".

Now I want to log in as the postgresql user and create a database or other stuff:

$ su postgres
Password:


# or

$ su - postgres
Password:

But I don't know the password.

Is this the password of the user root or the user postgres? I don't know any of them. Is there a standard workaround for this?

Best Answer

If you want to login as postgres, and you have sudo access without password requirements, do:

sudo -iu postgres

The -i starts a login shell.

Related Question