LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-15-2003, 07:00 PM   #1
AMDPwred
Member
 
Registered: Dec 2001
Location: Richmond, VA
Posts: 391

Rep: Reputation: 30
Deleting directories with files in them


I was trying to delete a directory with files in it but I couldn't unlink them. A quick reference to my Red Hat book confirmed you cannot delete a directory if it has files in it. Is there anyway around this?
 
Old 02-15-2003, 07:01 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
of course you can

rm -rf directory
 
Old 02-16-2003, 12:52 AM   #3
macewan
Senior Member
 
Registered: Jan 2002
Distribution: Ubuntu, Debian
Posts: 1,055
Blog Entries: 1

Rep: Reputation: 45
as an example let's say you have a directory called fred. now this directory is located at /home/AMDPwred/fred and you want to dump it.

rm -rf /home/AMDPwred/fred
 
Old 02-16-2003, 12:57 AM   #4
skidhmor
Member
 
Registered: Feb 2003
Location: Maitland, FL, USA
Distribution: Gentoo
Posts: 38

Rep: Reputation: 15
As warning though, do NOT type rm -rf / as root.
Unless, of course, you WANT to delete your entire linux install, plus any mounted partitions that are writeable(ie- any mounted FAT32 windows partitions)
 
Old 02-16-2003, 01:01 AM   #5
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
Quote:
Originally posted by macewan
rm -rf /home/AMDPwred/fred
maybe the -f option is a little too much. when one uses the -r option, there should not be too many problems - but if there are, wouldn't you want to know about them?
 
Old 02-16-2003, 01:20 AM   #6
crichards
Member
 
Registered: Feb 2003
Location: Arizona
Distribution: Gentoo!
Posts: 124

Rep: Reputation: 15
When I was experimenting with User Mode Linux, I did an rm -rf /.

It is devastating to your system. BE VERY CAREFUL WITH rm -rf! Double check what you are typing!!!
 
Old 02-16-2003, 09:02 AM   #7
emetib
Member
 
Registered: Feb 2003
Posts: 482

Rep: Reputation: 33
to remove a directory-

rm -dR /filename.

to remove only the contents

rm /filename/*

when you are in your /home dir remenber not to put the / before your dir. if there is a /test and a /home/user/test you will end up removing the one that isn't in your /home/user

good luck
 
Old 02-16-2003, 12:06 PM   #8
macewan
Senior Member
 
Registered: Jan 2002
Distribution: Ubuntu, Debian
Posts: 1,055
Blog Entries: 1

Rep: Reputation: 45
naturally you need to be careful and think before you perform these functions.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
trouble deleting files / directories neocontrol Linux - Software 1 07-16-2005 04:09 PM
Deleting directories NomadABC Linux - Newbie 2 02-10-2005 02:11 PM
rm command - deleting directories Micro420 Linux - Newbie 11 11-02-2003 02:18 PM
Deleting Directories J_Bone Linux - Newbie 4 08-17-2003 04:19 PM
deleting directories AZDAVE Linux - Newbie 1 08-15-2003 10:05 AM


All times are GMT -5. The time now is 07:03 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration