Switch the current terminal to user backup and load a login-style HOME, PATH, and related environment.
Which command is appropriate?
su - USER starts a login shell and initializes the target user's login environment. It differs from non-login su USER.
Detailed explanation
su - backupCorrect. su - backup starts backup's login shell.
su backupIncorrect. su backup changes user but preserves more of the current environment.
sudo -l backupIncorrect. sudo -l lists policy and does not start a shell.
su --preserve-environment backupIncorrect. Preserving the environment is the opposite of the requirement.
Try it yourself
An example you can run in a temporary verification environment.
su --help 2>&1 | grep -E -- '-l|--login' | head -n 1Expected result
login shellに関するhelp行Key points
- Hyphen means login shell
- Initialize target environment
- Different from su USER
Notes
- Environment: util-linux su help / user切替なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Permission bit
A mode bit controlling read, write, execute, or special execution behavior.
Account state
Attributes that determine whether a password or login account can be used.
Resource limit
A per-process or per-user ceiling such as open files or process count.