{"id":59110,"date":"2023-08-16T15:01:38","date_gmt":"2023-08-16T07:01:38","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=59110"},"modified":"2023-08-24T17:09:14","modified_gmt":"2023-08-24T09:09:14","slug":"linux-command-rm-rmdir","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/","title":{"rendered":"How to Delete Files and Folers in Linux"},"content":{"rendered":"<p>To delete a file, files, or a folder in Linux, the Linux command to use is either <code>rm<\/code> or <code>rmdir<\/code>. The rm command stands for \u201cremove\u201d and is used to delete files and directories. By using various options, you can remove files, directories, and even the contents of directories. For example, <code>rm filename<\/code> will delete a file, while <code>rm -r directoryname<\/code> will delete a directory and all its contents.<\/p>\n<p>The <code>rmdir<\/code> command stands for \u201cremove directory\u201d and is specifically used to delete empty directories. If a directory contains any files or subdirectories, the <code>rmdir<\/code> command will not remove it, and an error message will be displayed. In contrast, the <code>rm<\/code> command with the<code> -r<\/code> option can delete non-empty directories. Essentially, <code>rm<\/code> is more versatile, while <code>rmdir<\/code> is more specialized for removing empty directories.<\/p>\n<p>In this post, we look at different ways to use <code>rm<\/code> and <code>rmdir<\/code>.<\/p>\n<h2 id=\"rm\">How to use <code>rm<\/code><\/h2>\n<h3>1. Delete a file<\/h3>\n<pre>rm [file]<\/pre>\n<p>The <code>rm<\/code> command removes a single file. To do this, type <code>rm<\/code> followed by the name of the file you want to delete.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>The following command  is used to remove a specific file named<code> example.txt<\/code> located within a directory named <code>myfolder<\/code>.<\/p>\n<pre>rm myfolder\/example.txt<\/pre>\n<p>Here\u2019s an example of how it works:<\/p>\n<ol>\n<li>Suppose you have a directory named <code>myfolder<\/code> and inside that directory, there\u2019s a file named <code>example.txt<\/code>.<\/li>\n<li>You run the command <code>rm myfolder\/example.txt<\/code>.<\/li>\n<li>The file <code>example.txt<\/code> inside <code>myfolder<\/code> will be deleted, and there will be no output message displayed in the terminal by default.<\/li>\n<li>If you try to access the file <code>example.txt<\/code> again, you\u2019ll get an error message like <code>No such file or directory<\/code>.<\/li>\n<\/ol>\n<p>Before running the command, if you had:<\/p>\n<pre>myfolder\/\r\n\u2514\u2500\u2500 example.txt<\/pre>\n<p>After running the command, the structure would be:<\/p>\n<pre>myfolder\/<\/pre>\n<hr>\n<h3>2. Remove files without confirmation<\/h3>\n<pre>rm -f [file]<\/pre>\n<p>This option allows users to remove write-protected files without confirmation.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Suppose you have a file named <code>file1.txt<\/code> in your current directory, and you want to delete it. You can run the following command:<\/p>\n<pre>rm -f file1.txt\r\n<\/pre>\n<p>Since the <code>-f<\/code> option is used, there will be no confirmation prompt, and the file will be deleted immediately. There will be no output displayed in the terminal if the operation is successful. If you try to view the contents of the directory afterward, you will find that <code>file1.txt<\/code> is no longer there.<\/p>\n<hr>\n<h3>3. Delete multiple files<\/h3>\n<pre>rm [file1] [file2] [file3]<\/pre>\n<p>Use the <code>rm<\/code> command with filenames as arguments to remove multiple files at once.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Before running the command, let\u2019s say you have the following files in your directory:<\/p>\n<pre>file1.txt\r\nfile2.txt\r\nfile3.txt\r\notherfile.txt\r\n<\/pre>\n<p>You run the command <code>rm file1.txt file2.txt file3.txt<\/code>.<\/p>\n<p>After running the command, the files <code>file1.txt<\/code>, <code>file2.txt<\/code>, and <code>file3.txt<\/code> are deleted, and your directory now looks like this:<\/p>\n<pre>otherfile.txt\r\n<\/pre>\n<hr>\n<h3>4. Display output message<\/h3>\n<pre>rm -v [filename]<\/pre>\n<p>The <code>-v<\/code> (verbose) option allows you to get information about what is being removed.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>When you execute the command <code>rm -v example.txt<\/code>, here\u2019s the output you will get:<\/p>\n<pre>removed 'example.txt'\r\n<\/pre>\n<p>In this example, the file <code>example.txt<\/code> is deleted, and the system prints a message confirming that the file has been removed. If the file does not exist, an error message like <code>rm: cannot remove 'example.txt': No such file or directory<\/code> would be displayed instead.<\/p>\n<hr>\n<h3>5. Prompt for confirmation before deleting a file<\/h3>\n<pre>rm -i [filename]<\/pre>\n<p>This option is used to request confirmation before deleting a file. Typing <code>y<\/code> (yes) confirms, typing <code>n<\/code> (no) stops.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Let\u2019s say you have a file named <code>example.txt<\/code> and you run the command:<\/p>\n<pre>rm -i example.txt<\/pre>\n<p>The system will prompt you with a message like:<\/p>\n<pre>remove regular file 'example.txt'? <\/pre>\n<p>You\u2019ll then need to type <code>y<\/code> (for yes) or <code>n<\/code> (for no) to confirm or deny the deletion. If you type <code>y<\/code> and press Enter, the file <code>example.txt<\/code> will be deleted. If you type <code>n<\/code>, the file will remain untouched.<\/p>\n<pre>remove regular file 'example.txt'? y<\/pre>\n<p>After this, <code>example.txt<\/code> will be deleted if you confirmed with <code>y<\/code>.<\/p>\n<hr>\n<h2 id=\"rmdir\">How to use <code>rmdir<\/code><\/h2>\n<p>This command removes directory as well as files within the directory. There isn\u2019t significant difference with the <code>rm -r<\/code> command except that it can not be used to remove a file.<\/p>\n<p>General syntax for <code>rmdir<\/code> command:<\/p>\n<pre>\r\n$ rmdir [OPTION...] [DIRECTORY...]\r\n<\/pre>\n<h3>1. Remove a directory<\/h3>\n<pre>rmdir [directory]<\/pre>\n<p>Use this command to remove a directory, but it will only be removed if it is empty.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Suppose you have a directory named <code>myfolder<\/code> and it\u2019s empty. When you run the command:<\/p>\n<pre>rmdir myfolder<\/pre>\n<p>The directory <code>myfolder<\/code> will be deleted, and there will be no output message if the operation is successful.<\/p>\n<p>However, if <code>myfolder<\/code> is not empty or does not exist, you will receive an error message. For example, if <code>myfolder<\/code> contains files or subdirectories, you might see:<\/p>\n<pre>rmdir: failed to remove 'myfolder': Directory not empty<\/pre>\n<p>Or if <code>myfolder<\/code> does not exist:<\/p>\n<pre>rmdir: failed to remove 'myfolder': No such file or directory<\/pre>\n<hr>\n<h3>2. Delete multiple directories<\/h3>\n<pre>rmdir [folder1] [folder2] [folder3]<\/pre>\n<p>This command allows you to delete several directories at once, but they all must be empty.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>The <code>rmdir folder1 folder2 folder3<\/code> command in Linux attempts to remove the directories named <code>folder1<\/code>, <code>folder2<\/code>, and <code>folder3<\/code>. This command will only succeed if all three of these directories are empty; otherwise, an error message will be displayed.<\/p>\n<p>Here\u2019s an example of how this might work:<\/p>\n<p>If <code>folder1<\/code>, <code>folder2<\/code>, and <code>folder3<\/code> are all empty directories, the command will remove them, and there will be no output message.<\/p>\n<p>If any of these directories are not empty or do not exist, an error message will be displayed for each problematic directory.<\/p>\n<p>Example of the output if <code>folder2<\/code> is not empty:<\/p>\n<pre>rmdir: failed to remove 'folder2': Directory not empty\r\n<\/pre>\n<p>In this case, <code>folder1<\/code> and <code>folder3<\/code> would still be removed if they were empty, but <code>folder2<\/code> would remain untouched.<\/p>\n<hr>\n<h3>3. Remove parent directories <\/h3>\n<pre>rmdir -p [directory-path]<\/pre>\n<p>The <code>-p<\/code> option removes the specified directory and its parent directories.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Here\u2019s an example of how the command <code>rmdir -p folder_a\/folder_b<\/code> would work:<\/p>\n<p>Suppose you have a directory structure like this:<\/p>\n<pre>folder_a\r\n\u2514\u2500\u2500 folder_b\r\n<\/pre>\n<p>If both <code>folder_a<\/code> and <code>folder_b<\/code> are empty, running the command <code>rmdir -p folder_a\/folder_b<\/code> will remove <code>folder_b<\/code> first, and then, since <code>folder_a<\/code> becomes empty, it will remove <code>folder_a<\/code> as well.<\/p>\n<p>If there were any files or subdirectories inside <code>folder_a<\/code> or <code>folder_b<\/code>, the command would not remove them, and you would receive an error message like:<\/p>\n<pre>rmdir: failed to remove 'folder_a\/folder_b': Directory not empty\r\n<\/pre>\n<p>In the successful case, there would be no output, and both directories would be deleted.<\/p>\n<hr>\n<h3 style=\"padding-bottom:10px\">More Linux commands:<\/h3>\n<table>\n<tbody>\n<tr>\n<td width=\"150\">Directory Operations<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/\"><code>rmdir<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-cd\/\"><code>cd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-pwd\/\"><code>pwd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-exa\/\"><code>exa<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ls\/\"><code>ls<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">File Operations<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-cat\/\"><code>cat<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-cp\/\"><code>cp<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-dd\/\"><code>dd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-less\/\"><code>less<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-touch\/\"><code>touch<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ln\/\"><code>ln<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-rename\/\"><code>rename<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-more\/\"><code>more<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-head\/\"><code>head<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">File System Operations<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-chown\/\"><code>chown<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-mkfs\/\"><code>mkfs<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-locate\/\"><code>locate<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">Networking<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ping\/\"><code>ping<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-curl\/\"><code>curl<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-wget\/\"><code>wget<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-iptables\/\"><code>iptables<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-mtr\/\"><code>mtr<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">Search and Text Processing<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-find\/\"><code>find<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-grep\/\"><code>grep<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-sed\/\"><code>sed<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-whatis\/\"><code>whatis<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-ripgrep\/\"><code>ripgrep<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-fd\/\"><code>fd<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-tldr\/\"><code>tldr<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">System Information and Management<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-env\/\"><code>env<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-history\/\"><code>history<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-top\/\"><code>top<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-who\/\"><code>who<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-htop\/\"><code>htop<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-glances\/\"><code>glances<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-lsof\/\"><code>lsof<\/code><\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"150\">User and Session Management<\/td>\n<td><a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-screen\/\"><code>screen<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-su\/\"><code>su<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-sudo\/\"><code>sudo<\/code><\/a> \u00b7 <a href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-open\/\"><code>open<\/code><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>","protected":false},"excerpt":{"rendered":"<p>Clean up your Linux workspace effortlessly with the rm and rmdir commands.<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3397],"tags":[888,3316],"topic":[],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Delete Files and Folers in Linux - Hongkiat<\/title>\n<meta name=\"description\" content=\"Clean up your Linux workspace effortlessly with the rm and rmdir commands.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Delete Files and Folers in Linux\" \/>\n<meta property=\"og:description\" content=\"Clean up your Linux workspace effortlessly with the rm and rmdir commands.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-16T07:01:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-24T09:09:14+00:00\" \/>\n<meta name=\"author\" content=\"Hongkiat.com\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hongkiat.com\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/\"},\"author\":{\"name\":\"Hongkiat.com\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/7cc686597d92f9086729e4bcc1577ba3\"},\"headline\":\"How to Delete Files and Folers in Linux\",\"datePublished\":\"2023-08-16T07:01:38+00:00\",\"dateModified\":\"2023-08-24T09:09:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/\"},\"wordCount\":882,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"keywords\":[\"Linux\",\"Linux Commands\"],\"articleSection\":[\"Desktop\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/\",\"name\":\"How to Delete Files and Folers in Linux - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"datePublished\":\"2023-08-16T07:01:38+00:00\",\"dateModified\":\"2023-08-24T09:09:14+00:00\",\"description\":\"Clean up your Linux workspace effortlessly with the rm and rmdir commands.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/linux-command-rm-rmdir\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Delete Files and Folers in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/7cc686597d92f9086729e4bcc1577ba3\",\"name\":\"Hongkiat.com\",\"description\":\"This post is published by an HKDC (hongkiat.com) staff. (I.e., intern, staff writer, or editor).\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Delete Files and Folers in Linux - Hongkiat","description":"Clean up your Linux workspace effortlessly with the rm and rmdir commands.","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:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/","og_locale":"en_US","og_type":"article","og_title":"How to Delete Files and Folers in Linux","og_description":"Clean up your Linux workspace effortlessly with the rm and rmdir commands.","og_url":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2023-08-16T07:01:38+00:00","article_modified_time":"2023-08-24T09:09:14+00:00","author":"Hongkiat.com","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Hongkiat.com","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/"},"author":{"name":"Hongkiat.com","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/7cc686597d92f9086729e4bcc1577ba3"},"headline":"How to Delete Files and Folers in Linux","datePublished":"2023-08-16T07:01:38+00:00","dateModified":"2023-08-24T09:09:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/"},"wordCount":882,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"keywords":["Linux","Linux Commands"],"articleSection":["Desktop"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/","url":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/","name":"How to Delete Files and Folers in Linux - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"datePublished":"2023-08-16T07:01:38+00:00","dateModified":"2023-08-24T09:09:14+00:00","description":"Clean up your Linux workspace effortlessly with the rm and rmdir commands.","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/linux-command-rm-rmdir\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Delete Files and Folers in Linux"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/7cc686597d92f9086729e4bcc1577ba3","name":"Hongkiat.com","description":"This post is published by an HKDC (hongkiat.com) staff. (I.e., intern, staff writer, or editor).","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/com\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-fno","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/59110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=59110"}],"version-history":[{"count":4,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/59110\/revisions"}],"predecessor-version":[{"id":68904,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/59110\/revisions\/68904"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=59110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=59110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=59110"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=59110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}