What is the difference between commands
sudo -i and
sudo su -?
Are they the same?
They may provide functionally close to the same thing, but it seems 'sudo -i' is lighter weight and keeps some handy back references in your environment.
You can see the extra processes by looking at 'ps auxf' (f gives you a forest view)
sudo -i yields this process tree
sudo su - yields this process tree
Note that they are starting from the same bash process pid, 4482, but that su - seems to spawn another step.)
Your first 'sudo' is already elevating your access level to root. Running su without specifying a username inside sudo changes the current user to root twice.
Another way to investigate this is by running both commands with strace -f.
If you diff those two straces, you'll see more exeve's being run for sudo su -.
One more thing.
sudo -i maintains the extra environment variables set by SUDO.
sudo su - clobbers those variables.
Shot answer: No, they are not the same.
Long answer: sudo and su - are different programs that accomplish the same task, that is elevating you to root privileges.
su used to be the de facto way of becoming root on Linux systems. However there was always the need to separate privileges and leave some auditing info behind. Also when you do su - everything you do is done as root and is dangerous to have that much power. Here is where sudo came to the rescue.
sudo has some characteristics that su does not. The key element in sudo is it's ability to to run "one" command as root and then drop privileges to normal user. Example: Remove a file owned by root.
This command will erase the file because sudo will elevate you to root every time you use the sudo command before another command. The next command you ran will be run like a normal user (unless you append the sudo command in the beginning). This allows you to accomplish administrative task and then drop privileges immediately helping you avoid dangerous conditions.
sudo also provides other benefits likes restricting the set of program a user can run, logs commands run under sudo and other things. For more info sudo in a nutshell
When you do su - or sudo -i you do the same thing. That is becoming root but keep in mind that su and sudo are completely different and provide you with different tools as a system admin. Personally I NEVER run su - and my pam policy prohibits it, allowing no one to run it. In my systems you always have to use sudo cause of the added benefits.
More info: Using and enabling sudo