mkdir is used to create new directories.
mkdir automatically makes the following standard entries in the new directory:
. | (dot) | for the directory itself |
.. | (dot dot) | for the parent directory |
To be able to use mkdir you have to have write permission in the parent directory.
Syntax
mkdir[ -m modus][ -p] directory ... |
No option specified mkdir creates the named directories in mode 777 (see section “chmod change file modes”) unless the umask command has been used to change the
(mode) The access permissions specified in mode are used for the new directory (see section “chmod change file modes”).
(parent) mkdir creates any non-existing parent directories that are given in the path name of directory before creating the directory itself.
Name of the directory that you wish to create. You can also create more than one directory at a time. directory can be given either as a relative path name or as an absolute path name. The user ID and the group ID of the new directory are set to the real user ID and real group ID of the calling process. |
Exit status
0 | If all directories given in the command line were made successfully. |
>0 | If an error occurs. mkdir also prints an error message. |
Locale
The following environment variables affect the execution of mkdir: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example
Creating a new directory named letters in the directory /home/sisyphus/general:
Next you list the contents of this directory:
Then you create the new directory:
Finally you check whether a directory named letters has been created:
|
See also
rm, rmdir, umask |