mkdir Command

Create the DIRECTORY(ies), if they do not already exist. Basic Usage:
mkdir directory

Examples:
mkdir aaa
It makes new aaa folder. If there is aaa folder, it gives warning.


mkdir bbb ccc
It makes bbb and ccc folders.

mkdir -p asa/asa1/asa2
-p veya --parents : no error if existing, make parent directories as needed

mkdir -p aa1/{bb1/cc1/{dd1,dd2,dd3},bb2,bb3,bb4}
aa1 aa1/bb1,bb2,bb3,bb4 aa1/bb1/cc1 aa1/bb1/cc1/dd1,dd2,dd3

mkdir -m 754 aaa veya mkdir -m o=+r,g=+rx aaa
Grub has reading and execute rights and others have only reading right.
-m mode or --mode=mode:
set file mode (as in chmod), not a=rwx - umask
You can set authority with + symbol for each user by letters if you wish. u is user; g is group; o is others.
r: reading; x:execution; w:writing.
r=4, x=1, w=2 for encoding
0: no authority.
Description made with three numbers. 7 is owner rights, 5 is grub rights, 4 is others rights for 754. 7 = 4+2+1 (Owner has all rights). 5=4+1 (it means reading and execution rights). 4 is giving only reading right. You can fix user rights with 4,2,1 numbers and adding.
Above command makes aaa folder.Owner has all rights.

mkdir -m 777 aaa
mkdir -m + aaa
mkdir -m - aaa
Each of above three commands makes aaa folder. Owner, grub and others have all rights.

mkdir -m g=+ aaa
mkdir -m g=-w
mkdir -m g=-wr
Each of above three commands owner and others have all rights, but grub hasn't.

mkdir -m g=+r aaa
Grub(g) has only reading(r) right. User(u) and others(o) have all rights.

mkdir -m o=+x aaa
User(u) and grub(g) have all rights. Others have anly execution right.

mkdir -m o=+x,g=+rx aaa
We set grub and others rights for aaa directory.

mkdir -m u=+rx,o=+x,g=+rx aaa
We can set rights for each user one by one as above command.

mkdir --mode=700 aaa
User has all rights, but Grup and others have nothing.

mkdir --mode=u=+rx,o=+x,g=+rx aaa
--mode parameter like -m parameter for setting rights.

mkdir --help
Display help page.
mkdir --version
Display version info.


Above process applied on "GNU bash, version 4.3.11(1)-release (i686-pc-linux-gnu)"
Date of Article: 10.03.2016




HOME GNU/LINUX Commands TURKISH