Common Linux commands: mkdir and linuxmkdir

Source: Internet
Author: User

Common Linux commands: mkdir and linuxmkdir

Link: http://www.cnblogs.com/MartinChentf/p/6076075.html (reprinted please indicate the source)

In Linux, The mkdir command is used to create a directory or a cascading directory.

1. Command Format

Mkdir [Option] Directory Name

2. Command Options

-M =Mode

Specify the access permission for the directory, similar to chmod.

-P if the directory already exists, no error is prompted. If the parent directory does not exist, the parent directory is created. This option is often used to create a cascading directory.

-V displays prompt information for each directory.

3. Instance

Instance 1: Create the baklog directory in the current directory.

/home/dodv81>umask
0002
/home/dodv81>mkdir baklog/home/dodv81>lldrwxrwxr-x 2 dodv81 dodv81 4096 Nov 17 23:21 baklog/home/dodv81>mkdir baklogmkdir: cannot create directory `baklog': File exists

By default, the mkdir command creates a directory in the current directory without any options. The default permission of the directory is777-umask. If the directory already exists, an error is prompted.

Instance 2: create multiple directories.

/home/dodv81/baklog>mkdir cep dod testlog/home/dodv81/baklog>lscep  dod  testlog

Or multiple directories are enclosed by braces ({}) and separated by commas.

/home/dodv81/baklog>mkdir {cep,dod,testlog}/home/dodv81/baklog>lscep  dod  testlog

The following directory cannot be created:

/home/dodv81/baklog>mkdir {cep, dod, testlog}/home/dodv81/baklog>ls{cep,  dod,  testlog}

Instance 3: Create a cascading directory. Subdirectories in the same directory are placed in braces and separated by commas.

/home/dodv81>mkdir -p baklog/{bin,lib,lig/{cep,dod,testlog}}/home/dodv81>ls -R baklog/baklog/:bin  lib  ligbaklog/bin:baklog/lib:baklog/lig:cep  dod  testlogbaklog/lig/cep:baklog/lig/dod:baklog/lig/testlog:

Instance 4: Specify the permission for the directory. The specified permission isMode-umask. For example, if mode = rx, the final permission is 555-2 = 554, that is, rw-r --.

/Home/dodv81/baklog/bin> mkdir-m = r a -- read-only
/Home/dodv81/baklog/bin> mkdir-m = w B -- write only/home/dodv81/baklog/bin> mkdir-m = rw c -- Read/home/dodv81/ baklog/bin> mkdir-m = rx d -- read executable/home/dodv81/baklog/bin> mkdir-m = rwx e -- read and write executable/home/dodv81/baklog/ bin> lltotal 20dr -- r -- 2 dodv81 dodv81 4096 Nov 17 48 ad-w -- w ---- 2 dodv81 dodv81 4096 Nov 17 48 bdrw-rw-r -- 2 dodv81 dodv81 4096 Nov 17 cdr-xr-x 2 dodv81 dodv81 4096 Nov 17 48 ddrwxrwxr-x 2 dodv81 dodv81 4096 Nov 17 e

 

Instance 5: view the process information of creating a directory

/home/dodv81>mkdir -vp baklog/{bin,lib,lig/{cep,dod,testlog}}mkdir: created directory `baklog'mkdir: created directory `baklog/bin'mkdir: created directory `baklog/lib'mkdir: created directory `baklog/lig'mkdir: created directory `baklog/lig/cep'mkdir: created directory `baklog/lig/dod'mkdir: created directory `baklog/lig/testlog'

 

Common Linux commands: directories

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.