How to undo a sudo command?

I used the following sudo command " sudo rm -rf ~/ .Trash/"  because my trash can wouldn't empty.  Unfortunately this deleted everything on my computer.  Any way to undo this command?  Please help????

Linc Davis wrote:
I'm not sure what you mean, but if you gave those instructions, please don't do it again. There is absolutely no reason ever to run such a command, even if the syntax were correct. Also, make sure you test any advice you give on this site on your own computer, as required by the terms of use.
I have given that command, but with the proper syntax, any number of times, with absoutely no adverse affects. When I do give that command, or any command with rm, I take great pains to emphasize that it absolutely must be copied and pasted in. And I triple and quadruple check the syntax before I post it. And then I make sure that the Jive formating hasn't screwed with it in any way after posting. Given certain situations, it can be very useful.

Similar Messages

  • Help me "undo" a sudo command

    Hello there,
    Please help the newbie and tell me please how to undo the following terminal command:
    sudo ln -s /System/Library/Filesystems/fusefs.fs/mount_fusefs /usr/bin/mount_fusefs
    Do it in a way where I would I understand what I did in the first place and how it is going to be undone...
    TIA!

    +sudo rm /usr/bin/mount_fusefs+
    This removes the symbolic link you created without disturbing the original. If you want certainty, create a test file, create a symbolic link to it, then remove the symbolic and you will see that the original is still there.

  • How to undo terminal commands

    ...sigh... being new to MAC I shouldn't have just assumed I could putz around and make changes like I used to with PC.
    So, I use Gradebook (I'm a teacher) and unfortunately, it's reliant on Java.
    So the other day I made the mistake of updating Java and it sent my world into a tailspin.  Gradebook suddenly stopped working.  It would just bounce in my dock but never open.
    Then I found out it was having issue with the new Java.  So I found instructions  to reverse the Java update  and go back to Java 6 here which required me to go into terminal and make changes:  http://support.apple.com/kb/HT5559?viewlocale=en_US
    I did that.  Now everyone claims that Gradebook fixed their issue with the new Java.  But I'm still having that bouncing then nothing problem.  So someone suggested I upgrade to Mavericks.  So I did... and when I re-tried Gradebook it told me I needed to download Java 6 for it to work, so I got excited thinking my problems were solved.  But nope... bouncing in the dock then nothing.
    Now I'm thinking those changes I made in Terminal are what the problem is.  So I googled how to remove those entries and I went into .bash and deleted them (kept a copy of what I was deleting though, just in case)  Didn't work.  So now I've read that I have to UNDO my changes and not delete them.  But I have no idea how to do that.
    This was my entire history in that .bash file:
    /Applications/Android\ File\ Transfer.app/Contents/MacOS/Android\ File\ Transfer ; exit;
    'lookupd -flushcache''lookupd -flushcache'
    'lookupd -flushcache'
    'lookupd -flushcache
    'lookupd -flushcache'
    /Applications/Gradebook.app/Contents/MacOS/JavaApplicationStub ; exit;
    sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
    sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
    sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
    sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI .plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
    sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
    sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
    sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
    sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
    sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI .plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
    sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
    sudo ln -s /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
    sudo ln -s /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
    sudo ln -s /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
    sudo update_prebinding -root / -force
    sudo update_prebinding -root/-force
    exit
    sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
    man sudo
    sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
    The red are the ones I put in.  That blue one references Gradebook but I don't recall entering that.
    Help me please???   I'd really, really appreciate it! 

    There are instructions at the bottom of the page you linked to that tell you how to undo it.
    Editing the .bash_history file only removes commands from the recorded history, it doesn't undo them. Although doing that isn't going to cause any problems, it does reveal a tendency to fiddle with "arcane knowledge" without fully understanding it. That's very, very bad, as doing the wrong thing in the Terminal could easily cause irreversible damage to the system that can only be fixed by reinstalling. It could even lead to data loss.

  • Help, i made a terminal command and i don't know how to undo it.

    i found my long lost folder of terminal commands.. and i forgot what this one did, so i clicked it (i made the commands into a "unix executable file").. and all my files on my desktop are now hidden.. the only way to find them is to type in the file name into finder.
    the command i typed in was
    while (true) do
    chflags hidden ~/Desktop/*
    done
    and now everything on my desktop is gone, and i dont know how to undo it, I undid once about 3 months ago when i wrote it, but i forgot what i did. I tried counterering the command with others but it isn't doing anything. thank you
    edit: i know this command cant destroy my system because it wasn't a sudo, but still, i had all my class work on my laptop and now it's all invisible

    Hi, try this...
    while (true) do
    chflags nohidden ~/Desktop/*
    done

  • How to disable sudo command in Terminal

    How to disable sudo command in Terminal

    Bad idea.
    Only an Admin user can use sudo, so if you have users on your system that you do not want to use sudo, then do not give them an admin account, and do not give them the password for an admin account.

  • Hi guys, I have a big problem! My bookmark shortcut entry(command D) does not work anymore and do you know by any changes how to undo resetting of Safari? Thnx a million :)

    Hi guys, I have a big problem! My bookmark shortcut entry(command D) does not work anymore and do you know by any changes how to undo resetting of Safari? Thnx a million

    Try troubleshooting the Safari .plist file.
    Quit Safari.
    Open a Finder window. Select your Home Folder in the Sidebar on the left. It has a small house icon. Then open the Library folder then the Preferences folder.
    Move the com.apple.Safari.plist file from the Preferences folder to the Desktop. Relaunch Safari. Try a bookmark.
    If that didn't help, check Safari / Preferences then select the Extensions tab. If you have any installed, turn that off, quit then relaunch Safari.
    If Extensions aren't the issue, reset Safari. From the menu bar click Safari / Reset Safari. Select the top 7 buttons, click Reset.

  • How To Undo A Recently Processed Command

    Hi,
    If I recently processed a command:
    CmdUtils::ProcessCommand(someCmd);
    How do I undo the said command?
    Should I use:
    ICmdHistory->Undo(steps, target);
    The target here is the IDatabase that I can get from ICommandMgr->GetTargetDB(), right?
    Thanks,
    -- Jeff

    Linc Davis wrote:
    I'm not sure what you mean, but if you gave those instructions, please don't do it again. There is absolutely no reason ever to run such a command, even if the syntax were correct. Also, make sure you test any advice you give on this site on your own computer, as required by the terms of use.
    I have given that command, but with the proper syntax, any number of times, with absoutely no adverse affects. When I do give that command, or any command with rm, I take great pains to emphasize that it absolutely must be copied and pasted in. And I triple and quadruple check the syntax before I post it. And then I make sure that the Jive formating hasn't screwed with it in any way after posting. Given certain situations, it can be very useful.

  • What is sudo command for? can I undo sudo commands?

    what is sudo command for? can I undo sudo commands?

    Niel wrote:
    If a dialog box appears that asks for your password, ask yourself whether you're doing anything that requires it, such as logging in, using sudo, moving or copying items in some system-level folders, or installing software. Mistyping a command may delete files that should remain intact, or damaging the Mac OS X installation by moving files around or altering permissions on certain components.
    (30169)
    Is there any way that I could know that those problems are occuring>>> i'm referring to "moving files" and altering permissions on certain components?
    and when you say altering permissions? what do you mean by that?
    is there anyway that I can fix it? or buy a certain software for mac that would fix the system problems? like in windows there are Norton system work
    I was wondering I copy and paste the said command to my terminal but it didn't work. Do you know what would happen to my system if I messed up with that command? >>>im referring to this command http://docs.info.apple.com/article.html?artnum=307354
    Message was edited by: Mac Ken

  • How can I undo a terminal command?

    I have altered the default location of screenshots taken on my iMac. Origionally the screenshots were sent to my desktop.
    I created a folder and named it screenshots. I then opened a terminal screen which was found in the finder, under utilities. Then I copied the following into the command line "defaults write com.apple.screencapture location". Then before clicking return, I dragged the folder I named "screenshots" into the terminal window. Then I typed "killall SystemUIServer" to reset the terminal and the changes took effect.
    I am curious now, how to undo these changes if I want to?

    I don't believe you are using a PPC iMac, so you may want to change your profile configuration to include all the information about your hardware.
    A good utility for doing these types of configurations without the need to know Terminal commands is MacPilot 4.3.1.

  • How do I reverse these sudo commands?

    Are there sudo commands I can enter in Terminal that will reverse these two that I entered?
    sudo ipfw add reject src-ip 173.194.55.0/24 in
    sudo ipfw add reject src-ip 206.111.0.0/16 in
    Thanks!

    sudo ipfw show
    Will list your rules
    sudo ipfw -q -f flush
    Will reset them to default.
    If you need to keep some rules whilst deleting others you will need to work that out
    If you reboot it should also reset any rules that are not in the config file - rules added manually are not in the config.
    Apple have pulled the manual for ipfw, so I'm unable to show you what Apple's syntax is, look at …
    man ipfw
    to see what I mean.

  • Sudo command gone wrong. HELP!

    I have no experience with command lines in the terminal and naively entered the sudo -s command in terminal.
    I only did some online research after to find that you really have to know what you are doing before entering anything into terminal.
    There has been no damage done to my computer that I can notice yet, but I was wondering if there was a way to check?
    Can you undo sudo commands??
    Also, does this mean computer is vunerable to hackers now? I read online that sudo commands can compromise the security of you system?
    Basically I entered the following:
    * sudo -s
    * my username password
    * sh disable_activation_osx
    When I thought that didn't work I then entered the following:
    * ./disable_activation_osx
    I think I got the sudo command wrong first too
    I typed sudo - s (with an extra space)
    Actually as I type right now I am noticing my cursor keeps jumping lines making it hard to type!!
    I think something is definitely wrong with my computer now!!

    1.  Trying to install bootleg copies of CS5 (or whatever version it is) by following instructions you got off a cracked software site is probably not the smartest thing you could do...
    2.  You probably didn't do it correctly anyway.  But then again maybe you did - if you entered "sudo -s" properly the symbol at teh start of your command line should change from a $ to a #.  you then would have had to run the other commands in the same folder as the disable_activation_osx script was located.
    3.  If you did happen to run those commands properly, then whether your computer is vulnerable or not depends entirely on what was in the script you ran...which I'm guessing you also don't know.  Running arbitrary scripts you get from people supposedly telling you how to install bootleg software - and as the superuser for your system, no less - is also not particularly smart.
    4.  No you cannot "undo" sudo commands.  You can run other commands to effectively undo some things, if you know what you are doing.  Nor can you necessarily check "for damage".  Again, it all depends on the contents of the shell script you may or may not have run.  If you didn't actually run the script, a reboot will probably fix whatever issues you think you are having.
    5.  Next time, acquire your software legally.

  • Sudo Command in Bash Script

    So I created a simple bash script to run on login.....
    one of the commands is the following:
    sudo "something something something"....
    One thing I haven't learned in my years of Unix is how do you get a bash script to run a sudo command without having to enter a password?  I know this is trival, but just a quick 'this is how you do it' would be cool.
    Thanks ahead of time on this really dumb question.

    There's a few ways to do this.  Here's two (pick the method you like):
    Method 1: Using "askpass".
    With this you always do sudo -A command.  The -A argument tells sudo to execute a command that echos the password to stdout.  That command is something you write.  For this explaination let's call the command pw and stick it /usr/local/bin.  So it's full pathname would be /usr/local/bin/pw.
    sudo -A can get the pathname to pw a number of ways.
    1. From the sudoers file.
    Use visudo to add the following line to the sudoers file:
    Defaults:ALL    askpass=/usr/local/bin/pw
    2. Using the SUDO_ASKPASS environment variable.
    export SUDO_ASKPASS=/usr/local/bin/pw
    This might work too (assuming SUDO_ASKPASS has been previously exported):
    SUDO_ASKPASS=/usr/local/bin/pw sudo -A command
    Method 2: Have sudo read the password from stdin
    echo -n password | sudo -S command
    The -S option tells sudo to read the password from stdin so echo pipes it in (without the ending newline).
    The only relatively secure scheme of these two methods is the askpass (-A) method.  At least with that method you have a chance of encrypting/hiding your password down in the command that echoes it to stdout.  The -S method would contain your password explicitly in a script somewhere unless you make other provisions to encrypt/hide it with that technique.

  • Terminal doesn't understand sudo command

    I am installing MacPorts 1.7.0 from a .dmg file. Following, I set up the environment variables in the .profile file, and tried to use Terminal to update using the sudo port selfupdate command from Terminal.
    This is the result I got:
    -bash: sudo: command not found
    Why is this, and what can I do?

    I think the error refers to the command(s) following "sudo." Were you prompted for your password?
    No, that would be:
    sudo fred
    Password:
    sudo: fred: command not found
    But if the command bash is asked to execute is not found you get
    fred
    -bash: fred: command not found
    So I think he is not finding sudo.
    That makes me think that PATH has been messed up, because sudo is in /usr/bin/sudo which is always in PATH unless it has been messed up. Which makes me think that .profile was properly executed, and that is how PATH got messed up.
    So I would look very closely at .profile and make sure PATH is setup correctly. I would expect it to looks something like:
    export PATH="$PATH:/opt/local/bin"

  • Error executing sudo command

    When I try to execute a sudo command I get the following message:
    "sudo: /etc/sudoers is mode 0644, should be 0440
    Segmentation fault"
    What does it mean?
    Thanks for all the help.

    When I try to execute a sudo command I get the following message:
    "sudo: /etc/sudoers is mode 0644, should be 0440
    Segmentation fault"
    What does it mean?
    It means someone has incorrectly modified the /etc/sudoers file, and as a side effect its permissions were changed to an insecure form, so sudo refuses to use the file. It is also possible that the /etc/sudoers file syntax is also invalid, which might also cause the segmentation fault.
    'visudo' should be used to edit the /etc/sudoers file, which would have properly preserved the permissions, as well as verified that the updated /etc/sudoers file contained valid syntax so that sudo would continue to work. See 'man visudo'.
    You now have a problem, in that you can no longer use sudo to fix the permissions.
    You should first try booting your installation DVD. Via the Menu, you can run Disk Utility and run Repair Permissions. Hopefully this will repair the /etc/sudoers file. You could try running Applications -> Utilities -> Disk Utility, however, if it wants to use sudo to elevate its privileges, that would fail, as a broken /etc/sudoers file is still a broken /etc/sudoers file.
    If you have by any chance enabled the 'root' account, you could try logging in as root and fixing the /etc/sudoers file's permissions.
    You should also run visudo, so that the file's syntax is valid.
    I think you can use the Installation DVD to enable the root account. that might be another way to login as root.
    If repair permissions does not work, then maybe you can put your Mac into firewire target mode, mount your Mac's disk on another Mac via firewire, and repair the /Volume/Macintosh HD/etc/sudoers permissions from the working Mac.
    If that failes, the next step is booting your Mac in Single User mode. Search for "Single User Mode" in the forums, and you should find instructions on both booting, as well as how to make the root file system writable so you can change the permissions from single user mode.
    And if that does not work, I think you are left with reinstalling the OS.
    Message was edited by: BobHarris

  • TS4006 is there a way to undo the "Erase" command before the deletion starts?

    is there a way to undo the "Erase" command before the deletion starts while the phone is turned off.  In my case the erase is pending the phone being turned on.  Now that I have found the phone, I don't want the deletion to happen.  How can I undo the command before turning on the iPhone?

    There's no way to block the remote wipe.  But once it's been wiped, you can perform a restore from your backup on either icloud or itunes.

Maybe you are looking for

  • How to create the report in given format???

    Hi there, My table view gets the report in this format. Unit -----Report-----Sum u1----------A---------s1 u1----------B---------s2 u2----------A---------s3 u2----------B---------s4 U3----------A---------s5 U3----------B---------s6 I need report in th

  • Itunes unknown error 1701

    I know this topic has been raised before but I cannot find a resolution.  Opening iTunes prompts me to download a new VoiceOver kit.  It downloads but won't install.  I get an unknown error 1701.  This is latest Mac OS (10.8.3) and iTunes (11.0.4).

  • Very small problem RE: Variable not initializing

    //Hey, folks! Having a small problem here. Compiler keeps telling me that "result" variable may not have been initialized for this method. This is probably an issue of variable scope? It's staring me in the face and I can't see the problem. Can you s

  • Priting same SAPscript form on different printer: different results

    Hi, my client has different printer models and is claiming now that the forms appear different. Do I have to create a SAPscript form for each printer type? Is there a way to use the same form for all printer models? Would we have the same problem usi

  • Add new field in selection-screen and output dynamically

    hi gurus,   i need to add field in selectio-screen. i need to validate the field with existing fields. i need to add this in alv grid output list dynamically. thanks & regards,    kgn9.