# How to delete a Linux directory

If you want to delete all files in a folder, it’s **more practical to simply delete the entire directory**. This saves you a lot of time, as you don’t need to select every individual file. This also lets you remove all subdirectories in the folder. [Linux](https://www.ionos.com/digitalguide/server/know-how/linux-the-cost-effective-alternative-to-windows/) gives you many different solutions to quickly and easily remove a Linux directory.

## Delete a Linux directory: file manager

The simplest way to delete a Linux directory is by using the file manager.

1. In the file manager, go to the directory that you want to remove.
2. Right-click on the directory and then click **“Move to trash”** in the menu that opens.

---

### Fact

There are many different Linux distributions with different graphical interfaces, but they generally have a similar structure. The way shown below should work on Ubuntu, Fedora or Debian.

---

[![Image: Open the menu by right-clicking on the directory you want to remove](https://www.ionos.com/digitalguide/fileadmin/_processed_/a/8/csm_open-the-menu-by-right-clicking-on-the-directory-you-want-to-remove_9663a9101b.webp "Open the menu by right-clicking on the directory you want to remove")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/open-the-menu-by-right-clicking-on-the-directory-you-want-to-remove.png) You can delete the directory by clicking on “Move to trash”.       Sometimes, **certain directories need administrator rights** for you to delete them. Depending on the [file manager](https://www.ionos.com/digitalguide/server/tools/alternative-file-managers-for-windows-linux-and-mac/) you use, it might ask you if it should delete the directory using admin rights, just like Windows would. If the file manager doesn’t ask you this, you have to launch it with the commands “sudo” or “su” in Terminal. This will automatically grant you admin rights in the graphical file manager.

---

### Tip

If you’re not sure what your file manager is called, you can find its name in the menu under “Help”, “About”, or “?”.

---

## Delete a Linux directory: Terminal

There are several different [Linux commands](https://www.ionos.com/digitalguide/server/configuration/linux-commands-an-overview-of-terminal-commands/ "Linux commands: An overview of terminal commands") in Terminal, each with different functions. You can use these commands to delete individual files or entire Linux directories.

1. Open your file manager and go to the directory you want to remove. You can also open Terminal directly and enter **“cd /path/to/the/directory”** to get to the folder that contains the directory.
2. Right-click on the window and the menu will open. **Select “Open in Terminal”**.

[![Image: When you right-click in the file manager, you get the menu with the option to open the Terminal](https://www.ionos.com/digitalguide/fileadmin/_processed_/8/a/csm_when-you-right-click-in-the-file-manager-you-get-the-menu-with-the-option-to-open-the-terminal_ec8e564405.webp "When you right-click in the file manager, you get the menu with the option to open the Terminal")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/when-you-right-click-in-the-file-manager-you-get-the-menu-with-the-option-to-open-the-terminal.png) By right-clicking in the file manager, you can open the chosen directory path directly in Terminal.       3. You can use the **command “rm -r”** (short for “remove”) followed by the name of the directory to delete the whole folder and all of its contents.

```none
rm -r file
```

---

### Note

When you remove a Linux directory, you also remove all files and subdirectories in it. To avoid mistakes, **the command needs to be extended with “-r”**. This deletes the directory and all contained files recursively.

---

[![Image: The Terminal command to delete a full folder in Linux](https://www.ionos.com/digitalguide/fileadmin/_processed_/c/d/csm_the-terminal-command-to-delete-a-full-folder-in-linux_0aba41cd92.webp "The Terminal command to delete a full folder in Linux")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/the-terminal-command-to-delete-a-full-folder-in-linux.png) By using the command “rm” followed by “-r” and the folder name, you can delete a full folder including all its files and subfolders.       As is the case with the file manager, **some directories can only be deleted through the Terminal if you have admin rights**. In this case, change to a root user in the command line by typing “su” and your root password. If you don’t want to change user, you can also enter the following command to delete a Linux directory using admin rights:

```none
sudo rm -r directoryname
```


This is a markdown version of: [https://www.ionos.com/digitalguide/server/configuration/delete-a-linux-directory/](https://www.ionos.com/digitalguide/server/configuration/delete-a-linux-directory/) for AI/LLM consumption.