mkdir [directory name] if you would like to create a directory in the name ‘myproject’ type mkdir myproject
$ mkdir myproject
mkdir <dirname1> <dirname2> <dirname3> ...
mkdir newdir
To create a new directory in another location, you’ll need to provide the parent directory’s absolute or relative file path. For example, to create a new directory in the /tmp
directory you would type.
mkdir /tmp/newdir
If you try to create a directory in a parent directory where the user does not have sufficient permissions, you will receive Permission denied
error
mkdir /root/newdir
mkdir: cannot create directory '/root/newdir': Permission denied
you want to create a directory /home/linuxize/Music/Rock/Gothic.
mkdir /home/linuxize/Music/Rock/Gothic
If any of the parent directories don’t exist, you will get an error as shown below:
mkdir: cannot create directory '/home/linuxize/Music/Rock/Gothic': No such file or
When the -p
option is used, the command creates the directory only if it doesn’t exist.
mkdir -p /home/linuxize/Music/Rock/Gothic
we’re creating a new directory with 700
permissions, which means that only the user who created the directory will be able to access it
mkdir -m 700 newdir
The mkdir
command also allows you to create a complex directory tree with one command
mkdir -p Music/{Jazz/Blues,Folk,Disco,Rock/{Gothic,Punk,Progressive},Classical/Baroque/Early}
mkdir foldername
To create a folder named ‘newfolder‘ the command
mkdir newfolder
create multiple directories hierarchy(creating folder and sub folders with a single command) using mkdir command.
mkdir folder1\folder2\folder3.
You need to have permission to create a folder for the command to work. Not having permission to create a folder would throw up an ‘access denied’ error.
C:\Users>mkdir c:\Windows\System32\test
Access is denied.
If there exists a file or folder with the same name, the command throws up error.
C:\>md test
A subdirectory or file test already exists.
If the name needs to have space within, you should enclose it in double-quotes.
For example, to create a folder with the name ‘My data’, the command would be
c:\>mkdir "my data"