LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-02-2004, 12:25 PM   #1
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Rep: Reputation: 47
Watch those commands...


Even the most advanced and long-time linux users are not immune to the evil vile typeo or mistyped command.

I was having an issue witht he naming of the kernel after a recompile and was not sure which /lib/modules/* directory was active, my solution which I have done many times was to delete all the /lib/modules/* directories and re-compile-install the kernel modules.

rm /lib/modules/* -rf

however in my haste and overconfidence I failed to notice my command was this:

rm /lib/* -rf

the outcome is obvious....

Well as I use gentoo (stage 1) and just finished compiling the system yesterday (after 3 days streight of compiling without supervision everything I could need) I have no packages or backups to restore... off to start another 3 day long compile.

WATCH THOSE COMMANDS!!!!!

Last edited by exodist; 11-02-2004 at 12:28 PM.
 
Old 11-02-2004, 01:12 PM   #2
QtCoder
Member
 
Registered: Aug 2003
Location: USA
Distribution: Slackware 12.0 RC1
Posts: 129

Rep: Reputation: 15
Yep, I know what you mean.

I did something similar where I accidentally typed the wrong extension in an rm -rf command. Of course, it had to happen in a critical system directory. So, what I always do before I ever do a forced recursive remove is double check my command. It certainly saves some headaches. Luckily this happened on my home comp, and not my server. :-)
 
Old 11-02-2004, 01:22 PM   #3
m00t00
Member
 
Registered: Sep 2004
Distribution: Slackware 10, Gentoo
Posts: 292

Rep: Reputation: 30
ah... me too. I had just finished my shiney new gentoo stage 1 install, and I went into /etc to delete all the *~ backup files. So I typed rm *~, not noticing that my '~' was in a different place than I was used to, and the key I pressed did nothing. So the command was 'rm *' . There went my /etc....
 
Old 11-02-2004, 01:53 PM   #4
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
hmmm.

I think I will write a perl script that I will alias to rm that will run the rm command as typed, however if it is an obvious bad combo like rm in /lib or /etc, and so on it will call the user an idiot and not do it.......

I will keep this forum posted...
 
Old 11-02-2004, 01:57 PM   #5
m00t00
Member
 
Registered: Sep 2004
Distribution: Slackware 10, Gentoo
Posts: 292

Rep: Reputation: 30
hmmz. Good idea. except.... skip all the checking, just call the user an idiot and not do it =]
 
Old 11-02-2004, 02:17 PM   #6
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
lol, that would work if I didn't consider myself one of the users. damn, biggest mistake in the 5 years I have been on linux.. oh I take that back, purchasing redhat9.1 when I found myself without a slackware cd or internet access for a week... I was better off without the computer and the $$$ in my pocket. (Vacation)
 
Old 11-02-2004, 04:09 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
How about
touch -- /home/-i
touch -- /usr/-i
touch -- /lib/-i
touch -- /-i

? ;)
 
Old 11-02-2004, 04:22 PM   #8
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
care to explain what that does?
 
Old 11-02-2004, 04:34 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
It creates a 0-byte length file by the name of
-i in the directories in question ...

If you run an rm in those it's being interpreted
as a -i switch to rm, thus asking you (only in
those specially protected directories) whether
you're SURE you want to do that.


Cheers,
Tink
 
Old 11-02-2004, 04:36 PM   #10
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
you are a saint. thanx
 
Old 11-02-2004, 04:42 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
/me goes down on his knees and says a Lords prayer, and asks for protection of all those Linux boxen out there ...

:)

I really like that technique because it saves you
from RedHats (for example) stupid alias and being
asked on EVERY deletion ... :)


Cheers,
Tink
 
Old 11-02-2004, 04:55 PM   #12
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
lol yeah, usually I have an alias making -f a given, so it never prompts me.. this dounside is obvious, though in 5 years it is the first time I screwed up on an rm command (though I have screwed up many other ways)
 
Old 11-04-2004, 05:15 PM   #13
m00t00
Member
 
Registered: Sep 2004
Distribution: Slackware 10, Gentoo
Posts: 292

Rep: Reputation: 30
if -i is specified after -f, or vice versa, the last one will take affect.
 
Old 11-04-2004, 08:12 PM   #14
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Which, when you use wildcards, and don't prepend the
files to your switches (quite uncommon) is going to be
the -i ;)

I don't know many people who go
rm * -rf

In fact, I don't know any. But I expect a few
to pop-up now ;}


Cheers,
Tink
 
Old 11-05-2004, 06:36 PM   #15
m00t00
Member
 
Registered: Sep 2004
Distribution: Slackware 10, Gentoo
Posts: 292

Rep: Reputation: 30
/me pulls out a .22

All ye who use rm * -rf step forward.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Watch vs BSD Watch blueCow *BSD 4 08-16-2009 05:35 PM
Watch Commands Execute in GUI within background lennysokol Linux - General 1 05-16-2005 02:53 PM
freevo. How do I watch tv? glore Linux - Software 2 07-20-2004 10:21 AM
Cantīt watch 3D java hotpepsi Linux - Newbie 0 06-17-2004 03:44 AM
Watch em squirm! Bert Linux - General 1 08-20-2002 09:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration