Sudo su vs sudo -i
If you ever wondered, sudo su
and sudo -i
are not exactly the same.
sudo su
- Calls
sudo
with commandsu
, i.e. Bash is called as interactive non-login shell. It executes only.bashrc
and you remain in the same directory. sudo su -
- Logs in as super user, i.e.
/etc/profile
,.profile
and ``.bashrc`are executed and you are logged in to root’s home directory with root’s environment. sudo -i
-i = simulate initial login. The manpage for sudo says:
Run the shell specified by the target user’s password databaseentry as a login shell. This means that login-specific resourcefiles such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell’s -c option. If no command is specified, an interacātive shell is executed. sudo attempts to change to that user’s home directory before running the shell. The command is run with an environment similar to the one a user would receive at log in. The Command environment section in the sudoers(5) manual documents how the -i option affects the environment in which a command is run when the sudoers policy is in use.
Sources⌗
- AskUbuntu
- man sudo