How do you create a new directory?

Answer

Use the mkdir command. mkdir dirname creates a single directory. mkdir -p path/to/nested/dir creates the full path including all intermediate directories — the -p flag is very useful and prevents errors if the directory already exists. mkdir -m 755 dirname creates a directory with specific permissions. To create multiple directories at once: mkdir dir1 dir2 dir3. Example: mkdir -p /var/app/logs/2026 creates all directories in the chain.