{"id":3208,"date":"2025-02-19T19:16:52","date_gmt":"2025-02-19T19:16:52","guid":{"rendered":"https:\/\/foghosting.com\/how-to-create-a-directory-in-linux-with-mkdir-command\/"},"modified":"2025-02-19T19:16:52","modified_gmt":"2025-02-19T19:16:52","slug":"how-to-create-a-directory-in-linux-with-mkdir-command","status":"publish","type":"post","link":"https:\/\/foghosting.com\/blog\/how-to-create-a-directory-in-linux-with-mkdir-command\/","title":{"rendered":"How to Create a Directory in Linux with mkdir Command?"},"content":{"rendered":"<div id=\"content\">\n<div role=\"main\">\n<div>\n<figure><\/figure>\n<\/div>\n<div>\n<h2><span id=\"Introduction\">Introduction<\/span><\/h2>\n<p>Directories in Linux serve as containers for organizing and storing files and other directories. Much like folders in a filing cabinet, directories help users maintain a structured and orderly file system, making it easier to locate and manage files efficiently. The \u201cmkdir\u201d command, short for \u201cmake directory,\u201d is a fundamental tool in Linux that allows users to create new directories quickly and easily. This article will delve into the functionality of the \u201cmkdir\u201d command in Linux, explaining its syntax and demonstrating how to create both single and multiple directories using this command. By understanding the basics of the <strong>mkdir command<\/strong>, users can effectively organize their file systems and streamline their workflow in Linux environments.<\/p>\n<h2><span id=\"In_Linux_What_is_the_mkdir_Command\">In Linux, What is the mkdir Command?<\/span><\/h2>\n<figure><\/figure>\n<p>In Linux, the \u201cmkdir\u201d command stands for \u201cmake directory.\u201d It\u2019s like giving a command to create a new folder or directory on your computer. Just as you might create a new folder on your desktop to keep your files organized, the \u201cmkdir\u201d command does the same thing in the Linux operating system. When you use the \u201cmkdir\u201d command followed by the name you want to give to your new directory, Linux creates that directory for you. For example, if you type \u201cmkdir documents\u201d into the command line and press enter, Linux will create a new directory named \u201cdocuments\u201d in your current location. This command helps you organize your files and keep your computer tidy by creating new folders wherever you need them.<\/p>\n<figure><\/figure>\n<p>The syntax of the \u201cmkdir\u201d command in Linux refers to the specific structure and format that the command follows when used in the terminal. The basic syntax of the \u201cmkdir\u201d command is \u201cmkdir [options] [directory_name].\u201d Here\u2019s what each part of the syntax means:<\/p>\n<ul>\n<li>\u201cmkdir\u201d: This is the actual command that tells Linux to create a new directory.<\/li>\n<\/ul>\n<figure><\/figure>\n<ul>\n<li>\u201c[options]\u201d: These are additional settings or parameters that you can include to modify the behavior of the \u201cmkdir\u201d command. Some common options include \u201c-p\u201d to create<\/li>\n<li><\/li>\n<li>\u00a0parent directories if they don\u2019t exist and \u201c-v\u201d to display a message for each directory created.<\/li>\n<\/ul>\n<figure><\/figure>\n<ul>\n<li>\u201c[directory_name]\u201d: This is the name of the directory you want to create. You can replace \u201c[directory_name]\u201d with the name you want to give to your new directory.<\/li>\n<\/ul>\n<h2><span id=\"How_to_Create_a_New_Directory_In_Linux\">How to Create a New Directory In Linux?<\/span><\/h2>\n<ol>\n<li>Open a terminal on your Linux system. You can usually find the terminal application in the system\u2019s applications menu.<\/li>\n<\/ol>\n<p>Once you have the terminal open, navigate to the location where you want to create the new directory. You can use the \u201ccd\u201d command to change directories. For example, if you want to create the new directory in your home directory, you can use the following command \u201ccd ~<\/p>\n<p>Now, use the \u201cmkdir\u201d command followed by the name you want to give to your new directory. For example, if you want to create a directory named \u201cdocuments,\u201d you can use the following command \u201cmkdir documents.\u201d This will create a new directory named \u201cdocuments\u201d in your current location.<\/p>\n<h2><span id=\"Using_mkdir_How_to_Create_Multiple_Directories\">Using mkdir How to Create Multiple Directories<\/span><\/h2>\n<p>To create multiple directories at once using the mkdir command in Linux, you can specify the names of the directories you want to create separated by spaces. Here\u2019s how you can do it, use the command \u201cmkdir directory1 directory2 directory3.\u201d<\/p>\n<p>Note \u2013 Replace \u201cdirectory1\u201d, \u201cdirectory2\u201d, and \u201cdirectory3\u201d with the names of the directories you want to create.<\/p>\n<figure><\/figure>\n<h2><span id=\"How_to_Create_Parent_Directories\">How to Create Parent Directories?<\/span><\/h2>\n<p>To create parent directories along with a new directory in Linux, you can use the \u201c-p\u201d option with the \u201cmkdir\u201d command. This option ensures that all parent directories leading up to the specified directory are created if they don\u2019t already exist. Here\u2019s how you can do it, use the following command:\u00a0<\/p>\n<pre><code>mkdir -p \/path\/to\/parent\/directory\/newdirectory<\/code><\/pre>\n<figure><\/figure>\n<p>Replace \u201c\/path\/to\/parent\/directory\/newdirectory\u201d with the desired path for the new directory.<\/p>\n<h2><span id=\"How_to_Set_Permissions_When_Making_a_Directory\">How to Set Permissions When Making a Directory?<\/span><\/h2>\n<figure><\/figure>\n<p>When creating a directory in Linux using the mkdir command, you can simultaneously set permissions for the directory using the chmod command.<\/p>\n<p><strong>Using Numeric Mode:<\/strong><\/p>\n<p>You can specify permissions using numeric mode with chmod. The numeric mode represents permissions for the user, group, and others, respectively.<\/p>\n<p>For example, to create a directory with read, write, and execute permissions for the user, and read and execute permissions for the group and others, you can use:<\/p>\n<pre><code>mkdir new_directory<\/code><\/pre>\n<pre><code>chmod 755 new_directory<\/code><\/pre>\n<figure><\/figure>\n<p><strong>Combining mkdir and chmod:<\/strong><\/p>\n<p>You can combine the mkdir and chmod commands using the &#038;&#038; operator to create a directory and set permissions in a single line.<\/p>\n<pre><code>mkdir new_directory && chmod 755 new_directory<\/code><\/pre>\n<p>Note \u2013 this is an example.<\/p>\n<p>Also Read: Linux Commands Cheat Sheet: Advanced Techniques<\/p>\n<h2><span id=\"Conclusion\">Conclusion\u00a0<\/span><\/h2>\n<p>The \u201cmkdir\u201d command in Linux serves as a fundamental tool for creating directories or folders, facilitating the organization and management of files within the operating system. By understanding its syntax and functionality, users can efficiently create single or multiple directories, create parent directories, and even set permissions for directories during creation. Whether organizing personal files or managing system directories, the \u201cmkdir\u201d command empowers users to maintain a structured and orderly file system in Linux environments. By leveraging the flexibility and versatility of the \u201cmkdir\u201d command, users can enhance their productivity and streamline their workflow in Linux.<\/p>\n<\/p><\/div>\n<div>\n<div>\n<h3>Arpit Saini<\/h3>\n<p>\n\t\t\t\t\tHe is the Director of Cloud Operations at Fog Hostig and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.\t\t\t\t<\/p>\n<\/p><\/div><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Directories in Linux serve as containers for organizing and storing files and other directories. Much like folders in a filing cabinet, directories help users maintain a structured and orderly file system, making it easier to locate and manage files efficiently. The \u201cmkdir\u201d command, short for \u201cmake directory,\u201d is a fundamental tool in Linux that<\/p>\n","protected":false},"author":3,"featured_media":3076,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[17],"tags":[],"class_list":["post-3208","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dedicated-servers"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/comments?post=3208"}],"version-history":[{"count":0,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3208\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media\/3076"}],"wp:attachment":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media?parent=3208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/categories?post=3208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/tags?post=3208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}