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

Manuel Jordan
  • 1,768
  • 7
  • 30
  • 50
  • 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 04 '20 at 00:56
  • 2
    Possibly helpful or possibly even more confusing: https://askubuntu.com/questions/331062/what-is-the-functional-difference-between-sudo-su-and-sudo-i – chili555 Apr 04 '20 at 01:28
  • @user535733 about They land you in different working directories according with the link shared by @chili555 - which refers to other - https://help.ubuntu.com/community/RootSudo#Special_notes_on_sudo_and_shells is not correct. Observe the table values – Manuel Jordan Apr 04 '20 at 03:45
  • @ManuelJordan 'working directory' is different from 'home'. – user535733 Apr 04 '20 at 12:09
  • Consider to write your answer, if you can add more details would be excellent ... – Manuel Jordan Apr 04 '20 at 12:49
  • 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! – André Clérigo Apr 04 '20 at 02:17

1 Answers1

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)