{"id":26,"date":"2018-08-22T12:33:29","date_gmt":"2018-08-22T12:33:29","guid":{"rendered":"https:\/\/purepcs.co.uk\/kb\/?p=26"},"modified":"2018-08-22T12:33:29","modified_gmt":"2018-08-22T12:33:29","slug":"linux-file-and-directory-removal-from-the-command-line","status":"publish","type":"post","link":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/","title":{"rendered":"Linux file and directory removal from the command line"},"content":{"rendered":"<div class=\"post-text\">\n<ul>\n<li>To remove <strong>the folder<\/strong> with all its contents(<strong>including all interior folders<\/strong>):\n<pre><code>rm -rf \/path\/to\/directory\r\n<\/code><\/pre>\n<\/li>\n<li>To remove all the <strong>contents of the folder<\/strong>(<strong>including all interior folders<\/strong>) but not the folder itself:\n<pre><code>rm -rf \/path\/to\/directory\/*\r\n<\/code><\/pre>\n<p>or<\/p>\n<pre><code>rm -rf \/path\/to\/directory\/{*,.*}\r\n<\/code><\/pre>\n<p>if you want to make sure that hidden files\/directories are also removed.<\/li>\n<li>To remove all the &#8220;files&#8221; from inside a folder(<strong><em>not<\/em> removing interior folders<\/strong>):\n<pre><code>rm -f \/path\/to\/directory\/{*,.*}\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>Where:<\/p>\n<ul>\n<li><code>rm<\/code> &#8211; stands for &#8220;<strong>remove<\/strong>&#8220;<\/li>\n<li><code>-f<\/code> &#8211; stands for &#8220;<strong>force<\/strong>&#8221; which is helpful when you don&#8217;t want to be asked\/prompted if you want to remove an archive, for example.<\/li>\n<li><code>-r<\/code> &#8211; stands for &#8220;<strong>recursive<\/strong>&#8221; which means that you want to go recursively down every folder and remove everything.<\/li>\n<\/ul>\n<h6>Original Source:<a href=\"https:\/\/askubuntu.com\/a\/60433\" target=\"_blank\" rel=\"noopener\">\u00a0https:\/\/askubuntu.com\/a\/60433<\/a><\/h6>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>To remove the folder with all its contents(including all interior folders): rm -rf \/path\/to\/directory To remove all the contents of the folder(including all interior folders)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,13],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-command-line-cli","category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux file and directory removal from the command line - Pure PC&#039;s<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux file and directory removal from the command line - Pure PC&#039;s\" \/>\n<meta property=\"og:description\" content=\"To remove the folder with all its contents(including all interior folders): rm -rf \/path\/to\/directory To remove all the contents of the folder(including all interior folders)\" \/>\n<meta property=\"og:url\" content=\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/\" \/>\n<meta property=\"og:site_name\" content=\"Pure PC&#039;s\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-22T12:33:29+00:00\" \/>\n<meta name=\"author\" content=\"purepcs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"purepcs\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/\"},\"author\":{\"name\":\"purepcs\",\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089\"},\"headline\":\"Linux file and directory removal from the command line\",\"datePublished\":\"2018-08-22T12:33:29+00:00\",\"dateModified\":\"2018-08-22T12:33:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/\"},\"wordCount\":118,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089\"},\"articleSection\":[\"Command Line (CLi)\",\"Linux\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/\",\"url\":\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/\",\"name\":\"Linux file and directory removal from the command line - Pure PC&#039;s\",\"isPartOf\":{\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#website\"},\"datePublished\":\"2018-08-22T12:33:29+00:00\",\"dateModified\":\"2018-08-22T12:33:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/purepcs.co.uk\/kb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux file and directory removal from the command line\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#website\",\"url\":\"https:\/\/purepcs.co.uk\/kb\/\",\"name\":\"Pure PC&#039;s\",\"description\":\"Ramblings, Knowledge and Musings\",\"publisher\":{\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/purepcs.co.uk\/kb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089\",\"name\":\"purepcs\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/05a7ed7212adca9fab9199df1a61e3092c4eaf22b6e66ab39599144a212ea6f2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/05a7ed7212adca9fab9199df1a61e3092c4eaf22b6e66ab39599144a212ea6f2?s=96&d=mm&r=g\",\"caption\":\"purepcs\"},\"logo\":{\"@id\":\"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux file and directory removal from the command line - Pure PC&#039;s","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/","og_locale":"en_GB","og_type":"article","og_title":"Linux file and directory removal from the command line - Pure PC&#039;s","og_description":"To remove the folder with all its contents(including all interior folders): rm -rf \/path\/to\/directory To remove all the contents of the folder(including all interior folders)","og_url":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/","og_site_name":"Pure PC&#039;s","article_published_time":"2018-08-22T12:33:29+00:00","author":"purepcs","twitter_card":"summary_large_image","twitter_misc":{"Written by":"purepcs","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#article","isPartOf":{"@id":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/"},"author":{"name":"purepcs","@id":"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089"},"headline":"Linux file and directory removal from the command line","datePublished":"2018-08-22T12:33:29+00:00","dateModified":"2018-08-22T12:33:29+00:00","mainEntityOfPage":{"@id":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/"},"wordCount":118,"commentCount":0,"publisher":{"@id":"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089"},"articleSection":["Command Line (CLi)","Linux"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/","url":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/","name":"Linux file and directory removal from the command line - Pure PC&#039;s","isPartOf":{"@id":"https:\/\/purepcs.co.uk\/kb\/#website"},"datePublished":"2018-08-22T12:33:29+00:00","dateModified":"2018-08-22T12:33:29+00:00","breadcrumb":{"@id":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/purepcs.co.uk\/kb\/linux-file-and-directory-removal-from-the-command-line\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/purepcs.co.uk\/kb\/"},{"@type":"ListItem","position":2,"name":"Linux file and directory removal from the command line"}]},{"@type":"WebSite","@id":"https:\/\/purepcs.co.uk\/kb\/#website","url":"https:\/\/purepcs.co.uk\/kb\/","name":"Pure PC&#039;s","description":"Ramblings, Knowledge and Musings","publisher":{"@id":"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/purepcs.co.uk\/kb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/d93eda5f74d1012b66a00b4518a0b089","name":"purepcs","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/05a7ed7212adca9fab9199df1a61e3092c4eaf22b6e66ab39599144a212ea6f2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/05a7ed7212adca9fab9199df1a61e3092c4eaf22b6e66ab39599144a212ea6f2?s=96&d=mm&r=g","caption":"purepcs"},"logo":{"@id":"https:\/\/purepcs.co.uk\/kb\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":1,"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":27,"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/posts\/26\/revisions\/27"}],"wp:attachment":[{"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/purepcs.co.uk\/kb\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}