mkdir
making roommkdir creates a directory. By default the parent has to exist already and the name must be free; -p removes both conditions, creating every missing level and staying quiet if the directory is already there — which is why scripts almost always use it.
mkdir -p means "make sure this path exists" — safe to run once or a hundred times.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
The first command already created site, assets and img in one go and printed nothing. Asking again without -p fails.
A new directory asks for rwxrwxrwx and the umask of 022 removes write for group and others, leaving rwxr-xr-x.
The directory never exists with looser permissions, even for a moment — better than mkdir followed by chmod.
drwx------ shuts out the group and everyone else entirely.
Switches
A switch changes how the command behaves. These are the ones used day to day; man mkdir lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-p- Parents: create any missing directories along the path, and do not complain if it already exists.
-v- Verbose: print a line for each directory created.
-m MODE- Set the permissions at creation, for example -m 700.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
mkdir -p logs/{app,nginx,db}Brace expansion: three subdirectories in one command.
mkdir -pv a/b/cPrints a line for each directory it actually had to create.
mkdir -m 700 ~/.sshThe mode SSH insists on for its configuration directory.
rmdir empty-dirRemoves a directory only if nothing is inside it — a safe way to tidy up.
In cybersecurity
A directory's permissions decide who can create, rename and delete the files in it — regardless of what the files themselves allow.
Anyone with write permission on a directory can delete or replace files in it, even files they cannot read.
For anything sensitive use -m 700 at creation. Tightening afterwards leaves a window where it was open.
A predictable directory name under /tmp can be created first by another user. Use mktemp -d instead.