How can I switch back normal mode from sudo mode in Linux and Mac OS X?

48

8

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.

Hillman

Posted 2012-03-23T02:53:38.060

Reputation: 581

1By the way, a more straightforward way to get a root shell with sudo is sudo -s. – Spiff – 2012-03-23T09:45:29.880

how is -s more straightforward than su ? does it behave any differently? – Damon – 2014-02-24T03:03:38.733

Answers

73

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

Eric Andres

Posted 2012-03-23T02:53:38.060

Reputation: 863

This also works to get out of sudo -i – Kolob Canyon – 2016-09-22T19:15:07.633

15

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

Posted 2012-03-23T02:53:38.060

Reputation: 861

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??

Xander

Posted 2012-03-23T02:53:38.060

Reputation:

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.

user601576

Posted 2012-03-23T02:53:38.060

Reputation:

This just duplicates the previous answers. – fixer1234 – 2016-06-04T23:16:11.727

This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. – DavidPostill – 2016-06-04T23:22:14.570

Sorry for offending you folks. Just trying to clarify. So have fun all you critics. – None – 2016-06-05T01:49:13.727

I will be deleting this fine information an dropping my participation in your limited blog website. – None – 2016-06-05T01:50:18.217

Hope you critics are happy. Good bye! – None – 2016-06-05T01:50:38.907

@user601576 It's not a blog... If you ever want to come back, I suggest reading the [tour]. – wizzwizz4 – 2018-07-25T13:39:58.897

0

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

rutgersmike

Posted 2012-03-23T02:53:38.060

Reputation: 121