Skip to content

mkdir command on Linux (create directory)

The mkdir command on Linux creates one or more directories below the local directory. You must have permission to write to the directory to run mkdir.

The most common options are:

  • -p: Creates the specified directory even if the parent directory does not exist. In this case, it also creates the parent directory;
  • -m: Configures the permission of the created directory. Possible permissions are rxwrxwrxw (we’ll see later).
  • Examples:

Create the documents directory:

$ mkdir documents

Create the letters directory below the documents directory. If documents do not exist, create them first before the letters:

$ mkdir —p documents/letters

Creates the templates directory below the documents directory with read, write, and execute permissions for the directory owner, his group, and other users:

$ mkdir —m 777 documents/templates