su -

Switch to another user account (full login environment)

su - username switches to another user with their full login environment. Without the dash, su keeps your current environment, which can cause PATH issues. Exit returns to the previous user.

Example

$ su - postgres
$ whoami
postgres
Tip: Type it yourself in the terminal below - reading is not the same as doing.