PDA

View Full Version : Unix Cold blooded?

peter_q
April 1st, 2009, 07:02 PM
So I'm in this unix class, which is helping me learn about linux and stuff too... And we went around mkdiring and touching... Making all these cute little files. I got to spend time with em--going around cding and stuff. catting all the outputs...

But then came time to stop using the terminal... Then the horrible command rm -rf came about...

Oh the horror. No "Are you sure" or "Won't you miss them?" prompts... I should have aliased to rm -i...

It just felt so inhumane... A whole directory massacared. And all I see is the cold, hollow user$_ smartboyathome April 1st, 2009, 07:05 PM Just DON'T RUN rm -rf /* as it will kill your system. :( Kareeser April 1st, 2009, 08:02 PM The unix program "rm" does one thing, removing files, and it does it well. That's a core linux philosophy :) So rm assumes you know what the heck you're doing when you add the "f" switch. :) t0p April 1st, 2009, 08:09 PM I agree with the OP. All commands that have the potential to be harmful should be removed from Linux forthwith. Also, only fluffy bunnies should be allowed as screensaver images. Why would anyone want something more vicious than a fluffy bunny on their display? jespdj April 1st, 2009, 08:29 PM Maybe they should replace the "-f" switch with something more elaborate. Like this: rm -r -yes-I-really-want-to-destroy-my-system-please-let-me-do-it * :P Yownanymous April 1st, 2009, 08:39 PM Why would anyone want something more vicious than a fluffy bunny on their display? Might I direct you here (http://ubuntusatanic.org/)? tjwoosta April 1st, 2009, 08:43 PM the #1 rule with unix commands RTFM!! if you would have read the man entry for rm you would have noticed what each of the flags does -r, -R, --recursive remove directories and their contents recursively -f, --force ignore nonexistent files, never prompt mcduck April 1st, 2009, 08:49 PM Maybe they should replace the "-f" switch with something more elaborate. Like this: rm -r -yes-I-really-want-to-destroy-my-system-please-let-me-do-it * :P That would be quite funny :D I kind of miss the good old "glxgears --iacknowledgethatthistoolisnotabenchmark" insane_alien April 1st, 2009, 09:14 PM Just DON'T RUN rm -rf /* as it will kill your system. :( i tried it ages ago. it DOESN'T kill your system... ...until you reboot. although you won't be able to run any program that isn't cached in RAM after this command has done its dirty work. Mehall April 1st, 2009, 09:24 PM i tried it ages ago. it DOESN'T kill your system... ...until you reboot. although you won't be able to run any program that isn't cached in RAM after this command has done its dirty work. Did that to a EEE in John Lewis. That's what they get for not putting a passwd on sudo. lisati April 1st, 2009, 09:32 PM I agree with the OP. All commands that have the potential to be harmful should be removed from Linux forthwith. And while we're at it, we should ban ALL motor vehicles and other things which can kill people. (Just kidding!) Accidents happen: sometimes we just have to swallow our pain and get on with putting the pieces back together again and moving on. And people do dumnb things and try risky commands out of curiosity (which is why the mention of certain commands in these forums is sometimes discouraged) Speaking of motor vehicles, one idea I came across a year or two back was to replace airbags with some kind of device which hurts people, such as enormous metal spikes. This has the potential for motivating people to drive safely. The down side is that I haven't yet come across a way of preventing innocent people getting hurt. billgoldberg April 1st, 2009, 10:50 PM Did that to a EEE in John Lewis. That's what they get for not putting a passwd on sudo. That's not very nice. :p smbm April 1st, 2009, 10:57 PM Did that to a EEE in John Lewis. That's what they get for not putting a passwd on sudo. That's pretty uncool. apmcd47 April 1st, 2009, 11:33 PM So I'm in this unix class, which is helping me learn about linux and stuff too... And we went around mkdiring and touching... Making all these cute little files. I got to spend time with em--going around cding and stuff. catting all the outputs... But then came time to stop using the terminal... Then the horrible command rm -rf came about... Oh the horror. No "Are you sure" or "Won't you miss them?" prompts... I should have aliased to rm -i... It just felt so inhumane... A whole directory massacared. And all I see is the cold, hollow user$_

NO! DON'T DO IT!

$rm *.tmp no0001.tmp? y no0002.tmp? y . . . no2003.tmp? y$
One of the philosophies of the original coders of UNIX was "We are grown-ups. We don't need hand-holding". If you really need that don't do
alias rm='rm -i'do something like
alias rmi='rm -i'instead. If you are used to typing "rmi" and it doesn't exist, fine. If you are used to typing rm and expect it to be an alias, and it isn't, you have a problem.

Actually, I agree that Unix is a harsh mistress. I'm surprised that people in charge of creating distros haven't thought "let's create a few hand-holding commands for the less computer-savvy". Stick 'em into another directory (eg /usr/bin/hh) and the Unix purists can ignore it while the others put it ahead of the other commands.

Andrew

LookTJ
April 1st, 2009, 11:42 PM
I agree with the OP. All commands that have the potential to be harmful should be removed from Linux forthwith.Then I wouldn't have the joy of self-discipline.

jenkinbr
April 2nd, 2009, 12:04 AM
I agree with the OP. All commands that have the potential to be harmful should be removed from Linux forthwith.

I disagree.

Do you realize that many apps use rm, dd, and other potentially dangerous commands as a backend for removing files?

Caution is the key here. Read the man page, and know exactly what it is you type before pushing enter.

schauerlich
April 2nd, 2009, 01:22 AM
NO! DON'T DO IT!

$rm *.tmp no0001.tmp? y no0002.tmp? y . . . no2003.tmp? y$

The solution to that is to pipe yes through it.

$yes | rm *.tmp remove no0001.tmp? remove no0002.tmp? ... remove no2003.tmp?$

yes basically just says "y" over and over until the next command stops.

jenkinbr
April 2nd, 2009, 01:24 AM
The solution to that is to pipe yes through it.

$yes | rm *.tmp remove no0001.tmp? remove no0002.tmp? ... remove no2003.tmp?$

yes basically just says "y" over and over until the next command stops.
That doesn't eliminate the potential for accidents when using an alias, though.

schauerlich
April 2nd, 2009, 01:35 AM
That doesn't eliminate the potential for accidents when using an alias, though.

Well, leave the alias on for normal usage, and then you're sure about something, use the "yes" trick.

apmcd47
April 2nd, 2009, 09:52 AM
The solution to that is to pipe yes through it.

$yes | rm *.tmp remove no0001.tmp? remove no0002.tmp? ... remove no2003.tmp?$

yes basically just says "y" over and over until the next command stops.
An easier workaround is
\$ \rm *.tmpWHEN I remember it (prefixing a command in bash forces it to disregard aliases and functions). But why should I work around somebody else's brain-dead attempt to stop themselves from accidentally deleting something?

rm -i was a lazy attempt to filter out the wheat from the chaff when attempting to delete with a wild-card. What is really needed is the prompt
Are you sure you want to delete this many files? when a certain number is exceeded. Anyone could write a shell-script which could do the job. I'm just surprised that no-one has.

I think I'd better stop now ;)

Andrew

 Just found this in the rm man page:

-I prompt once before removing more than three files, or when
removing recursively. Less intrusive than -i, while still giv‐
ing protection against most mistakes

Eisenwinter
April 2nd, 2009, 10:34 AM
I agree with the OP. All commands that have the potential to be harmful should be removed from Linux forthwith.

Also, only fluffy bunnies should be allowed as screensaver images. Why would anyone want something more vicious than a fluffy bunny on their display?
rm is not harmful. you just need to know what you're deleting.

jenkinbr
April 2nd, 2009, 03:10 PM
rm is not harmful. you just need to know what you're deleting.
On the flip side of this, rm is dangerous when you don't know what it does

!!!WARNING!!!: DO NOT RUN COMMANDS BELOW THIS POINT!!!
On a complete other note, however, my Ubuntu install is *almost* completely replaceable, as there are only a few customizations I've made to things in the /usr, /var, and /etc directories. I would much rather run

sudo rm -rf /usr /etc /var
and have to enter my password, then run

rm -rf ~/*