mkdir
The shell command that makes a new directory; with -p it also makes missing parent directories and does not complain if the directory already exists.
In more detail
The -p flag makes mkdir safe to repeat, because it does not fail when the directory already exists. It creates an empty folder and nothing else.
Examples
mkdir -p by-handThe Ansible file module with state: directory is the idempotent equivalent and reports whether it changed anything.mkdir -p project/src/libmkdir my-project && cd my-project && git initRelated terms
- file module — The module that makes sure a file, directory or link exists or is absent, with the owner and permissions you ask for.
- shell script — A text file of shell commands that runs them in order, top to bottom, as if you had typed them one by one.
- rmdir — The command that removes a directory only if it is empty.
- touch command — The command that creates an empty file if it does not exist, or updates the modification time of one that does.
- idempotency — The property of an operation that gives the same result whether you run it once or many times, because a repeat run finds nothing left to do.
Taught in
- What Configuration Management Is — Ansible Configuration Management at Scale
- Making, Copying, Moving And Removing — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- Permissions And Ownership — Bash Scripting & Command Line Automation
- find And xargs — Bash Scripting & Command Line Automation
- Archives, Transfers And The Network — Bash Scripting & Command Line Automation
- Immutable Containers: Read-Only At Runtime — Certified Kubernetes Security Specialist (CKS) Exam Prep
- A Repository Is A Folder With A Memory — Advanced Git Internals & Distributed Workflows
- Down Until Morning: Unit Files, Drop-ins, Masks And systemd's Helpers — CompTIA Linux+ (XK0-006) Exam Prep
- Deploying Files: file, copy, lineinfile And blockinfile — RHCE in Ansible (EX294): Automate Red Hat Systems