Last login: Tue 13 Oct 2026 on tty1
Archived edition.
Ten things the page says. Every one of them is on your machine right now — run the command above and check.
Create the DIRECTORY(ies), if they do not already exist.[man]
set file mode (as in chmod), not a=rwx - umask.[man]
no error if existing, make parent directories as needed, with their file modes unaffected by any -m option.[man]
set SELinux security context of each created directory to the default type.[man]
like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX.[man]
Mandatory arguments to long options are mandatory for short options too.[man]
mkdir creates directories with the specified names.[info]
mkdir creates each directory NAME in the order given.[info]
It reports an error if NAME already exists, unless the -p option is given and NAME is a directory.[info]
'-m MODE' --mode=MODE Set the file permission bits of created directories to MODE, which uses the same syntax as in 'chmod' and uses 'a=rwx' (read, write and execute allowed for everyone) for the point of the departure. .[info]
Build a whole tree in one call
-p is what makes mkdir safe to run twice, which is what makes it usable inside a script.
These commands write files, so run them in a scratch directory:
$ mkdir -p ~/motd-lab && cd ~/motd-lab
$ mkdir -p project/src/lib
$ mkdir -p project/src/lib
$ mkdir -v -m 700 private
$ ls -ld private
$ find project -type d
WHAT YOU SHOULD SEEThe second mkdir -p succeeds silently instead of erroring. private is created as drwx------. find lists all four directories.
Five questions, each one taking a term out of a line above. Ten points for each. Tap hear it to have a question read to you; answering plays the verdict.
QUESTION 1 OF 5
Which term completes this line from the page? “Create the _____(ies), if they do not already exist.”
From point 1 above.
QUESTION 2 OF 5
Which term completes this line from the page? “no error if existing, make parent _____ as needed, with their file modes unaffected by any -m option.”
From point 3 above.
QUESTION 3 OF 5
Which term completes this line from the page? “like -Z, or if CTX is specified then set the SELinux or _____ security context to CTX.”
From point 5 above.
QUESTION 4 OF 5
Which term completes this line from the page? “mkdir _____ directories with the specified names.”
From point 7 above.
QUESTION 5 OF 5
Which term completes this line from the page? “It _____ an error if NAME already exists, unless the -p option is given and NAME is a directory.”
From point 9 above.
Answer all five to bank your points.
Five chapters, three voices. Tap one to jump — the player at the bottom of the screen follows.
Know someone with ten minutes and a terminal? Send them today's page. This is the card that appears when you post it:
The Operator has a dispatch on mkdir(1),
and he files them for subscribers only. It is free.
Join the club, or read about
the series.
MOTD is a weekday reading of one manual page already installed on your own
machine. Every statement is quoted from that page or from the GNU info
documentation beside it, and every edition names the command that shows you
the source.
archive ·
the operator ·
about ·
podcast ·
Feline Union