How to Delete a Folder in Linux

Photo of author

By Oluwaseun Bamisile

Published

Have you been searching the internet for a guide that comprehensively demonstrates how to delete a folder in the Ubuntu Linux-based OS? You should read this guide – it features various methods to delete a folder in Ubuntu Linux.

Before proceeding, it is important to mention that this guide was written using the Ubuntu 22.04 LTS Linux-based OS. Due to this, the procedures provided may be slightly different if you use other versions of the Ubuntu Linux OS.

Option 1: Delete a Folder Through the GUI

Most distributions of the Linux operating system offer a GUI (Graphical User Interface), including the Ubuntu operating system. Hence, through the file manager in the GUI, users should be able to delete a folder.

To delete a folder on your Ubuntu Linux-based computer via the GUI, follow the procedures and screenshot images below.

  1. On the Ubuntu dock, click the Show Applications button. Then, input “files” in the search field and select the Files icon from the search result.
If available, you can also click the Files icon on the Ubuntu dock to open the file manager.
Delete A Folder In Linux Through The GUI
  1. When the file manager opens, click the search icon at the top and input the name of the folder you want to delete in the search field. For this demonstration, I want to delete a folder named “Sample.”
  1. Now, right-click the folder from the search result. Finally, left-click Move to Trash from the options that appear to delete the folder.
Alternatively, select the folder, then click the Delete button on your keyboard.
Delete A Folder In Linux Through The GUI
The procedures mentioned in this section will not permanently delete a folder. Rather, it will move the folder to the trash, where it can be restored or permanently deleted.

Hence, read our How to Empty Trash in Ubuntu article to learn how to permanently delete all the folders and files in your Ubuntu computer’s trash folder. Alternatively, go through the other section below to learn how to permanently delete a folder on your Ubuntu Linux-based PC via the terminal.

Option 2: Delete a Folder via the Terminal

Another method to delete a folder on your Ubuntu Linux-based computer is through the terminal using the rm command. In fact, unlike the method discussed above, this method will permanently delete the folder on your computer.

So, to delete a folder on your Ubuntu Linux-based computer through the terminal, follow the procedures below.

  1. Open the terminal on your Ubuntu computer by right-clicking any free space on the desktop and selecting Open in Terminal from the displayed options. Alternatively, you can also use the Ctrl + Alt + T keyboard shortcut to open the terminal in Ubuntu.
Delete A Folder In Linux Via Terminal
  1. When the terminal opens, execute the command below. However, replace “folder-name” with the exact name of the folder you want to delete.
find / -name "folder-name" -exec rm -r {} +

For example, if I want to delete a folder named “Sample” on my Ubuntu PC, below is what the command should look like.

find / -name "Sample" -exec rm -r {} +
  1. Consequently, the command will find and permanently delete the folder on your computer.
Delete A Folder In Linux Via Terminal

Frequently Asked Questions

1. How do I delete a folder in the Linux terminal?

To delete a folder via the Linux terminal, type “find / -name “folder-name” -exec rm -r {} +” in the terminal and press the enter key. However, replace “folder-name” in the command with the exact name of the folder you want to delete.

2. Can I delete a folder that is currently in use in Ubuntu?

No, you cannot delete a folder that is currently in use on your Ubuntu computer. In order to delete a folder in the Ubuntu operating system, the folder must not be active.

Hence, you will need to stop every program or process using the folder before making an attempt to delete the folder.

3. How can I move a folder to trash in Ubuntu?

Follow the procedures below to learn how to move a folder to trash on your Ubuntu computer.
a) On the Ubuntu dock, click the Show Applications button.
b) Then, input “files” in the search field and select the Files icon from the search result.
c) When the file manager opens, click the search icon at the top and type the name of the folder you want to move to the trash in the search field.
d) Now, right-click the folder from the search result and left-click Move to Trash from the options that appear.

4. Can I recover a deleted file in Ubuntu?

That depends on the method you use to delete the file. To be more specific, if you delete the file by moving it to the trash, you can easily recover it from the trash folder.

5. Can I empty the trash folder in Ubuntu?

Yes, you can empty the trash folder on your Ubuntu computer. Read How to Empty Trash in Ubuntu to learn how to do that.

Conclusion

Deleting unnecessary folders frees up storage space on your Ubuntu Linux-based computer. As a matter of fact, it makes your computer operate faster and smoother.

Gladly, this guide demonstrated multiple ways to delete a folder in the Ubuntu Linux operating system. To be precise, we learned how to perform this task through the Ubuntu GUI (Graphical User Interface).

Procedures to delete a folder via the Linux terminal were also provided in this guide.

I sincerely hope this guide and the methods included were helpful to you. If they were helpful to you, click on “Yes” beside the “Was this page helpful” question below.

You may also express your thoughts and opinions by using the “Leave a Reply” form at the bottom of this page.

Finally, visit our Linux how-to page to get more Linux guides.

About the Author

Photo of author

Oluwaseun Bamisile

Oluwaseun is the Lead Content Editor at Itechguides.com. He holds a National Diploma in Computer Science (currently studying part-time for his Higher National Diploma). An internet geek with a love for automobiles, he writes product reviews, tech articles, and how-to guides on the site.

Related Articles

Get in Touch

We're committed to writing accurate content that informs and educates. To learn more, read our Content Writing Policy, Content Review Policy, Anti-plagiarism Policy, and About Us.

However, if this content does not meet your expectations, kindly reach out to us through one of the following means:

  1. Respond to "Was this page helpful?" above
  2. Leave a comment with the "Leave a Comment" form below
  3. Email us at [email protected] or via the Contact Us page.

Leave a comment

Send this to a friend