Question: How Do I Remove a Nested Directory in Linux?
Contents

Use option -p, to delete nested directories as shown below. Note: Don’t get panic that how a directory can be nested and also empty. It is nested when you are invoking the command, but it deletes the inner most directory first, and makes the next level directory empty then it deletes that directory.

How do I delete a subfolder in Linux?

Here’s where we would use the “rm” command. You can also remove empty directories with the “rm” command, so you can always use that one. We used the option “-r” to recursively delete all subdirectories (subfolders) and files in the parent directory. If you don’t use the “-r” option, you will only delete a single file.

How do I delete a subfolder?

To delete a Subfolder:

  1. Go to Folders. Open the parent Folder that your Subfolder exists in.
  2. Click the 3-dot menu next to the Folder.
  3. Select Delete this Folder.
  4. A warning will appear. Click Delete.
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest