Linux Command Cheat Sheet/Switch user with login shell

Become another user and load their shell profile.

Section: Users Groups and Sessions

Switch user with login shell

bash
bash
su - postgres
Explanation

Classic for service accounts that own app data or databases.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Users Groups and Sessions
Show current user and groups
Display numeric and named identity info.
OpenIn sheetbash1 tag match
Show how the shell resolves a command
Reveal whether a name is an alias, builtin, function, or file.
OpenIn sheetbash1 tag match
Print current username
Show the effective user name.
OpenIn sheetbash1 tag match
Build command lines from stdin
Pass stdin items as arguments to another command.
OpenIn sheetbash1 tag match
Search shell history
Filter previous shell commands.
OpenIn sheetbash1 tag match
Strip directory and suffix from path
Return the last path component.
OpenIn sheetbash1 tag match