LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do you remove a non empty directory (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-you-remove-a-non-empty-directory-190142/)

aaronruss 06-05-2004 06:40 PM

How do you remove a non empty directory
 
I would like to know how to remove a non empty directory. I am trying to use the command rmdir but the directory is not empty and it will not delete.

I want to know how to do this from the command line and do not want to have to go and delete all the folders and files in the directory I just want to remove it all at once.

I have checked the man rmdir, info rmdir and the rmdir --help I can not find any thing that explains how to do this.

leonscape 06-05-2004 06:42 PM

rm -r thedirectory

marghorp 06-05-2004 08:23 PM

or rm -rf directory

the -f option is force, which means it will not prompt you for deleting any of the files in the directory. If you delete without force, you will be prompted for every file in that directory. The -r option is recursively, which means that all files in that directory and its subdirectories will be deleted. So be careful with the rm -rf command.

For example:

The command rm -rf / would be equivalent to format c: in windows and even worse. It would be like a windows command format c: and format d: and format e: and format f: ..... all combined. The rm -rf / actually erases everything on your harddisk or your harddisks.

SO BE CAREFUL!!

However this caution is intended only if you run as root or you have messed your permissions. Running rm -rf / as an ordinary user in a healthy system would result in error messages stating that a user has no permission for deleting /

As every other thing you do as root, is to be very careful.

Peace!

Systematic 06-05-2004 08:26 PM

i use rm -rdf this way its recursive, forces and removes the dir completely..


All times are GMT -5. The time now is 12:41 PM.