Mkdir

From LQWiki
Jump to navigation Jump to search

mkdir is the command used to create directories. To use it successfully, you need write access to the parent directory. The syntax is mkdir options dirname. The option -m specifies the mode (permissions) of the created directory and -p creates a directory tree with any necessary parent directories. For instance, mkdir -p parent/child creates both directories in a single operation. If the parent(s) already exist, there is no error. The -v option makes the operation more verbose.

Contrary to the misleading desktop metaphor, a directory is not really a 'folder'. A cardboard folder physically contains paper files. A directory does not contain its files, but is simply a special type of file that indexes other files (including other directories). It contains a list of names mapped to inode numbers which locate the files on disk.

A directory always contains at least the two entries: '.' (which refers to itself) and '..' (which refers to its parent). Unless it is the root directory on its volume, in which case its '..' refers to itself, just as '.' does.

Many people are used to using md as the command to make directories, so it is often aliased.

  alias md=mkdir    # In bash, etc.
  alias md mkdir    # In tcsh, etc.

Provided by

Most (all?) Linux distributions incorporate this from the GNU Coreutils: man page

Related Commands

  • link - Make hard links.
  • ln - Make hard or soft links
  • readlink - Make a canonical name.
  • rmdir - Remove empty directories.

See Also

External links

This article is a stub and needs to be finished. Plunge forward and help it grow!