Name

mkdir — stdin  stdout  - file  -- opt  --help  --version

Synopsis

mkdir [options] directories

mkdir creates one or more directories:

mkdir directory1 directory2 directory3

Useful options

-p

Given a directory path (not just a simple directory name), create any necessary parent directories automatically. The command:

mkdir -p /one/two/three

creates the directories /one and /one/two if they don’t already exist, then /one/two/three.

-m mode

Create the directory with the given permissions (explained more fully with the chmod and umask commands in File Properties):

mkdir -m 0755 mydir

By default, your shell’s umask controls the permissions.

Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.