HowTo Delete Directory in CentOS UNIX?
What is the command that i need to use, if i want to delete file or dir's?:)
I'm using Cent OS 3.5 inUNIX The Red Hat Enterprise Server |
You should be able to use standard Linux commands: rm and rmdir.
To delete a file: rm filename To delete a directory: rmdir directory (directory must be empty though) See the man pages for rm and rmdir for more info. |
Code:
[root@masterServer root]# rmdir httpd-2.0.48 |
Use:
# rm -rf httpd-2.0.48/* # rmdir httpd-2.0.48 |
Code:
[root@masterServer root]# rm -rf httpd-2.0.48/* |
use
# rm -rf httpd-2.0.48 |
Hi hfawzy, thanks dude! This command workz!!! :D :D :D
Command for deleteing non-emty's directory's Code:
rm -rf "dir name" |
Just be careful with that command, as one little slip can destroy everything if you're doing it as root. The options given to rm tell it to delete all files and directories within directories recursively and force deletion even when you'd normally get a warning. If you type the wrong thing to delete, your system can easily be gone.
|
Thanks this kinda helped me out today.. i didn't know it varied across distros
|
It doesn't vary across distros, it's just a matter of whether you're directly deleting the directory with everything in it or deleting its contents before deleting the directory.
|
but generally rm -r dirname would get rid of a dir and all its files. thats what i do in ubuntu anyway. however I was helping a friend of mine with a centos server today and i had to use this method
|
yes, it works in CentOS 6.2 today...rookie here...
|
Note that -r = recursive and -f = force(!), which may be required, depending on the file ownerships/perms at the time.
As warned above, a relatively simple typo can remove more than you want or even the entire system.... It has really been happened to people. Try not to use root when doing that, it should only be required if the files are owned by root. |
re: OP
For future inquiries:
Code:
rm -r -f dir_path |
All times are GMT -5. The time now is 09:19 AM. |