In a Linux system, what's the difference between su - spiderman and sudo -u spiderman?
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
In a Linux system, what's the difference between
su - spidermanandsudo -u spiderman? - Assistant
The
su - spidermancommand switches the user to "spiderman" and also sets up the environment as if the user "spiderman" had logged in directly. This means it loads the environment variables and sets the working directory to the home directory of "spiderman".On the other hand,
sudo -u spidermanruns the subsequent command as the user "spiderman" without setting up the environment as if they had logged in directly. It does not load the environment variables or set the working directory to the home directory of "spiderman".In summary,
su - spidermanfully switches to the "spiderman" user including environment setup, whilesudo -u spidermanruns a single command as the "spiderman" user without full environment setup.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.