#Q DIR SHOULD I REMOVE IT HOW TO#
rm -rf NewProject How to delete multiple directories at once? So, In such a case you will have to use rm -rf option. Sometimes you might be asked to confirm the deletion if the Directory or File inside the directory is write-protected. If i run this command the directory named NewProject will get delete along with contents within it. Note : NewProject is a directory name on my computer, In your case, it could be anything.ĭeleting Non-Empty directory in Linux Using rm Command- rm -r NewProject Run this command to delete an empty folder/directory- rm -d NewProject If you want remove an empty directory with rm command then you will have to run rm -d or rm –dir and if you want to delete non-empty folder then you will have to run rm -r command. The rm command is used with some options like -d, –dir and -r. Rm command can delete both empty and non-empty directories.īut without proper knowledge about the rm command, It would be difficult for the users to use it. rm is one of the command line utility which is used to delete file or directory in Linux operating system. So, to remove such directories you need rm command. If you want to remove a Directory in Linux which contains files or any kind of Data rmdir can remove it. How to remove directory/folder using rm command in Linux? rmdir NewProjectĪfter running rmdir command followed by the directory name the directory gets removed but the condition is the directory should be empty. Now, I can easily delete “NewProject” directory just by running rmdir command like this. Now to delete “NewProject” Directory I need to get into Desktop. rmdir for removing directory in Linuxīy default your current open directory in command line would be the home/user. To do so, after opening the command line interface first of all run “pwd” command to know the current path of the command line. To delete “NewProject” I will have to open my Desktop in the command line interface. Here, Notice – The “NewProject” directory is on my Desktop. Use rmdir command followed by the name of the directory which you want to delete or remove.įor Example, there is a “NewProject” Directory in my machine which contains nothing. This the error which occurs when you try to delete directory which is not empty. rmdir: failed to remove 'DirectoryName': Directory not empty They try to delete any folder/directory using this command without knowing that it can not delete a directory that has any type of file. It is super simple to use rmdir command but sometimes it creates confusion for the new users. But once you delete the file or directory from the Trash also then it is not possible to recover the file or folder without using any extra file recovery software. As long as any file or directory is into the Trash, It could be recovered anytime. However, if you are using Gnome’s file or KDE Dolphin then the file you delete gets stored into the Trash. So, be a bit careful before you run the command. When you delete a directory from your Linux machine using the command-line interface, it would be almost impossible to recover it again. Some people visit to our website copy the command and try to delete files or directories without knowing about the complete use of the command. You Must Know It Before Deleting a Directoryīefore you run any Linux command to delete a directory, It is important to know the terms of command. Rm and rmdir are command to delete or remove directory from Linux. So, here we are going so show you how you can delete or remove a directory from a Linux machine using command line interface. Well, no problem you can do anything in Linux using commands. But what if you are working on a headless server where there is no option to use file manger?