The mkdir command is used to create a new directory.

mkdir new_directory

Note that if we specify a path with more than one directory, the entire path must exist in order for the deeper directory to be created.

If we want to create all the intermediate directories, we can use the -p flag.

mkdir dir/dir1/dir2

If dir and dir1 don’t exist, it will output an error mkdir: dir: No such file or directory

mkdir -p dir/dir1/dir2

This will create dir and dir1 if they don’t exist