mkdir - make directories
mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
TAG | DESCRIPTION |
---|---|
-m, --mode=MODE | set file mode (as in chmod), not a=rwx - umask |
-p, --parents | no error if existing, make parent directories as needed |
-v, --verbose | print a message for each created directory |
-Z, --context=CTX | set the SELinux security context of each created directory to CTX |
--help | display this help and exit |
--version | output version information and exit |
--kernelargs args | Adds args to the arguments appended on the kernel command line. If this is not specified mkbootdisk uses grubby to parse the arguments for the default kernel from grub.conf, if possible. |
--size size | Uses size (in kilobytes) as the size of the image to use for the boot disk. If this is not specified, mkbootdisk will assume a standard 1.44Mb floppy device. |
Example-1:
Creates a new directory called mydir whose parent is the current directory.
$ mkdir mydir
output:
$ls
mydir
Example-2:
Create the mydir directory, and set its permissions such that all users may read, write, and execute the contents.
$ mkdir -m a=rwx mydir
output:
# ls -l
total 24
-rw-r--r-- 1 ubuntu ubuntu 212 Jan 8 12:43 file.txt
drwxrwxrwx 2 root root 4096 Jan 8 15:27 mydir
Example-3:
How to create multiple directories at one time:
$ mkdir test1 test2 test3
output:
$ls
test1 test2 test3
Example-4:
How to create several subdirectories at one time:
$ mkdir -p /home/test/test1/test2/test3/test4
output:
# ls -R /home/test/
/home/test/:
test1
/home/tutor/test1:
test2
/home/tutor/test1/test2:
test3
/home/tutor/test1/test2/test3:
test4
/home/tutor/test1/test2/test3/test4: