What's the difference between "sudo -i" and "sudo su -" [closed] What's the difference between "sudo -i" and "sudo su -" [closed] bash bash

What's the difference between "sudo -i" and "sudo su -" [closed]


su has only one purpose: to start a shell running as the given user (root by default).

sudo is a highly configurable program that lets you run any command as any user, with the configuration allowing the local administrator to place limits on what commands you can run using sudo, as well as which commands require your password.

su is (I believe) the older program which allows you to do anything the given user can do, which is often more than you need. sudo is safer in that it can be tailored to allow you just enough authority to run the commands you need, nothing more.


http://linux.die.net/man/8/sudo

The -i (simulate initial login) option runs the shell specified by the password database entry of the target user as a login shell. This means that login-specific resource files 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 interactive shell is executed. sudo attempts to change to that user's home directory before running the shell. The security policy shall initialize the environment to a minimal set of variables, similar to what is present when a user logs 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.