Categories: File Management

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.

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.

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.