fbpx Linux mkdir Command: Create Directories (mkdir -p and -m) | Certificação Linux

Linux mkdir Command: Create Directories and Subdirectories

📅 01/01/2019 ⏱ 1 min ✍️ Uira Ribeiro
Linuxcommands
Linux mkdir Command: Create Directories and Subdirectories
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

The mkdir command in Linux creates one or more directories under the current directory. You need write permissions on the directory to execute mkdir.

The most frequent options are:

  • -p: Creates the specified directory even if the parent directory does not exist. In this case, it also creates the parent directory;
  • -m: Sets the permission of the created directory. The possible permissions are rxwrxwrxw (we will see more later).
  • Examples:

Creates the documentos directory:

$ mkdir documentos

Creates the cartas directory under the documentos directory. If documentos does not exist, it creates it first before cartas:

$ mkdir –p documentos/cartas

Creates the modelos directory under the documentos directory with read, write, and execute permissions for the directory owner, its group, and other users:

$ mkdir –m 777 documentos/modelos

Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.

Liked it? Share

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp