{"id":15673,"date":"2022-02-28T15:23:37","date_gmt":"2022-02-28T15:23:37","guid":{"rendered":"https:\/\/linuxways.net\/?p=15673"},"modified":"2022-02-28T15:23:37","modified_gmt":"2022-02-28T15:23:37","slug":"how-to-delete-a-directory-in-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-delete-a-directory-in-ubuntu-20-04\/","title":{"rendered":"How to Delete a Directory in Ubuntu 20.04"},"content":{"rendered":"<p>Ubuntu, which is based on Debian&#8217;s design which is one of the best Linux distro currently available. Although this Linux distro was designed for personal computers (PC), it can also be deployed on servers. Every operating system has different types of directories that store multiple files. Storage space is a common problem nowadays in most systems, so to free up space, or to remove duplicate copies of the same directories we need to delete the directories. Ubuntu provides multiple ways to delete directories to free-up space which will be discussed in detail in this article.<\/p>\n<p>A directory is a categorization structure in the file systems that contain referrals to other computer files and maybe other directories. A directory service&#8217;s primary task is to control the interactions between consumers and their IT resources within an organization or manage the same type of data in one place. In this Article deletion process of the directory on the Ubuntu system will be discussed.<\/p>\n<h2><strong>Delete a Directory in Ubuntu<\/strong><\/h2>\n<p>Ubuntu provides both ways to delete the directory: Graphical User Interface and Command Line interface. Below mentioned are some ways to delete a directory.<\/p>\n<ul>\n<li>Delete Directory using GUI<\/li>\n<li>Delete Directory using the rm command<\/li>\n<li>Delete Directory using the rmdir command<\/li>\n<\/ul>\n<p>Below these ways are explained in detail.<\/p>\n<h3><strong>Delete Directory using GUI<\/strong><\/h3>\n<p>If you are a beginner and don\u2019t know how to use the Linux terminal, then you can also delete the directory using the GUI method.<\/p>\n<p>To delete the directory, left click on the directory and click on the &#8220;move to trash&#8221; option. As I wanted to delete the &#8220;Linux&#8221; directory from the Documents folder, I will move the cursor on it and then left click on it and then click on the option &#8220;move to trash&#8221; from the drop-down list as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"596\" class=\"wp-image-15674\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-description-2.png\" alt=\"Graphical user interface, application Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-description-2.png 891w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-description-2-300x201.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-description-2-768x514.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/p>\n<p>After selecting this option you should be able to see that the directory is no longer available as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"593\" class=\"wp-image-15675\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-teams-desc.png\" alt=\"Graphical user interface, application, Teams Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-teams-desc.png 891w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-teams-desc-300x200.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-application-teams-desc-768x511.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/p>\n<h3><strong>Delete Directory using rm command<\/strong><\/h3>\n<p>The rm command is abbreviated as &#8220;remove&#8221;. This command is used to delete things from file systems like Linux like files, symbolized links, directories, and so on. This operation usually works quietly, and you should take caution while using it because after you delete files, you won&#8217;t be able to recover the data of those files or directories. It does not delete directory by default unless used with some option<\/p>\n<h4><strong>How to Delete Empty Directory<\/strong><\/h4>\n<p>The below-mentioned syntax is used to delete an empty directory using rm.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -d directory_name<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Run the mentioned command below to delete the directory &#8220;Linux&#8221;.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -d linux<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"952\" height=\"278\" class=\"wp-image-15676\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-20.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-20.png 952w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-20-300x88.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-20-768x224.png 768w\" sizes=\"auto, (max-width: 952px) 100vw, 952px\" \/><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>The Linux directory will be removed in the below output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"248\" class=\"wp-image-15677\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-21.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-21.png 973w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-21-300x76.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-21-768x196.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/p>\n<h4><strong>How to Delete Non-Empty Directory<\/strong><\/h4>\n<p>Below mentioned is the syntax to delete all files and directories that aren&#8217;t empty using rm.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -r directory_name<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>-r:<\/strong> recursive option<\/p>\n<p>Run the command mentioned below to delete the non-empty &#8220;Linux&#8221; directory.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -r linux <\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"225\" class=\"wp-image-15678\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-3.png\" alt=\"Graphical user interface Description automatically generated with medium confidence\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-3.png 721w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-3-300x94.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>The Linux directory containing files will be removed in the below output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1218\" height=\"198\" class=\"wp-image-15679\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa.png\" alt=\"Graphical user interface, text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa.png 1218w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-300x49.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-1024x166.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-768x125.png 768w\" sizes=\"auto, (max-width: 1218px) 100vw, 1218px\" \/><\/p>\n<p>Below\u00a0rm is used\u00a0with the -r\u00a0and -f arguments to remove non-empty directory\u00a0and all files without being prompted:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -rf directory_name<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The mentioned command will delete a non-empty &#8220;Linux&#8221; directory without being prompted.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -rf linux<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"873\" height=\"245\" class=\"wp-image-15680\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-22.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-22.png 873w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-22-300x84.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-22-768x216.png 768w\" sizes=\"auto, (max-width: 873px) 100vw, 873px\" \/><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>The Linux directory will be removed in the below output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1219\" height=\"192\" class=\"wp-image-15681\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-1.png\" alt=\"Graphical user interface, text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-1.png 1219w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-1-300x47.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-1-1024x161.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-1-768x121.png 768w\" sizes=\"auto, (max-width: 1219px) 100vw, 1219px\" \/><\/p>\n<h4><strong>How to Delete Multiple Directories<\/strong><\/h4>\n<p>Below mentioned is the syntax to delete multiple directories using the rm command.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -r directory_name1 directory_name2 \u2026..<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Run the mentioned below command to delete the &#8220;linux1&#8221; and &#8220;linux2&#8221; directory.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rm -r linux1 linux2<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"243\" class=\"wp-image-15682\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-with-med-1.png\" alt=\"Text Description automatically generated with medium confidence\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-with-med-1.png 927w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-with-med-1-300x79.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-with-med-1-768x201.png 768w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>The linux1 and linux2 directory will be removed in the below output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1212\" height=\"158\" class=\"wp-image-15683\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-2.png\" alt=\"Graphical user interface, text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-2.png 1212w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-2-300x39.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-2-1024x133.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-text-description-automa-2-768x100.png 768w\" sizes=\"auto, (max-width: 1212px) 100vw, 1212px\" \/><\/p>\n<h2><strong>Delete Directory Using the rmdir command<\/strong><\/h2>\n<p>In Linux, the rmdir command is used to delete empty directories or directories from the system. Only if all of the directories specified in the command-line interface are empty, does the rmdir command erase them. If the supplied directory contains any directories or files, the rmdir command will not be able to delete them.<\/p>\n<p>Below mentioned is the syntax to remove an empty directory using rmdir.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>$ <strong>rmdir directory_name<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Run the below-mentioned command to remove the empty &#8220;Linux&#8221; directory using rmdir.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre><strong>$ rmdir -r linux<\/strong><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"802\" height=\"240\" class=\"wp-image-15684\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-23.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-23.png 802w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-23-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/text-description-automatically-generated-23-768x230.png 768w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>The Linux directory will be removed in the below output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1217\" height=\"183\" class=\"wp-image-15685\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-4.png\" alt=\"Graphical user interface Description automatically generated\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-4.png 1217w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-4-300x45.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-4-1024x154.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/02\/graphical-user-interface-description-automaticall-4-768x115.png 768w\" sizes=\"auto, (max-width: 1217px) 100vw, 1217px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>To solve the problem of storage space, we need to delete the directories which are no longer in our use. Ubuntu provides multiple ways to delete the directory. This article is about deleting a directory using the GUI method, &#8220;rm&#8221; command, and &#8220;rmdir&#8221; command. All these methods are discussed in detail.<\/p>","protected":false},"excerpt":{"rendered":"<p>Ubuntu, which is based on Debian&#8217;s design which is one of the best Linux distro currently available. Although this Linux distro was designed for personal computers (PC), it&hellip;<\/p>","protected":false},"author":1,"featured_media":15686,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[878,100],"class_list":["post-15673","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-directory","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/15673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=15673"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/15673\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/15686"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=15673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=15673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=15673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}