The mkdir command is used to make a directory. In this example, the "foo" directory is created.
The ls (list) command with the -l (long) option can be used to view the standard permissions and ownership of the newly created directory. By default, the standard permissions of a newly created directory will be drwxr-xr-x. The "d" indicates it is a directory. Additionally, the directory will be owned by the user that created the directory (root in this example).
ls -l /tmp . . . drwxr-xr-x 1 root root 4096 Sep 18 19:02 foo
Permission denied will be displayed if you do not have write permission to the parent directory. For example, let's say you want to create a directory under /opt. In this example, only root has write permission to the /opt directory. In other words, only root will be able to create a directory under /opt. All other users will get permission denied.
This can be resolved by giving sudo permission to the mkdir command.
ls -ld /opt . . . drwxr-xr-x 1 root root 4096 Sep 18 13:49
The -p or --parents option can be used to create parent directories (if they do not exist). In this example, the "foo" and "bar" directories will be created if they do not exist. Without the -p or --parents option, if a subdirectory does not exist (foo in this example), then the target directory (bar in this example) would not be created.
mkdir --parents /tmp/foo/bar