Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-24-2005, 01:01 AM   #1
LQ Newbie
Registered: Jun 2005
Location: Agoura Hills, CA
Distribution: FC3
Posts: 17

Rep: Reputation: 0
deleting directory w/o descending

how do i delete a directory without descending and having to delete every content inside. i tried doing 'prompt' and 'rm -r' but to no avail.

Old 08-24-2005, 01:22 AM   #2
Registered: Dec 2003
Location: Next to Equator
Distribution: GNU/Linux 2.6.14
Posts: 382

Rep: Reputation: 30
you can add a f to rm -r becoming rm -rf
Old 08-24-2005, 01:33 AM   #3
Registered: Jul 2003
Location: Santiago, Chile
Distribution: Gentoo
Posts: 282

Rep: Reputation: 30
It is weird that rm -r does not just work, as newinlinux said try with rm -rf
Old 08-24-2005, 02:35 AM   #4
Senior Member
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
Make SURE you type that in right, especially if you are root. It does not ask questions about what you are doing.

I had moved my Gentoo to a new hard drive and I booted the old drive and typed in rm -rf /* just to see what it would do. It ran until it deleted something that it needed then errored out. About 90% of the files were gone, I think it was something in /usr/sbin. Trust me, it will delete what you tell it, even if you tell it wrong.


Old 08-24-2005, 08:46 AM   #5
Registered: Oct 2004
Location: Germany
Distribution: Debian
Posts: 274

Rep: Reputation: 34
some distros do an alias rm="rm -i" as default, for new users coming from windows...

normally these are in /etc/tcshrc.alias or /etc/profile or /etc/bashrc or whatever shell is in use...
Old 08-24-2005, 09:39 AM   #6
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,274
Blog Entries: 10

Rep: Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847
rm -r alone doesn't work because by default rm doesn't remove directories - only their contents and tells you it can't remove a directory because it is a directory. The -f flag says to disregard all warning conditions and force the remove.

As pointed out by others it is useful for removing an entire directory tree but can be very dangerous if you don't use it correctly.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a Directory using c++ in Linux ArulPrabhuT Programming 11 08-20-2011 12:10 PM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 07:05 AM
deleting old /usr directory after a move... jimieee Linux - General 2 12-26-2003 06:15 PM
Deleting a directory... closet geek Linux - General 7 07-09-2003 07:25 AM
deleting non-empty directory sadiboyz Linux - Newbie 2 04-21-2003 10:29 PM

All times are GMT -5. The time now is 04:35 PM.

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