I am a new user and I am trying to remove a specific folder. I am using sudo rm /path/
, but it is not working. What is the correct command to use?
It is a file catolog I am attempting to remove but I am geting a message that it is empty.
I am a new user and I am trying to remove a specific folder. I am using sudo rm /path/
, but it is not working. What is the correct command to use?
It is a file catolog I am attempting to remove but I am geting a message that it is empty.
Be sure the folder is really empty (hidden files/folders might be in there). Look at the file contents again with
If you're absolutely certain that it doesn't contain anything you want to have (including subdirectories), delete it with
-r
is for recursive, so it will delete the folder and subfolders, even if it is non-empty-f
is for force (this might be unnecessary).One thing to note is that the folder should be empty, then run the following command
Another thing to note is that the command your are typing should not start with a slash(/) not unless the folder is under root.
The last option and you should be very careful while using this one, is to force removal of the directory in question including any other files/directories in it.
Cheers.
For a beginner I would not recommend getting into the habit of using
rm -Rf
orrm -r -f
, this will bite you in the face sooner or later. Safer would be to create a systemwide alias. Open terminal: Ctrl+Alt+T, then type:So you get prompted before wiping out all your vacation photo's by accident. The second recommendation I would like to add is to use
rmdir
, it will complain about non-empty directories and that is exactly what you want as a newbee.But in the sense of the question, the answer is as given here already, use
-f
to erase a folder.If you are sure that the directory exists, then:
To delete the entire directory to your folders and files
If you want to delete all the files in directory and just want to keep the directory or some files use (with the
-i
flag you can keep the file or delete it).-i
is for interactive and will prompt you each and every time there is a file to delete.If you need to delete sub directories along parent directory, use:
If you would like to delete the contents and overwite the data on your drive try using shread. It only removes files so to remove everything in the directory use;
then remove the empty directory