|
|
I accidentally removed rm
|
|
|
|
Mac Elite
Join Date: Jan 2001
Location: Somewhere in the land surrouding Fenway Park
Status:
Offline
|
|
This is kind of embarrasing seeing as I have quite a few years of UNIX expierence but I guess we all make mistakes...
Today I was removing X11 from my system and I accidentally typed "sudo rm sudo rm ..." which then removed the rm command from my system.
I'm a developer and the version of OSX that I'm running right now is a little more current than what you guys are running, so I don't think re-installing the BSD subsystem using Pacifist is an option.
I'm not totally sure but isn't rm just a binary program like any other? If so I'd really appreciate it if someone could email it to me at [email protected]. Any other suggestions?
Thanks.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Mar 2001
Status:
Offline
|
|
This shouldn't have rermoved rm from your system...unless you were in the /bin directory at the time, where rm resides...if that was the case, yes, it can come from any other OS X system.
Or, you can just take it from your OS X install disc. It's at
/bin/rm
on the disc as well. Make sure you set its permissions, etc., correctly again:
-r-xr-xr-x 1 root wheel
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2001
Location: Somewhere in the land surrouding Fenway Park
Status:
Offline
|
|
In fact I was in the /bin directory at the time because thats where X11 is.
Thanks for the tip it worked great.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
Glad your problem is fixed - That means I can admit that I found it funny in a perverse sort of way - You know rm-ing rm.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Originally posted by Diggory Laycock:
Glad your problem is fixed - That means I can admit that I found it funny in a perverse sort of way - You know rm-ing rm.
I'm kind of surprised that you can use a command to delete itself. Shouldn't it return an "in use" error?
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Dec 2001
Location: England, UK
Status:
Offline
|
|
Won't that have also removed the 'sudo' binary?
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: Dec 2000
Status:
Offline
|
|
Originally posted by wataru:
I'm kind of surprised that you can use a command to delete itself. Shouldn't it return an "in use" error?
Ha, rm doesn't care about such petty distinctions as whether a file is in use or not. Its job is to delete, and dammit, it doesn't ask stupid questions, it deletes. That's why it's such a dangerous tool and should be used very sparingly and carefully.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: May 2000
Location: Urbandale, IA
Status:
Offline
|
|
Well, actually, the reason you were able to rm 'rm' is because Unix programs use the 'unlink()' system call to delete files, which simpy removes the directory entry's pointer to the inode of a given file. Then, as soon as the file is no longer in use, the OS's garbage-collection mechanism notices that there's a file with no names pointing to it and deletes the file. So any program can unlink any file, and the file itself will continue to exist until the OS notices that no one's using it anymore.
Wilfredo Sanchez presented his excellent paper on the challenges of integrating the Unix and Mac OS environments to the 2000 USENIX conference. His paper talks about the differing semantics of Mac and Unix deletes (among other things).
It's a great read! I actually just did a presentation on that paper myself for my Operating Systems class on Tuesday.
|
"Yields a falsehood when preceded by its quotation" yields a falsehood when preceded by its quotation.
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
Originally posted by GFive:
Won't that have also removed the 'sudo' binary?
No, because sudo is in /usr/bin and he was in /bin.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Dec 2001
Location: England, UK
Status:
Offline
|
|
Makes sense. I should have checked before I posted that
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Aug 2001
Location: Capitol City
Status:
Offline
|
|
One time I was trying to extract a tarball backup that I had, but sent tar the wrong parameter (-c instead of -x, duh) and it overwrote the file with an empty one (at least I think that's what happened, it was really late, and all of the sudden my tarball was gone, and the only command I found that might have done it was that) For future reference, not that I think I'll make that particular mistake again, is there a way to recover something like that?
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Mar 2001
Status:
Offline
|
|
That's one mistake you can't make twice...
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: May 2000
Location: Urbandale, IA
Status:
Offline
|
|
Originally posted by DaveGee:
That's one mistake you can't make twice...
Oooooo.... </me throws rotten fruit in DaveGee's general direction>
|
"Yields a falsehood when preceded by its quotation" yields a falsehood when preceded by its quotation.
|
|
|
|
|
|
|
|
Junior Member
Join Date: Feb 2002
Status:
Offline
|
|
Originally posted by CharlesS:
Ha, rm doesn't care about such petty distinctions as whether a file is in use or not. Its job is to delete, and dammit, it doesn't ask stupid questions, it deletes. That's why it's such a dangerous tool and should be used very sparingly and carefully.
I do most of my work at the command line, so what do you expect me to do? I use rm whenever I have the need to remove a file. Of course you should be careful with it, but it's not so dangerous that you should only use it when you have no other option.
rm'ing in super-user mode is another matter, of course.
|
self = [[JeffBinder alloc] init];
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
Originally posted by Jeff Binder:
rm'ing in super-user mode is another matter, of course.
Actually, I find that I care least about the things I can screw up as the superuser.
If I trash my /System folder -- so what? Reinstall the OS, and all is well.
On the other hand, if I'm sitting in my home directory and accidentally rm * -- aack! There goes whatever I've worked on today*, which means much more to me than some pile of Apple programs.
*today only, since like a Good Boy I have set psync to back up my Documents folder every morning, and a crontab task that saves an archived copy of the backup every month
|
|
|
|
|
|
|
|
|
Banned
Join Date: Sep 2000
Location: Fightclub
Status:
Offline
|
|
Bah, all this would be no problem if you could do this:
Code:
#rm /bin/rm
#undo
#ls rm
rm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|