Find the answer to your Linux question:
Results 1 to 9 of 9
Geez. Not the time to make a mistake like this at midnight :P. Arrghh... now iceweasel is highlighting every word as mispelt. Anyways, I accidentally rm -fr /usr/lib/'ed. It was ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    1

    Help! Accidentally bombed /usr/lib/



    Geez. Not the time to make a mistake like this at midnight :P. Arrghh... now iceweasel is highlighting every word as mispelt.

    Anyways, I accidentally rm -fr /usr/lib/'ed. It was actually an rm -fr * as root, but the cd command before it had a typo.

    I'm really tired, but I don't want to shut down my computer yet.

    I did keep a backup of the first 10 files in there, obviously no good because there were hundreds of files in there. I cp'd them in anyway. Is it safe to reboot? And most importanty, HOW CAN I RECOVER THESE FILES??

  2. #2
    Just Joined!
    Join Date
    Mar 2008
    Location
    Canada
    Posts
    42
    >Is it safe to reboot?
    If you mean 'safe' as in you won't lose any more files, yup, it's safe. But no, you won't be any better off by rebooting your system (although I would imagine the kernel's still bootable. Your daemons probably won't be happy though).

    >HOW CAN I RECOVER THESE FILES??
    If you don't have a backup of them, they're gone. Toast. Disappeared. While you could probably recover them with disk recovery software, you'd likely end up with an unstable filesystem that would have to be recreated anyway. I see two options for you: a) recreate the files in /usr/lib -- difficult or b) reinstall your operating system -- not (too) difficult.

    If it makes you feel any better, I know a guy who accidentally deleted his entire /etc directory a couple of months ago (regex expression gone wrong :P).

  3. #3
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,319
    I think you are a bit limited as to what you can do. If you do not have a backup, then you probably have to reinstall the OS from scratch.

  4. #4
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    this is a great lesson for not using root.

    I don't like touching root unless I have to and use sudo whenever possible.

  5. #5
    Just Joined!
    Join Date
    Mar 2008
    Location
    Canada
    Posts
    42
    Quote Originally Posted by jledhead View Post
    this is a great lesson for not using root.

    I don't like touching root unless I have to and use sudo whenever possible.
    I don't see how prepending 'sudo' to every command that you want to do as root is going to keep you from making mistakes...

    While it does keep you from accidentally executing commands as root, the issue here I think wasn't that the user didn't realize they were root. It was that they were in the wrong directory when they did rm -fr *, which sudo certainly wouldn't have prevented.

    I think the lesson to be learned here is always use 'rm' with caution.

  6. #6
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,308
    I agree with John A. If you are using sudo then you are gaining root privileges and thats like logging in as root user only.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  7. #7
    Just Joined!
    Join Date
    Mar 2008
    Location
    Canada
    Posts
    42
    Quote Originally Posted by devils casper View Post
    I agree with John A. If you are using sudo then you are gaining root privileges and thats like logging in as root user only.
    Well... sudo proponents argue that it prevents the case of someone logging in as root for some administrative task, then forgetting they're root and doing all sorts of normal user operations under root, making your entire system vulnerable (e.g. viruses). Using sudo means that you're very specifically granting one command root privileges, which prevents viruses from taking over the whole system and the "ohmigosh I forgot I was root" syndromes.

  8. #8
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    I'm not saying make sudo grant you admin access for everything. You can fine tune sudo so when you invoke sudo it will only work for paths or programs that you have explicitly set. Contrary to the default in ubuntu where sudo gives you
    username ALL = (ALL)ALL
    that is no good.

    But if you set certain paths and require them to prompt for a password, then I think you are less likely to remove your whole lib dir for example. Wouldn't you think getting a prompt for password when you do rm -rf * would be a good thing, so you can say hmmm, is that what I meant.

    I have sudo setup on a machine at work where other people need to log in to do certain root functions. I don't want to give them root and I don't want to give them sudo with ALL rights. So I setup a Cmnd_Alias in the sudo file that contains only the programs they need, like vi and tail and being able to execute a certain init script (not all, just one). So this user can log in and run those commands as root but can't do anything else as root, like rm -rf or reboot, things that would be bad.

    I prefer this to running as root or expecting a user to type whoami before each command so they don't do something wrong.

    just my opinion

  9. #9
    Just Joined!
    Join Date
    Mar 2008
    Location
    Canada
    Posts
    42
    Well -- the main reason I prefer using root login is because I tend to do a lot of administrative tasks in one login, so prepending 'sudo' to every command that I want to do quickly becomes quite tedious. But each to his own.

Posting Permissions

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