mkdir command on Linux (create directory) [Basic Guide]

The mkdir command on Linux creates one or more directories below the local directory. You must have permission to write to the directory to run mkdir.

The most common 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: Configures the permission of the created directory. Possible permissions are rxwrxwrxw (we’ll see later).
  • Examples:

Create the documents directory:

$ mkdir documents

Create the letters directory below the documents directory. If documents do not exist, create them first before the letters:

$ mkdir —p documents/letters

Creates the templates directory below the documents directory with read, write, and execute permissions for the directory owner, his group, and other users:

$ mkdir —m 777 documents/templates

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Need help?