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.

flickerfly
  • 7,509

1 Answers1

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.

roadmr
  • 34,802