How to remove directories?
I am new to linux and have the following questions on how to delete directories. I copied a file that contains multiple directories from a floppy to a directory under /root . Now I am trying to delete the entire file. What command should I use? I don't think I have to empty each subdirectories and then delete every of them one by one with 'rmdir', but I don't know any other way to do it.
Some times even all the files in a directory apparently have been deleted ('ls -l' gives 0 file), when trying to remove the directory itself with 'rmdir', I still get the message " directory is not empty", thereby the directory can't be deleted. Why does this happen, how to deal with it?
I appreciate greatly if anyone could answer above questions.
First, it is usually a good idea to create a regular user account and work with that regular user account on a day-to-day basis. This will prevent you from doing something that you will SERIOUSLY regret :)
Next, if you want to recursively delete a directory structure, type rm -rf <directory> .
BEFORE YOU DO THIS, type pwd and ls to make sure that (a) you are in the directory you want to be in and (b) that the directory that you are wanting to delete is there. The reason for this is that rm -rf executed as root WILL ERASE IMPORTANT FILES IF YOU ARE NOT CAREFUL. (i.e., if executed from the / directory, will delete all files on linux system).
If the directory listing done under a regular 'ls -l' shows no files, try doing an ls -ld .* (shows all the dot files under that structure w/o listing the directory above you) .
Check out the UNIX command reference on TechRepublic - I'm not sure what the link is, but it lists several frequently-used commands for UNIX and LINUX.
|All times are GMT -5. The time now is 07:34 PM.|