How do I delete the following directory?

I typed:

rmdir lampp

This error comes up:

rmdir: failed to remove `lampp': Directory not empty

Is there a command to delete all the files in the directory and delete the directory folder?

  • 1
    I'm unable to remove a directory like "New Folder" using all the above detailed commands. It's double worded. But I want to remove that directory. Any suggestions will be welcomed. T.Divakara, Bengaluru, India
    – user307933
    Jul 22, 2014 at 7:33
  • Its the blank space in the file name, try using 'quotes' > rmdir 'New Folder' < then the folder disapers, or use escape characters for non-vissible characters. Feb 5, 2015 at 13:25
  • 5
    Just doing rm -r lampp will do. Jul 1, 2016 at 19:39

4 Answers 4


Use the below command :

rm -rf lampp

It deletes all files and folders contained in the lampp directory.

In case user doesn't have the permission to delete the folder:

Add sudo at the beginning of the command :

sudo rm -rf folderName

Otherwise, without sudo you will be returned permission denied. And it's a good practice to try not to use -f while deleting a directory:

sudo rm -r folderName

Note: this is assuming you are already on the same level of the folder you want to delete in terminal, if not:

sudo rm -r /path/to/folderName

FYI: you can use letters -f, -r, -v:

  • -f = to ignore non-existent files, never prompt
  • -r = to remove directories and their contents recursively
  • -v = to explain what is being done
  • 73
    In my humble opinion, it's a good practice never to add the "f" on first attempt. Its purpose is to ignore certain warning prompts that may be important, especially if you've accidentally done it on/from the wrong directory. In my opinion it's good to try without the "f" first, then only if you are encountering a lot of warning prompts and you're sure it's OK to ignore them all, Ctrl+C out of it and repeat the command with the "f". Aug 27, 2013 at 2:52
  • 1
    @BKSpurgeon not unless you accidentally type --no-preserve-root too.
    – muru
    Oct 2, 2015 at 7:22
  • @thomasrutter ... Agree. A file "xxx" owner: root and group: root can BE deleted with the -f switch; and without sudo. This is the message without -f: "rm: remove write-protected regular file ‘/home/william/.cache/netbeans/v08.01/tmp/xxx’? _". _Tread gently.
    – will
    Dec 2, 2015 at 14:06
rm -R lampp

However, you need to be careful with a recursive command like this, as it's easy to accidentally delete a lot more than you intended.

It is a good idea to always double-check which directory you're in, and whether you typed the command correctly, before pressing Enter.

Safer version

rm -R -i lampp

Adding -i makes it a little safer, because it will prompt you on every deletion. However, if you are deleting many files this is not going to be very practical. Still, you can try this first.

Note about -f option:

Many people suggest using -f (combining it into -Rf or -rf), claiming that it gets rid of annoying prompts. However, in normal cases you don't need it, and using it suppresses some problems that you probably do want to know about. When you use it, you won't be warned if your arguments supply a non-existing directory or file(s): rm will just silently fail to delete anything. As a general rule, try first without the -f: if there are problems with your arguments, then you'll notice. If you start getting too many prompts about files without write access, then you can try it with -f. Alternatively, run the command from a user (or the superuser using sudo) that has full permissions to the files and directories you're deleting to prevent these prompts in the first place.

  • 6
    Note: lowercase -r can be used too and has the same effect here. I only tend to use uppercase -R because it's consistent with other commands I use such as grep and chmod, some of which only support the uppercase form. Sep 20, 2013 at 4:04
  • This one worked for me using adb (android debug bridge) on Android. Was trying rm -rf but it didn't work. Had to use rm -R. Thanks.
    – raddevus
    Mar 13, 2016 at 2:15
  • 1
    This is a good solution, especially if inexperienced with using the Bash terminal. The command can be shortened to rm -ir FOLDER.
    – AlainD
    Aug 30, 2019 at 9:50

There are lots of ways to delete a directory through CLI mode. It depends on which way you are comfortable with.

rm -rvf /path/to/directory  
  • -r = remove directories and their contents recursively
  • -v = explain what is being done
  • -f = ignore nonexistent files, never prompt

If you are new in Linux, use the man pages of commands (man rm) for more option and more accuracy.


I was having some trouble with that today, but I overcame it with sudo.

Caveat: Be very certain you want to delete the entire thing before using the command below.

$ sudo rm -R [Directory name]

I successfully did this today, and removed many non-empty directories that I confirmed I didn't want/need.

I'm using 14.04 LTS

  • 4
    "SUDO" is not a command - "sudo" is. Nevertheless, you do not use sudo to delete a non-empty directory, you use it to delete a file that is not owned by you. Doing this as a matter of course is dangerous and not very smart, as you should not be blindly deleting files you do not own. Sep 28, 2014 at 23:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .