Create A Directory
Part of the Fundamentals section of Coddy's Terminal journey — lesson 16 of 82.
The mkdir command stands for make directory. It creates a new folder in your current location.
Simply type mkdir followed by the name of the folder you want to create:
mkdir projectsYou can confirm it was created by running ls:
ls
documents
projects
readme.txtCreating multiple directories at once:
You can create several folders in a single command by listing them separated by spaces:
mkdir projects documents backupsCreating nested directories:
Use the -p flag to create a directory and all its parent directories at once:
mkdir -p projects/app/srcWithout -p, this would fail if projects or app don't already exist. With -p, all three folders are created automatically.
Note: Directory names follow the same rules as file names — avoid spaces and special characters. Use hyphens or underscores instead:
mkdir my-project # ✅ good
mkdir my_project # ✅ good
mkdir my project # ❌ creates two folders: my and projectChallenge
BeginnerCreate a new directory called projects in your current location, then use ls to confirm it was created.
Hint: Use the
mkdircommand followed by the directory name.
Cheat sheet
The mkdir command creates a new directory:
mkdir projectsCreating multiple directories:
mkdir projects documents backupsCreating nested directories with -p flag:
mkdir -p projects/app/srcThe -p flag creates all parent directories automatically if they don't exist.
Naming conventions: Use hyphens or underscores instead of spaces:
mkdir my-project # ✅ good
mkdir my_project # ✅ good
mkdir my project # ❌ creates two foldersTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Directories
Create A DirectoryCopy A DirectoryMove And Rename A DirectoryDelete A DirectoryRecap - Directory Operations7File Content
Head And TailWord CountSort CommandUnique CommandGrep BasicsGrep With FlagsRecap - Text Detective2Navigation
Print Working DirectoryList FilesChange DirectoryAbsolute vs Relative PathsHome And Root DirectoryRecap - Find Your Way8Redirection
Standard OutputOverwrite To A FileAppend To A FileStandard InputStandard ErrorRecap - Log Builder6Wildcards And Patterns
The Star WildcardThe Question Mark WildcardBracket WildcardsCombining WildcardsRecap - Selective Operations9Piping
What Is A PipeChaining Two CommandsChaining Multiple CommandsPipe With GrepRecap - Data Pipeline