When attempting to remove a directory using a command such as the rmdir command, you may receive a prompt such as “rmdir: ‘dir’: Directory not empty” and be unable to delete the directory.
To remove a directory that contains other files or directories, use the following command.
rm -r mydir
In the example above, you would replace “mydir” with the name of the directory you want to delete. For example, if the directory was named “files”, you would type rm -r files at the prompt.
Executing the above command would delete all files and directories within the directory named in the command. However, it would also present a prompt for approval to delete each of the files. If you don’t want to receive a prompt for each file, use the following command instead.
rm -rf mydir
In the above example, the “mydir” directory, along with all files and directories within that directory, would be deleted with no prompt or message.