mkdir Command: Tutorial & Examples
Create a new directory
The mkdir
command is a utility in Linux that allows you to create directories (also known as folders).
Here is the basic syntax for using mkdir:
mkdir [options] directory
The directory
argument is the name of the directory that you want to create.
Here are some common options for mkdir
:
-m mode
: Specifies the permissionsmode
for the new directory.-p
: Creates any missing intermediate directories in the specified path.
Here is an example of using mkdir
to create a new directory named mydir
:
mkdir mydir
This command will create a new directory with the default permissions mode.
To create a new directory with specific permissions, you can use the -m
option, like this:
mkdir -m 755 mydir
This command will create a new directory named mydir
with permissions set to 755
, which allows the owner to read, write, and execute the directory, and allows everyone else to
read and execute the directory.
To create a directory and any intermediate directories in the specified path, you can use the -p
option, like this:
mkdir -p /path/to/new/dir
This command will create the dir
directory and any intermediate directories that do not already exist in the specified path.