Search code examples
linuxsudo

Difference between sudo -s and sudo su in mac os


Both sudo -s and sudo su makes user root. is there any some difference?

With sudo -s enter image description here

with sudo su

enter image description here


Solution

  • From man sudo:

     -s, --shell
                 Run the shell specified by the SHELL environment variable if it is set or the shell specified by the invoking user's password
                 database entry.  If a command is specified, it is passed to the shell for execution via the shell's -c option.  If no command is
                 specified, an interactive shell is executed.
    

    So -s keeps your current shell (bash in this case), while omitting it uses the shell of the root user (sh). Myself, I prefer sudo -Es to keep both my shell and environment variables.