Linux mkdir Command: Create Directories and Subdirectories
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
That was just one piece. The course teaches the whole path — from your first command to exam day.