Quick Answer: How to Remove a Folder in Linux?
Contents

How do I force delete a directory in Linux?

To remove a directory that contains other files or directories, use the following command.

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.

How do I delete a folder in Terminal?

To get rid of stubborn files, first try using the Terminal to run a direct root-level delete command on the file:

  • Open the Terminal and type this command, followed by a space: sudo rm -rf.
  • Drag the desired file or folder to the terminal window.
  • Press enter, followed by entering your password.
Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest