4

I'm trying to remove a directory labeled 'phoneBackup' but it's not empty, it contains several dozen image files (.jpg, .gif, etc). I'm running the command "rmdir -r phoneBackup" from the parent directory, but upon execution I get the following error:

rmdir: invalid option -- 'r' Try `rmdir --help' for more information.

Both the 'rmdir --help' and the 'man rmdir' commands don't show -r as an option. Is there a package I need to install, or is there some other way of removing the directory I can use in place of rmdir? I'm running Elementary OS Luna, which is built off of Ubuntu 12.04.

Vincent Campbell
  • 180
  • 1
  • 2
  • 12

2 Answers2

5

rmdir work on empty directories. to remove directory and files/directories inside use

rm -rf /path/to/directory
Romeo Ninov
  • 5,319
  • 5
  • 20
  • 20
  • 1
    Be extremely careful with this command, issuing a `rm -rf /` will wipe out the entire linux installation – jcbermu Apr 06 '15 at 14:13
  • That worked! thanks. But why does rm -rf work, but rm -r doesn't? Also, what do both the r and f stand for? Last question, why aren't they showing in the man pages? – Vincent Campbell Apr 06 '15 at 14:13
  • r come for recursively, f come from force. and its good to use them together to remove also open files (from other applications) – Romeo Ninov Apr 06 '15 at 14:15
  • Alright, but why is r an invalid option when stand-alone, but it executes just fine paired with f? I didn't have any applications causing any of the files to be opened. – Vincent Campbell Apr 06 '15 at 14:18
  • As far as i understand -r give you an error when use with rmdir. When use with rm its another story. As I remember correctly Ubuntu make some changes in rm to avoid "suicide" rm -rf / so you can set to prompt you per file/directory or set explicitly force (do not ask questions, just do it) – Romeo Ninov Apr 06 '15 at 14:24
  • -r is recursive as previously mentioned, however recursive only works if the directory is empty. It has nothing to do with 'Open files' as mentioned by @RomeoNinov. -f tells it to remove, even if the directory isn't empty. rmdir doesn't have a -r option, so that is invaid. – djsmiley2kStaysInside May 26 '17 at 08:29
-3

another way to delete directory and its subdirectory/file is using WinSCP, instead of using rm -rf / which probably wipe out the entire linux installation.