1

Anyone want to comment on sudo bash in comparison to sudo su and sudo -i?

I know sudo -i is the preferred because "environment".

I've gotten into the bad habit from years ago when I was a kid in a basement of using sudo bash.

I know it's rather kludgy and awkward, but it works.

I'm looking for a precise and compelling argument to cut my brain free from this habit.

Please tell me why my method is trash? I need an intervention.

4
  • What does this have to do with Ubuntu? Apr 8, 2014 at 19:27
  • Alright, you got me, not much. I was just here reading something else that got into the whole sudo su vs sudo -i discussion and thought I'd branch that off into another question. Perhaps this explains why it hasn't already been asked here.
    – flickerfly
    Apr 8, 2014 at 19:31
  • 2
    askubuntu.com/questions/376199/…
    – Rinzwind
    Apr 8, 2014 at 19:31
  • Both those other questions talk about how it is different, but not why I should stop using 'sudo bash' so I don't think these present the answer to why 'sudo bash' is a bad idea.
    – flickerfly
    Apr 8, 2014 at 19:53

1 Answer 1

2

I don't think sudo bash is wrong, it's just less convenient. For one, it's 2 more characters than sudo -i. With sudo bash you're just starting bash as another user (try doing it and doing pwd to see what the current directory is), whereas sudo -i "attempts to change to that user's home directory before running the shell". sudo -i tries to give you an "environment similar to the one a user would receive at login". Also, sudo -i will read "login-specific resource files such as .profile or .login". Finally, sudo -i will honor the shell the user set in /etc/passwd.

On a single-user system these aren't likely to matter too much, but unless you never expect to work on a system other than yours, you'd do well to train yourself to do things the recommended way.

sudo su is also possibly not entirely wrong (and isn't longer than sudo -i), but this option is plainly ugly and looks really kludgy; if you can sudo, why sudo su, instead of sudoing a proper shell? also, sudo su will not properly set the user's login environment, you need sudo su - for that, at which point you're again typing 2 more characters than sudo -i.

Not the answer you're looking for? Browse other questions tagged .