{"id":3868,"date":"2025-12-12T12:39:18","date_gmt":"2025-12-12T12:39:18","guid":{"rendered":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?p=3868"},"modified":"2025-12-12T12:39:18","modified_gmt":"2025-12-12T12:39:18","slug":"rename-folder-in-linux","status":"publish","type":"post","link":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html","title":{"rendered":"How to Rename a Folder in Linux\u200b?"},"content":{"rendered":"\n<p>When working with Linux, whether you\u2019re managing files, organizing projects, or cleaning up your servers, renaming folders is something you will need to do quite often. It might sound like a basic task, but if you are new to the command line, it can feel a little confusing at first.<\/p>\n\n\n\n<p>The good news is that renaming folders in Linux is extremely easy once you understand the right command and how it works!<\/p>\n\n\n\n<p>In this guide, we will walk you through the simplest, most commonly used method for renaming a directory in the terminal. We will also explain important things to keep in mind so you don\u2019t run into errors.<\/p>\n\n\n\n<p>Let\u2019s get started!<\/p>\n\n\n\n<hr><p><strong>Also Read: <a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/484\/check-memory-usage-in-linux.html\">How to Check Memory in Linux?<\/a><\/strong><\/p><hr>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Method 1: Rename a Folder Using the mv Command<\/strong><\/h3>\n\n\n\n<p>Linux does not have a dedicated <strong>\u2018rename\u2019<\/strong> command for directories. Instead, the <strong>mv<\/strong> (move) command is used to rename files and folders. You simply <strong>\u2018move\u2019<\/strong> a folder from its old name to a new name.<\/p>\n\n\n\n<p>\u2794 To begin, open your terminal window.<\/p>\n\n\n\n<p>\u2794 Use the <strong>cd<\/strong> command to navigate to the directory where your folder exists.<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>cd \/path\/to\/your\/folder<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For example, if the folder is inside your Documents:<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>cd ~\/Documents<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u2794 Now, you have to use the mv command with this basic syntax.<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>mv old_folder_name new_folder_name<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For example, if you want to rename a folder from <strong>project1<\/strong> to <strong>project-final<\/strong>, run:<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>mv project1 project-final<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This will instantly rename the folder in the same location.<\/p>\n\n\n\n<hr><p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/481\/check-os-version-in-linux.html\"><strong>How to Check OS Version in Linux\u200b?<\/strong><\/a><\/p><hr>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Method 2: Rename a Folder from Any Location (Using Full Path)<\/strong><\/h3>\n\n\n\n<p>If you are not inside the folder\u2019s directory, you can still rename it using full paths.<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>mv \/home\/user\/old-folder \/home\/user\/new-folder<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This is useful when you want to rename a folder without switching directories.<\/p>\n\n\n\n<hr><p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/482\/check-os-kernel-version-in-linux.html\"><strong>How to Check OS Kernel Version in Linux\u200b?<\/strong><\/a><\/p><hr>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Method 3: Rename Multiple Folders Using Wildcards (Advanced)<\/strong><\/h3>\n\n\n\n<p>If you have multiple folders with similar names and want to rename them in a pattern, you can use a loop.<\/p>\n\n\n\n<p>For Example, add a prefix to all folders starting with <strong>\u2018test\u2019<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>for d in test*; do mv &#8220;$d&#8221; &#8220;new-$d&#8221;; done<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Use this only if you are comfortable with the command line to avoid accidental changes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Errors &amp; How to Avoid Them<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. \u2018No such file or directory\u2019<\/strong><\/h3>\n\n\n\n<p>This means the old folder name is incorrect or misspelled.<\/p>\n\n\n\n<p>Use this command to check:<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>ls<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \u2018Permission denied\u2019<\/strong><\/h3>\n\n\n\n<p>You may need elevated permissions.<\/p>\n\n\n\n<p>Try adding sudo:<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>sudo mv oldname newname<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Spaces in Folder Names<\/strong><\/h3>\n\n\n\n<p>If your folder name has spaces, wrap it in quotes:<\/p>\n\n\n\n<figure class=\"wp-block-table\">\n\t<button class=\"copy-btn\" onclick=\"copyCommand(this)\">\ud83d\udccb<\/button><span class=\"copy-msg\">Copied!<\/span>\n\t<table class=\"has-fixed-layout\"><tbody><tr><td class=\"kb_firewall\"><strong>mv &#8220;Old Folder&#8221; &#8220;New Folder Name&#8221;<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr><p><strong>Also Read: <\/strong><a href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/446\/search-file-in-linux-using-commands.html\"><strong>How to Search a File in Linux Using a Command?<\/strong><\/a><\/p><hr>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Renaming a folder in Linux is simple once you know the right command. The mv command, which is often labeled <strong>\u201cmove,\u201d<\/strong> can also rename directories.<\/p>\n\n\n\n<p>Whether you are organizing files, cleaning up project structures, or updating naming conventions, this method will help you do it quickly and efficiently.<\/p>\n\n\n\n<p>With just a few commands and a little practice, you will be managing files like a Linux pro!<\/p>\n\n\n<script>\nfunction copyCommand(btn) {\n  const td = btn.parentElement.querySelector(\"td.kb_firewall\");\n  const text = td.innerText.trim();\n\n  navigator.clipboard.writeText(text).then(() => {\n    const msg = btn.parentElement.querySelector(\".copy-msg\");\n    msg.style.display = \"inline-block\";\n    setTimeout(() => msg.style.display = \"none\", 1000);\n  });\n}\n<\/script>","protected":false},"excerpt":{"rendered":"<p>When working with Linux, whether you\u2019re managing files, organizing projects, or cleaning up your servers, renaming folders is something you will need to do quite often. It might sound like a basic task, but if you are new to the command line, it can feel a little confusing at first. The good news is that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-3868","post","type-post","status-publish","format-standard","hentry","category-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Rename a Folder in Linux\u200b?<\/title>\n<meta name=\"description\" content=\"Learn how to rename a folder in Linux using simple commands easily with this step-by-step guide that explains common errors, examples, and best practices.\" \/>\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.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Rename a Folder in Linux\u200b?\" \/>\n<meta property=\"og:description\" content=\"Learn how to rename a folder in Linux using simple commands easily with this step-by-step guide that explains common errors, examples, and best practices.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html\" \/>\n<meta property=\"og:site_name\" content=\"Host IT Smart Knowledge base\" \/>\n<meta property=\"article:published_time\" content=\"2025-12-12T12:39:18+00:00\" \/>\n<meta name=\"author\" content=\"Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html\",\"name\":\"How to Rename a Folder in Linux\u200b?\",\"isPartOf\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\"},\"datePublished\":\"2025-12-12T12:39:18+00:00\",\"dateModified\":\"2025-12-12T12:39:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\"},\"description\":\"Learn how to rename a folder in Linux using simple commands easily with this step-by-step guide that explains common errors, examples, and best practices.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\",\"name\":\"Host IT Smart Knowledge base\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\",\"name\":\"Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"caption\":\"Admin\"},\"sameAs\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\"],\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Rename a Folder in Linux\u200b?","description":"Learn how to rename a folder in Linux using simple commands easily with this step-by-step guide that explains common errors, examples, and best practices.","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.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html","og_locale":"en_US","og_type":"article","og_title":"How to Rename a Folder in Linux\u200b?","og_description":"Learn how to rename a folder in Linux using simple commands easily with this step-by-step guide that explains common errors, examples, and best practices.","og_url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html","og_site_name":"Host IT Smart Knowledge base","article_published_time":"2025-12-12T12:39:18+00:00","author":"Admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html","name":"How to Rename a Folder in Linux\u200b?","isPartOf":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website"},"datePublished":"2025-12-12T12:39:18+00:00","dateModified":"2025-12-12T12:39:18+00:00","author":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108"},"description":"Learn how to rename a folder in Linux using simple commands easily with this step-by-step guide that explains common errors, examples, and best practices.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/485\/rename-folder-in-linux.html"]}]},{"@type":"WebSite","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/","name":"Host IT Smart Knowledge base","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108","name":"Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","caption":"Admin"},"sameAs":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/"],"url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/3868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/comments?post=3868"}],"version-history":[{"count":5,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/3868\/revisions"}],"predecessor-version":[{"id":3873,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/3868\/revisions\/3873"}],"wp:attachment":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/media?parent=3868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/categories?post=3868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/tags?post=3868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}