May 12, 2010, 9:56 AM — Most people learn the mkdir command on the first day they start using Unix. Along with ls, cd and pwd, it's in the set of the most basic commands that everyone who ventures onto the command line on a Unix system ought to know. It generally takes a while before they learn the more exotic uses of this simple command -- such a creating a branching tree structure with just one mkdir.
The simplest form of the mkdir command is, of course, creating a single directory.
As novice Unix users begin to pick up relative addressing and environment variables, they will probably figure out that they can take their directory creating skills a little further and may try commands such as these -- creating a directory inside an existing directory (without moving into the directory first), creating a directory in their home no matter where they're starting from, creating a directory in the parent directory, creating temporary directories (with or without randomized names) and creating a directory using the output of Unix commands to name them.
mkdir mydir/newdir mkdir ~/mydir mkdir ../mydir mkdir /tmp/$USER mkdir /tmp/$USER$$ mkdir `date +%m%d%y`
Sometime later, new Unix users will likely run into the -p option that allows them to create deeply embedded directories without first having to create all the intermediate folders. Ah, the joy of Unix!
mkdir -p mydir/a/b/c/d/e
It isn't until the mkdir command is combined with brace expansion that things get really exciting (and a little hard to parse!).