removing content of directory

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
Locked
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

removing content of directory

Post by Red Squirrel »

How can I delete the entire content of a directory with a single command? I want the equivalent of del foldername*.* I started rm'ing the files individualy but it's just too long. For some reason a bunch of mail got stuck in the mail queue and it keeps bouncing all over the server and not going anywhere and it's muliplying each time. It's at like 300+ now so I just want to delete them. webmin only allows me to delete 20 at once which is stupid, so that takes long too.

Archived topic from Anythingforums, old topic ID:614, old post ID:5382
Honk if you love Jesus, text if you want to meet Him!
wldkos
Posts: 830
Joined: Mon Feb 24, 2003 12:19 pm

removing content of directory

Post by wldkos »

rm -rf *

make sure your in the directory that you want this to happen. You can use rm -rf /home/red/ohnooos!

but i've have bad mistakes with that deleting things that can't come back. The "rm" tool doesn't have a recycle bin ;)

Archived topic from Anythingforums, old topic ID:614, old post ID:5405
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

removing content of directory

Post by megaspaz »

The "rm" tool doesn't have a recycle bin
neither does using del or deltree in windows.

Archived topic from Anythingforums, old topic ID:614, old post ID:5408
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
Cisco_Kid
Posts: 497
Joined: Thu Jun 24, 2004 11:12 pm

removing content of directory

Post by Cisco_Kid »

megaspaz wrote:
The "rm" tool doesn't have a recycle bin
neither does using del or deltree in windows.
I would think not as the recycle bin was not stolen from the Mac system GUI until win95 when windows finally just started to catch up on the visual side.


Archived topic from Anythingforums, old topic ID:614, old post ID:5409
Started talking to yourself I see.
Yes, it was the only way I could be sure of an intelligent conversation

Blackadder
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

removing content of directory

Post by Red Squirrel »

Thanks rm -f * worked

Well deleted stuff is recoverable, just not an easy task to do and you need a special program, which starts at a few grand and is hard to get at discount stores such as K-mart (Kazaa mart)



Archived topic from Anythingforums, old topic ID:614, old post ID:5420
Honk if you love Jesus, text if you want to meet Him!
wldkos
Posts: 830
Joined: Mon Feb 24, 2003 12:19 pm

removing content of directory

Post by wldkos »

rm -rf -- using the 'r' means recursive, and the 'f' means force, so it won't ask you if you want to delete the files.

Archived topic from Anythingforums, old topic ID:614, old post ID:5477
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

removing content of directory

Post by Red Squirrel »

Yeah I knew that. That's why I never type rm -rf / :D

Archived topic from Anythingforums, old topic ID:614, old post ID:5487
Honk if you love Jesus, text if you want to meet Him!
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

removing content of directory

Post by megaspaz »

rm -rf / can be pretty totally safe... if invoked as a regular user. the only things that i know of off a default install that would get deleted would be files and directories owned by the user in /tmp.

*disclaimer, try it at your own risk. :P

Archived topic from Anythingforums, old topic ID:614, old post ID:5662
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

removing content of directory

Post by Red Squirrel »

unless you do a recursive chmod 777 on the / before. :o

Archived topic from Anythingforums, old topic ID:614, old post ID:5813
Honk if you love Jesus, text if you want to meet Him!
megaspaz
Posts: 340
Joined: Wed Dec 18, 2002 10:08 pm

removing content of directory

Post by megaspaz »

Red Squirrel wrote: unless you do a recursive chmod 777 on the / before. :o
well then i guess you'd better stay away from chmod and rm. :P

Archived topic from Anythingforums, old topic ID:614, old post ID:5845
Image
Resistance is futile...

Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums

"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

removing content of directory

Post by Red Squirrel »

Yep. But it would be near impossible to do both by accident though so that's reassuring. :D

So.... is the fact that I do everything under root bad? Since most things have it documented that it only works under root, so I never bothered making another account. So if I do rm -rf / will it delete everything? :o (including any mapped drives etc...)


Archived topic from Anythingforums, old topic ID:614, old post ID:5865
Honk if you love Jesus, text if you want to meet Him!
closet geek
Posts: 35
Joined: Thu Dec 18, 2003 8:40 am

removing content of directory

Post by closet geek »

Red Squirrel wrote: So.... is the fact that I do everything under root bad?  Since most things have it documented that it only works under root, so I never bothered making another account.  So if I do rm -rf / will it delete everything?  :o  (including any mapped drives etc...)
:huh:

By doing so you are bypassing one of the nicest security features of the linux kernel. It's your choice, but get into the bad habit now and you'll end up regretting it.

Andrew

Archived topic from Anythingforums, old topic ID:614, old post ID:9318
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

removing content of directory

Post by Red Squirrel »

But what's the other alternative?

Whenever I read something it says that it only works under root. Obviously I have my server programs running as their own user (ex: apache runs under "apache") but for installing stuff and all that, I go under root.

Archived topic from Anythingforums, old topic ID:614, old post ID:9534
Honk if you love Jesus, text if you want to meet Him!
Locked