{
    "mode": "info",
    "parameter": "mkdir",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/mkdir/json",
    "generated": "2026-11-15T15:00:25Z",
    "sections": {
        "File: coreutils.info,  Node: mkdir invocation,  Next: mkfifo invocation,  Prev: ln invocation,  Up: Special file types": {
            "content": "",
            "subsections": [
                {
                    "name": "12.3 'mkdir': Make directories",
                    "content": "'mkdir' creates directories with the specified names.  Synopsis:\n\nmkdir [OPTION]... NAME...\n\n'mkdir' creates each directory NAME in the order given.  It reports\nan error if NAME already exists, unless the '-p' option is given and\nNAME is a directory.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-m MODE'\n'--mode=MODE'\nSet the file permission bits of created directories to MODE, which\nuses the same syntax as in 'chmod' and uses 'a=rwx' (read, write\nand execute allowed for everyone) for the point of the departure.\n*Note File permissions::.  This option affects only directories\ngiven on the command line; it does not affect any parents that may\nbe created via the '-p' option.\n\nNormally the directory has the desired file mode bits at the moment\nit is created.  As a GNU extension, MODE may also mention special\nmode bits, but in this case there may be a temporary window during\nwhich the directory exists but its special mode bits are incorrect.\n*Note Directory Setuid and Setgid::, for how the set-user-ID and\nset-group-ID bits of directories are inherited unless overridden in\nthis way.\n\n'-p'\n'--parents'\nMake any missing parent directories for each argument, setting\ntheir file permission bits to '=rwx,u+wx', that is, with the umask\nmodified by 'u+wx'.  Ignore existing parent directories, and do not\nchange their file permission bits.\n\nIf the '-m' option is also given, it does not affect file\npermission bits of any newly-created parent directories.  To\ncontrol these bits, set the umask before invoking 'mkdir'.  For\nexample, if the shell command '(umask u=rwx,go=rx; mkdir -p P/Q)'\ncreates the parent 'P' it sets the parent's file permission bits to\n'u=rwx,go=rx'.  (The umask must include 'u=wx' for this method to\nwork.)  To set a parent's special mode bits as well, you can invoke\n'chmod' after 'mkdir'.  *Note Directory Setuid and Setgid::, for\nhow the set-user-ID and set-group-ID bits of newly-created parent\ndirectories are inherited.\n\n'-v'\n'--verbose'\nPrint a message for each created directory.  This is most useful\nwith '--parents'.\n\n'-Z'\n'--context[=CONTEXT]'\nWithout a specified CONTEXT, adjust the SELinux security context\naccording to the system default type for destination files,\nsimilarly to the 'restorecon' command.  The long form of this\noption with a specific context specified, will set the context for\nnewly created files only.  With a specified context, if both\nSELinux and SMACK are disabled, a warning is issued.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n"
                }
            ]
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}