The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   How to keep Unix from ERASING you entire hard drive?? (http://hintsforums.macworld.com/showthread.php?t=5594)

vonleigh 09-20-2002 10:54 AM

MT,

My methodology wasn't quite right while testing, upon further tests it does work as described (I was deleting whole dirs that contained the switch); d'oh.


Vonleigh

mervTormel 09-20-2002 11:17 AM

it's generally considered bad form to alias a true command, i.e., mask it's canonical name.

with rm, doubly so, because one gets false-confidence, and when one is su'd or sudo'd to another account, or remote'd to another machine, and has the bad habit instilled in their mind that they're safe and protected, this will bite. you'll usually hear a loud "Oh ****!" followed by denial, weeping, anger, fear, flop-sweat, chagrin, the whole gamut.

another trick and good habit. never use a naked rm without seeing its results first.

you can do this by proceeding rm with echo...
Code:

$ ls
-i  d8fs  d8fs1  d8fs2  d8fs3  d8fs4

$ echo rm * # or any shell glob term

rm -i d8fs d8fs1 d8fs2 d8fs3 d8fs4

this will let you "sanity check" your results. when your satisfied, up-arrow, control-a, conrtol-d-d-d-d, return

you can use this trick most anywhere as it merely expands the glob term and spits it to stdout.

dewme5 09-20-2002 12:02 PM

just a little comment on the sudo thing.. you don't have to know the sudo password, if it's already been entered into that terminal window. if your friend somehow got you to enter your password while helping you do someother stuff, and then ran that script later.. you left yourself wide open.

mervTormel 09-20-2002 12:11 PM

for 5 minutes...
 
% man sudo
...

"Once a user has been authenticated, a timestamp is updated and the user may then use sudo without a password for a short period of time (5 minutes unless overridden in sudoers)..."


% sudo -k # expire sudo timeout now (kill)

% sudo -v # renew sudo timeout for another N minutes (validate)

gowmc 09-20-2002 12:23 PM

Heads up!
 
Just as a warning about using the magical "touch ./\-i" trick, it does NOT work if you have a file in the directory whose name begins with a space. In fact, I imagine that it wont work if you have ANY file with a character that is sorted in "before" the "-". When this is the case, "rm -rf *" merely deletes everything, including the "-i" file.

Sorry if this isnt formatted nicely enough for you, but its my first reply.

mervTormel 09-20-2002 01:13 PM

thanks, gowmc. yep. there are quite a few chars that collate before '-' in the roman ascii context...
Code:

    040 sp  041  !  042  "  043  #  044  $  045  %  046  &  047  '
    050  (  051  )  052  *  053  +  054  ,  055  -  056  .  057  /

space, bang, quote, pound (octothorpe), dollar, percent, amp, tick, parens, splat, plus, and comma

some of these chars should not be used in filenames at all. e.g., if you use an odd number of ticks in a filename, you're going to have a lot of trouble getting that sucker thru filters. and none of them should be characters that you start your filenames with!

if you want filenames to collate before alpha names, use a number scheme.

hayne 09-20-2002 04:14 PM

make the -i file start with spaces
 
I haven't tried this - but it seems to me that you could ensure that the -i file trick described above will always work if you create the file with a bunch of spaces before the -i in its name.


All times are GMT -5. The time now is 06:12 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.