{"id":3533,"date":"2021-11-03T05:54:57","date_gmt":"2021-11-03T05:54:57","guid":{"rendered":"https:\/\/ownwebservers.com\/kb\/?p=3533"},"modified":"2021-11-03T05:54:57","modified_gmt":"2021-11-03T05:54:57","slug":"how-to-remove-files-in-linux-terminal","status":"publish","type":"post","link":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/","title":{"rendered":"How to Remove Files in Linux Terminal?"},"content":{"rendered":"<p>In this tutorial you will understand, how to use the\u00a0<strong>rm<\/strong>,\u00a0<strong>unlink<\/strong>\u00a0and\u00a0<strong>rmdir<\/strong> commands to delete files in Linux.<\/p>\n<h2>How to Remove Files<\/h2>\n<p>You can use\u00a0<strong>rm<\/strong>\u00a0(remove) or\u00a0<strong>unlink<\/strong>\u00a0command to remove or delete a file from the Linux command line.<\/p>\n<p>The\u00a0<strong>rm<\/strong>\u00a0command allows you to remove multiple files at once. With\u00a0<strong>unlink<\/strong>\u00a0command, you can delete only a single file.<\/p>\n<p>While removing files or directories you should be extra careful, as if the file is deleted, you won\u2019t be able to recover it easily.<\/p>\n<ul>\n<li>Use the\u00a0<strong>rm<\/strong>\u00a0or\u00a0<strong>unlink<\/strong>\u00a0command to delete a single file followed by the file name:<\/li>\n<\/ul>\n<blockquote><p>unlink \/home\/admin\/directoryname myfile<\/p>\n<p>rm \/home\/admin\/directoryname\/myfile<\/p><\/blockquote>\n<p>You will be notified for confirmation if the file is write-protected, as shown below. Type\u00a0<strong>y<\/strong>\u00a0and hit\u00a0<strong>Enter<\/strong>\u00a0key to remove the file, or else, it will be deleted without prompting if the file is not write-protected.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"vlt-box\">\n<div class=\"box-content\">\n<blockquote><p>rm: remove write-protected regular empty file \u2018file\u2019?<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<ul>\n<li>Use the\u00a0<strong>rm<\/strong>\u00a0command to delete multiple files at once followed by the file names separated with space:<\/li>\n<\/ul>\n<blockquote><p>rm \/home\/admin\/directoryname\/myfile1<\/p>\n<p>rm \/home\/admin\/directoryname\/myfile2<\/p>\n<p>rm \/home\/admin\/directoryname\/myfile3<\/p><\/blockquote>\n<p><strong>OR<\/strong><\/p>\n<blockquote><p>cd \/home\/admin\/directoryname<\/p>\n<p>rm myfile1 myfile2 myfile3<\/p><\/blockquote>\n<p><strong>OR<\/strong><\/p>\n<div class=\"vlt-box\">\n<div class=\"box-content\">\n<blockquote><p>rm \/home\/admin\/directoryname\/myfile*<\/p><\/blockquote>\n<p>To match multiple files, you can use an asterisk\u00a0<strong>(*)<\/strong>\u00a0and regular expansions. Execute the following command to remove all\u00a0<strong>.pdf<\/strong>\u00a0files placed in the current directory:<\/p>\n<div class=\"vlt-box\">\n<div class=\"box-content\">\n<blockquote><p>rm \/home\/admin\/directoryname\/*.pdf<\/p><\/blockquote>\n<\/div>\n<\/div>\n<p>Run the\u00a0<strong>ls<\/strong>\u00a0command to list the files if you are using regular expansions so that you can see what files will be deleted before running the\u00a0<strong>rm<\/strong>\u00a0command.<\/p>\n<ul>\n<li>Run the\u00a0<strong>rm<\/strong>\u00a0command with the\u00a0<strong>-i<\/strong>\u00a0option to verify each file before deleting it:<\/li>\n<\/ul>\n<div class=\"vlt-box\">\n<div class=\"box-content\">\n<blockquote><p>rm -i \/home\/admin\/directoryname\/myfile(s)<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<\/div>\n<\/div>\n<ul>\n<li>You can run the\u00a0<strong>-f<\/strong>\u00a0(force) option with\u00a0<strong>rm<\/strong>\u00a0command to remove the files without prompting even if the files are write-protected:<\/li>\n<\/ul>\n<div class=\"vlt-box\">\n<div class=\"box-content\">\n<blockquote><p>rm -f \/home\/admin\/directoryname\/myfile(s)<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<\/div>\n<\/div>\n<ul>\n<li>You can also combine rm options. You can run the following command to delete all .txt files in the present directory without a prompt in verbose mode.<\/li>\n<\/ul>\n<div class=\"vlt-box\">\n<div class=\"box-content\">\n<blockquote><p>rm -fv \/home\/admin\/directoryname\/*.txt<\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial you will understand, how to use the\u00a0rm,\u00a0unlink\u00a0and\u00a0rmdir commands to delete files in Linux. How to Remove Files You can use\u00a0rm\u00a0(remove) or\u00a0unlink\u00a0command to remove or delete a file from the Linux command line. The\u00a0rm\u00a0command allows you to remove multiple files at once. With\u00a0unlink\u00a0command, you can delete only a single file. While removing files [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-3533","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Remove Files in Linux Terminal? - OWS KB<\/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:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Remove Files in Linux Terminal? - OWS KB\" \/>\n<meta property=\"og:description\" content=\"In this tutorial you will understand, how to use the\u00a0rm,\u00a0unlink\u00a0and\u00a0rmdir commands to delete files in Linux. How to Remove Files You can use\u00a0rm\u00a0(remove) or\u00a0unlink\u00a0command to remove or delete a file from the Linux command line. The\u00a0rm\u00a0command allows you to remove multiple files at once. With\u00a0unlink\u00a0command, you can delete only a single file. While removing files [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/\" \/>\n<meta property=\"og:site_name\" content=\"OWS KB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/OWN-WEB-SERVERS-107052961577434\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-03T05:54:57+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@OwnWebservers\" \/>\n<meta name=\"twitter:site\" content=\"@OwnWebservers\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#\\\/schema\\\/person\\\/4a40fe3fe17a08ddd1d7c113668e75f2\"},\"headline\":\"How to Remove Files in Linux Terminal?\",\"datePublished\":\"2021-11-03T05:54:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/\"},\"wordCount\":363,\"publisher\":{\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/\",\"url\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/\",\"name\":\"How to Remove Files in Linux Terminal? - OWS KB\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#website\"},\"datePublished\":\"2021-11-03T05:54:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/how-to-remove-files-in-linux-terminal\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Remove Files in Linux Terminal?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/\",\"name\":\"OWS KB\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#organization\",\"name\":\"Own Web Servers\",\"url\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/OWS-Logo-with-punchline-front-scaled.png\",\"contentUrl\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/OWS-Logo-with-punchline-front-scaled.png\",\"width\":2560,\"height\":994,\"caption\":\"Own Web Servers\"},\"image\":{\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/OWN-WEB-SERVERS-107052961577434\",\"https:\\\/\\\/x.com\\\/OwnWebservers\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ownwebservers.com\\\/kb\\\/#\\\/schema\\\/person\\\/4a40fe3fe17a08ddd1d7c113668e75f2\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ba5db5841d48bd7517bb2583e13983e6d2fa56a4099a0b3c61ad2daefc321303?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ba5db5841d48bd7517bb2583e13983e6d2fa56a4099a0b3c61ad2daefc321303?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ba5db5841d48bd7517bb2583e13983e6d2fa56a4099a0b3c61ad2daefc321303?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/ownwebservers.com\\\/kb\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Remove Files in Linux Terminal? - OWS KB","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:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/","og_locale":"en_US","og_type":"article","og_title":"How to Remove Files in Linux Terminal? - OWS KB","og_description":"In this tutorial you will understand, how to use the\u00a0rm,\u00a0unlink\u00a0and\u00a0rmdir commands to delete files in Linux. How to Remove Files You can use\u00a0rm\u00a0(remove) or\u00a0unlink\u00a0command to remove or delete a file from the Linux command line. The\u00a0rm\u00a0command allows you to remove multiple files at once. With\u00a0unlink\u00a0command, you can delete only a single file. While removing files [&hellip;]","og_url":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/","og_site_name":"OWS KB","article_publisher":"https:\/\/www.facebook.com\/OWN-WEB-SERVERS-107052961577434","article_published_time":"2021-11-03T05:54:57+00:00","author":"admin","twitter_card":"summary_large_image","twitter_creator":"@OwnWebservers","twitter_site":"@OwnWebservers","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/#article","isPartOf":{"@id":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/"},"author":{"name":"admin","@id":"https:\/\/ownwebservers.com\/kb\/#\/schema\/person\/4a40fe3fe17a08ddd1d7c113668e75f2"},"headline":"How to Remove Files in Linux Terminal?","datePublished":"2021-11-03T05:54:57+00:00","mainEntityOfPage":{"@id":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/"},"wordCount":363,"publisher":{"@id":"https:\/\/ownwebservers.com\/kb\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/","url":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/","name":"How to Remove Files in Linux Terminal? - OWS KB","isPartOf":{"@id":"https:\/\/ownwebservers.com\/kb\/#website"},"datePublished":"2021-11-03T05:54:57+00:00","breadcrumb":{"@id":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ownwebservers.com\/kb\/how-to-remove-files-in-linux-terminal\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ownwebservers.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to Remove Files in Linux Terminal?"}]},{"@type":"WebSite","@id":"https:\/\/ownwebservers.com\/kb\/#website","url":"https:\/\/ownwebservers.com\/kb\/","name":"OWS KB","description":"","publisher":{"@id":"https:\/\/ownwebservers.com\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ownwebservers.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ownwebservers.com\/kb\/#organization","name":"Own Web Servers","url":"https:\/\/ownwebservers.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ownwebservers.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2026\/07\/OWS-Logo-with-punchline-front-scaled.png","contentUrl":"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2026\/07\/OWS-Logo-with-punchline-front-scaled.png","width":2560,"height":994,"caption":"Own Web Servers"},"image":{"@id":"https:\/\/ownwebservers.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/OWN-WEB-SERVERS-107052961577434","https:\/\/x.com\/OwnWebservers"]},{"@type":"Person","@id":"https:\/\/ownwebservers.com\/kb\/#\/schema\/person\/4a40fe3fe17a08ddd1d7c113668e75f2","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ba5db5841d48bd7517bb2583e13983e6d2fa56a4099a0b3c61ad2daefc321303?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ba5db5841d48bd7517bb2583e13983e6d2fa56a4099a0b3c61ad2daefc321303?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ba5db5841d48bd7517bb2583e13983e6d2fa56a4099a0b3c61ad2daefc321303?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/ownwebservers.com\/kb"]}]}},"_links":{"self":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/3533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/comments?post=3533"}],"version-history":[{"count":1,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/3533\/revisions"}],"predecessor-version":[{"id":3534,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/3533\/revisions\/3534"}],"wp:attachment":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/media?parent=3533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/categories?post=3533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/tags?post=3533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}