4

I am reading some tutorials about Linux configurations:

  • To accomplish many of the configurations is important and mandatory be the root.

Well I did realize that in many places are used sudo su and sudo -i, even when both accomplish the the same goal, I have the doubt about:

  • when is mandatory use one approach over the other?

I am doing this question because for some reason exists these two approaches

6
  • 1
    There is no Central Authority to decide what is mandatory and what is not. For most purposes, it does not matter which one you use, so it is a matter of your personal preference. Note that they are not identical: They land you in different working directories and have different environment variables.
    – user535733
    Apr 4, 2020 at 0:56
  • 2
    Possibly helpful or possibly even more confusing: askubuntu.com/questions/331062/…
    – chili555
    Apr 4, 2020 at 1:28
  • 1
    There is a thread about that issue already, that as been answered. Take a look in there, I think this will answer all your questions! Apr 4, 2020 at 2:17
  • @user535733 about They land you in different working directories according with the link shared by @chili555 - which refers to other - help.ubuntu.com/community/… is not correct. Observe the table values Apr 4, 2020 at 3:45
  • @ManuelJordan 'working directory' is different from 'home'.
    – user535733
    Apr 4, 2020 at 12:09

1 Answer 1

4

As pointed by the user @user535733 in the comments section, both commands will take you to different working directory.

sudo su will execute commands as root in your present working directory but sudo -i will take you to your root's home directory (by default to /root)

Another difference is if you are using anything other than bash as your shell sudo -i and sudo su will take you to the shell configured for the root user (bash is default in Ubuntu) while sudo -s uses the shell you configured for your user(e.g, zsh)

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