Sunday, 29 January 2012


mkdir  is used to create  one or more directories. It can create entire directory structure if needed, or can give required permissions to a directory.

Example1)To  simply create a directory or a directory structure.
/home/MUM-user$ mkdir  channels
you further want to create directory structures. The conventional method of doing it would be
/home/MUM-user$cd channels
/home/MUM-user/ channels$mkdir  STAR
/home/MUM-user/ channels$mkdir  SONY
/home/MUM-user/ channels$cd SONY
/home/MUM-user/ channels/ SONY$mkdir  KBC
i:e create all the individual directories in the tree.
mkdir provides an option –p to  help you to avoid  these commands.

/home/MUM-user$mkdir  -p  channels/ STAR/NGC/Speed
/home/MUM-user$ mkdir  -p  channels/ SONY/ KBC

These commands  will  create all the intermediate parent directories and the final directory.

Example 2)
To change  permissions to directories, you can use chmod command. To  do it while creating them, use  mkdir  -p <permissions>

/home/MUM-user/ $ mkdir   -p  -m  775   channels/discovery
/home/MUM-user/ $ls  –ld   channels/discovery
drwxrwxr-x 2  MUM-user  Tools      256      NOV 12     22:01 channels/discovery


No comments:

Post a Comment