I have used linux:Kali for a while and to get root access i just needed to type: su in terminal. But in OSX i need to type in su - what does this - mean?

If i just type su in terminal than i get sh-3.2# in next line

whereas if i type su - then i get root# in next line.

What's the difference between all of these commands.

Also i see some other commands to get root access in terminal: (1) su bash (2) sudo su

Please help to understand difference b/w all these commands.

2 Answers 2


From man su:

-l      Simulate a full login.  The environment is discarded except for
        HOME, SHELL, PATH, TERM, and USER.  HOME and SHELL are modified
        as above.  USER is set to the target login.  PATH is set to
        ``/bin:/usr/bin''.  TERM is imported from your current environ-
        ment.  The invoked shell is the target login's, and su will
        change directory to the target login's home directory.

-       (no letter) The same as -l.

As for su versus sudo, it's generally accepted in Apple circles that sudo is the preferred method of working in root. By default, su is disabled on OS X (as is the root account). There are only a few occasions when I've had to enable root to get things done.

For more information, I recommend reading both manpages.

man su man sudo

  • i am starting to learn bash scripting. So, i wanted root access to practice few codes. Thanks a lot :* Sep 28, 2014 at 5:21
  • 1
    It's a very, very bad idea to practice coding as root. You want as low-power an account access as possible so as to ensure that something you do incorrectly cannot have dramatic, system-wide effects. Only use root privs when you absolutely need them, e.g., when installing compiled binaries: ./configure ; make ; sudo make install. Kisses back atcha. Sep 28, 2014 at 5:23
  • thanks a lot for such a great comment. But i'll test them on my pc(installed Hackintosh in it) not my original MacBook Sep 28, 2014 at 5:27
  • Enjoy, @StackOverflow32. :) Sep 28, 2014 at 5:30

You forgot my favorite way to root:

sudo -s

That says to make a new root shell and gets all the modern and advanced sudo goodness like more fine grained access to grant or deny root in specific cases and also sets up a proper root shell, no matter if you use bash or another shell.

Also, sudo asks for your password, not the other user’s password and in the case of root, Apple doesn’t make a root password by default. This lets you get root without futzing in the majority of macOS systems you will use.

You must log in to answer this question.

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