Methods to Use the mkdir Command in Linux

by | Nov 8, 2023 | Etcetera | 0 comments

mkdir is a fundamental command in Linux, used for creating directories all through the file system. Standing for ‘make checklist,’ this command allows consumers to construct a brand spanking new checklist at a specified path, enabling the crowd and keep watch over of files and folders. With quite a lot of alternatives similar to -p, which allows the creation of nested directories, and integration with permissions and protection contexts, mkdir provides flexibility in controlling the checklist development.

Whether or not or no longer you’re a system administrator or an extraordinary client, working out discover ways to use mkdir can be important for managing files and creating a well-organized file system.

Elementary syntax for mkdir command:

$ mkdir [OPTION...] [DIRECTORY...]
1.Display detailed wisdom of command
mkdir -v

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

Example:

Whilst you execute the mkdir -v newdir command in Linux, it creates a list named “newdir,” and the -v (verbose) risk tells it to turn a message describing what it’s doing. The usual output of this command would look something like this:

mkdir: created checklist 'newdir'
2.Create a couple of directories
mkdir [dir1] [dir2] [dir3]

Create a couple of directories via specifying the checklist names as command arguments, separated via spaces.

See also  Learn how to Set up Commercials in WordPress with AdRotate Plugin

Example:

The command mkdir newdir1 newdir2 newdir3 will create 3 new directories named newdir1, newdir2, and newdir3 throughout the provide working checklist. Maximum steadily, this command isn’t going to supply any output if it’s successful.

Should you run ls immediately after that command, you’ll want to see output like this, assuming there were no other files or directories throughout the provide checklist:

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

Use the -m (-mode) risk with the mkdir command to create a list with specific permissions.

Example:

Whilst you run the command mkdir -m 755 mydirectory, the newly created checklist named mydirectory could have the permissions set to 755. This means the owner could have be informed, write, and execute permissions, while the crowd and others could have be informed and execute permissions.

Proper right here’s a breakdown of the 755 permissions:

  • 7 (owner): Be informed (4) + Write (2) + Execute (1) = 7
  • 5 (workforce): Be informed (4) + Execute (1) = 5
  • 5 (others): Be informed (4) + Execute (1) = 5
4.Create checklist with SELinux context
mkdir -Z [dirname]

This option is used to set default SELinux (Protection-Enhanced Linux) rules for a specific checklist at creation time.

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

Use the -p risk with the mkdir command to create a whole checklist development.

Example:

Proper right here’s an example:

mkdir -p /path/to/your/checklist/tree

This command will create all of the checklist path if it does no longer exist. If any part of the path (/path/to/your/checklist) is missing, it’s going to be created, along with the entire tree checklist. If the directories already exist, mkdir -p isn’t going to file an error, and no changes shall be made to offer directories.

See also  Will Entrepreneurs Proceed to Use Twitter in 2023? [New Data]
Further Linux directions:
List Operations rmdir · cd · pwd · exa · ls
Record Operations cat · cp · dd · much less · contact · ln · rename · extra · head
Record Instrument Operations chown · mkfs · find
Networking ping · curl · wget · iptables · mtr
Search and Text Processing to find · grep · sed · whatis · ripgrep · fd · tldr
Instrument Wisdom and Keep watch over env · historical past · best · who · htop · glances · lsof
Shopper and Session Keep watch over display screen · su · sudo · open

The put up Methods to Use the mkdir Command in Linux seemed first on Hongkiat.

WordPress Website Development

Supply: https://www.hongkiat.com/blog/linux-command-mkdir/

[ continue ]

WordPress Maintenance Plans | WordPress Hosting

read more

0 Comments

Submit a Comment

DON'T LET YOUR WEBSITE GET DESTROYED BY HACKERS!

Get your FREE copy of our Cyber Security for WordPress® whitepaper.

You'll also get exclusive access to discounts that are only found at the bottom of our WP CyberSec whitepaper.

You have Successfully Subscribed!