How do you create a new directory?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Linux / Shell Scripting development. It reveals whether you understand the building blocks that more complex concepts rely on.
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.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Linux / Shell Scripting answers easy to follow.