71

I use sudo su command to do something in Mac OS X but don't know how to switch back.

Hope you guy can do me a favour.

Jawa
  • 3,619
  • 13
  • 31
  • 36
Hillman
  • 811
  • 1
  • 6
  • 4

5 Answers5

96

Type exit. This will logout the super user and go back to your account.

Eric Andres
  • 1,103
  • 6
  • 10
22

If you run sudo su, that will open a shell as the superuser. Type exit or Ctrl-D to exit this shell.

Normally, you don't run sudo su, but you just run sudo command. Once you type your password, sudo will record a timestamp and let you run more commands under sudo without having to type your password for a few minutes. If you want to clear that timestamp (so that someone else can't run sudo without a password), you can run sudo -k.

Brian Campbell
  • 941
  • 5
  • 11
1

su is used to login into the root account, to logout from this , use Ctrl+D or type exit. Playing with su is very dangerous if not really necessary. The better idea is to add the used into sudo group and use the sudo command. And how come you use sudo su??

0

I entered sudo su and my password and the cursor changed from my user name to sh-3.2# typing the command whoami indicates "root". Exiting and entering sudo -s adds the designator root# to the cursor and entering whoami indicates "root". From this I conclude that the two commands are equivalent. The exit command reverts to the standard user account in either case.

0

Just type exit, and to verify that you're back to "you" type "whoami" and it should NOT say root.

rutgersmike
  • 121
  • 3