mkdir is a basic command in Linux, used for developing directories throughout the document gadget. Status for ‘make listing,’ this command permits customers to build a brand new listing at a specified trail, enabling the group and control of recordsdata and folders. With more than a few choices comparable to -p, which permits the introduction of nested directories, and integration with permissions and safety contexts, mkdir supplies flexibility in controlling the listing construction.

Whether or not you’re a gadget administrator or an ordinary consumer, figuring out learn how to use mkdir may also be necessary for managing recordsdata and making a well-organized document gadget.

Basic syntax for mkdir command:

$ mkdir [OPTION...] [DIRECTORY...]
1.Show detailed knowledge of command
mkdir -v

Use the -v (verbose) way to see what the mkdir command is doing within the background.

Instance:

While you execute the mkdir -v newdir command in Linux, it creates a listing named “newdir,” and the -v (verbose) possibility tells it to show a message describing what it’s doing. The standard output of this command would glance one thing like this:

mkdir: created listing 'newdir'
2.Create more than one directories
mkdir [dir1] [dir2] [dir3]

Create more than one directories through specifying the listing names as command arguments, separated through areas.

Instance:

The command mkdir newdir1 newdir2 newdir3 will create 3 new directories named newdir1, newdir2, and newdir3 within the present operating listing. Most often, this command is not going to produce any output if it’s a hit.

In case you run ls right away after that command, you could see output like this, assuming there have been no different recordsdata or directories within the present listing:

newdir1  newdir2  newdir3
3.Set listing permissions
mkdir -m [permission] [dir]

Use the -m (-mode) possibility with the mkdir command to create a listing with particular permissions.

Instance:

While you run the command mkdir -m 755 mydirectory, the newly created listing named mydirectory may have the permissions set to 755. This implies the landlord may have learn, write, and execute permissions, whilst the gang and others may have learn and execute permissions.

Right here’s a breakdown of the 755 permissions:

  • 7 (proprietor): Learn (4) + Write (2) + Execute (1) = 7
  • 5 (staff): Learn (4) + Execute (1) = 5
  • 5 (others): Learn (4) + Execute (1) = 5
4.Create listing with SELinux context
mkdir -Z [dirname]

This feature is used to set default SELinux (Safety-Enhanced Linux) regulations for a particular listing at introduction time.

5.Create multi-level directories
mkdir -p [directory_tree]

Use the -p possibility with the mkdir command to create an entire listing construction.

Instance:

Right here’s an instance:

mkdir -p /trail/to/your/listing/tree

This command will create all the listing trail if it does now not exist. If any a part of the trail (/trail/to/your/listing) is lacking, it’s going to be created, at the side of the overall tree listing. If the directories exist already, mkdir -p is not going to document an error, and no adjustments will likely be made to present directories.

Extra Linux instructions:
Listing Operations rmdir · cd · pwd · exa · ls
Report Operations cat · cp · dd · much less · contact · ln · rename · extra · head
Report Device Operations chown · mkfs · find
Networking ping · curl · wget · iptables · mtr
Seek and Textual content Processing to find · grep · sed · whatis · ripgrep · fd · tldr
Device Knowledge and Control env · historical past · best · who · htop · glances · lsof
Consumer and Consultation Control display screen · su · sudo · open

The submit Methods to Use the mkdir Command in Linux gave the impression first on Hongkiat.

WordPress Website Development Source: https://www.hongkiat.com/blog/linux-command-mkdir/

[ continue ]