Results 1 to 8 of 8

Thread: How to reverse/undo sudo?

  1. #1
    Join Date
    Jul 2008
    Beans
    169
    Distro
    Ubuntu 12.04 Precise Pangolin

    How to reverse/undo sudo?

    I have an SH file

    sudo -i
    run command here

    Once I have run the command, I want to remove the root privileges...

    So... how do I "undo" the sudo command, so speak?
    Last edited by KingNeil; March 8th, 2013 at 08:35 PM.

  2. #2
    Join Date
    Oct 2011
    Location
    ZZ9 Plural Z Alpha
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: How to reverse/undo sudo?

    Code:
    su user_name
    So for me, it would be

    Code:
    su cortman

  3. #3
    Join Date
    Apr 2012
    Beans
    5,343

    Re: How to reverse/undo sudo?

    Code:
    sudo -k
    revokes the user's cached credentials - see the man page for details

    Code:
    man sudo

  4. #4
    Join Date
    Jun 2007
    Location
    Porirua, New Zealand
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: How to reverse/undo sudo?

    Quote Originally Posted by KingNeil View Post
    I have an SH file

    sudo -i
    run command here

    Once I have run the command, I want to remove the root priveleges...

    So... how do I "undo" the sudo command, so speak?
    If you have used "sudo -i", you can return to "normal" privileges with:
    Code:
    exit
    Forum DOs and DON'Ts
    Never assume that information you find using a search engine is up-to-date.

  5. #5
    Join Date
    Jul 2008
    Beans
    169
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to reverse/undo sudo?

    lisati.... that is exactly what I was looking for

    exit
    Thank you. However, I do have another issue... (see next post)
    Last edited by KingNeil; March 8th, 2013 at 08:36 PM.

  6. #6
    Join Date
    Jul 2008
    Beans
    169
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to reverse/undo sudo?

    The issue is... I'm trying to do the following, in an SH file...

    Code:
    sudo -i
    command that requires sudo
    exit
    command that doesn't require sudo
    And, it doesnt seem to work...

    How would I go in and out of a sudo privileges within an SH file??
    Last edited by KingNeil; March 8th, 2013 at 08:37 PM.

  7. #7
    Join Date
    Mar 2008
    Beans
    1,219

    Re: How to reverse/undo sudo?

    Quote Originally Posted by KingNeil View Post
    Code:
    sudo -i
    command that requires sudo
    Why not just sudo command?
    -i is short for 'interactive' and you generally don't use interactive things in scripts.

  8. #8
    Join Date
    Aug 2006
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to reverse/undo sudo?

    Quote Originally Posted by prodigy_ View Post
    Why not just sudo command?
    -i is short for 'interactive' and you generally don't use interactive things in scripts.
    +1. There shouldn't be any need for sudo -i in a script.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •