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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-15-2003, 08:00 PM
|
#1
|
Member
Registered: Dec 2001
Location: Richmond, VA
Posts: 391
Rep:
|
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?
|
|
|
02-15-2003, 08:01 PM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
of course you can
rm -rf directory
|
|
|
02-16-2003, 01:52 AM
|
#3
|
Senior Member
Registered: Jan 2002
Distribution: Ubuntu, Debian
Posts: 1,055
Rep:
|
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
|
|
|
02-16-2003, 01:57 AM
|
#4
|
Member
Registered: Feb 2003
Location: Maitland, FL, USA
Distribution: Gentoo
Posts: 38
Rep:
|
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)
|
|
|
02-16-2003, 02:01 AM
|
#5
|
Member
Registered: Feb 2003
Distribution: Debian
Posts: 797
Rep:
|
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?
|
|
|
02-16-2003, 02:20 AM
|
#6
|
Member
Registered: Feb 2003
Location: Arizona
Distribution: Gentoo!
Posts: 124
Rep:
|
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!!!
|
|
|
02-16-2003, 10:02 AM
|
#7
|
Member
Registered: Feb 2003
Posts: 484
Rep:
|
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
|
|
|
02-16-2003, 01:06 PM
|
#8
|
Senior Member
Registered: Jan 2002
Distribution: Ubuntu, Debian
Posts: 1,055
Rep:
|
naturally you need to be careful and think before you perform these functions.
|
|
|
All times are GMT -5. The time now is 05:51 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|