LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Removing a Directory from the Terminal without deleting each file or folder (http://www.linuxquestions.org/questions/linux-general-1/removing-a-directory-from-the-terminal-without-deleting-each-file-or-folder-328697/)

lennysokol 05-30-2005 09:11 PM

Removing a Directory from the Terminal without deleting each file or folder
 
How can I delete a folder without deleting each file or folder via terminal?

So let's say I would want to delete the folder

/home/username/test

which has 230 files...

How can I delete the folder from the terminal?

I do not want to be prompted to delete each file or folder, yet, delete the complete folder.

Thanks

bigrigdriver 05-30-2005 09:34 PM

Su to root, then give this command:

rmdir --ignore-fail-on-non-empty <dirname>

where <dirname> is the name of the directory to remove.

Or, you could try: rm -dR <dirname> (-d works only for the root user).

-d remove the directory even if it isn't empty (root user only)
-R recursive drill down through the directory.

Tinkster 05-30-2005 09:37 PM

Or (slightly shorter)
rm -rf /home/username/test


Cheers,
Tink

lennysokol 05-30-2005 10:47 PM

Thank You. You were all very helpful.

Next time, I'll have to do a man on rmdir. I did not see anything on that, though.

:study: :study:

Thanks, once again. :D :D :) :) :)

__J 05-30-2005 11:30 PM

Quote:

Originally posted by Tinkster
Or (slightly shorter)
rm -rf /home/username/test


Cheers,
Tink

just adding a little to this, be careful when you are root with rm, for example:

rm -fr / home/username/test

notice the accidental space between / and home (which the shell will interpret as "remove the root directory ( / )), if you accidentally do this, say goodbye to your entire filesystem.


All times are GMT -5. The time now is 05:16 PM.