sudo -i vs sudo -s

December 28th, 2009 by Leandro Morgado

A long time ago, every time I needed to do some admin work on Linux I used to “su -” into a root shell. After moving from Debian to Ubuntu, I noticed that “su -” would not work as the root account was disabled. So I started fooling the system with:

shell> sudo su -

But that was more a hack than anything else. You don’t actually need to run su with sudo to get a root shell. You can either sudo right away with:

shell> sudo -i
shell> sudo -s

So what are the differences between these? Well, the -i switch gives you the root shell environment, working the same way as “su -“. The -s switch preserves your own environment, and is equivalent to just running “su” with the dash.

Obviously, I’m not the only one who has come across this question and Ubuntu docs have a full page on this.

Happy rooting! 🙂

Leave a Reply

You must be logged in to post a comment.