Untitled Document
mkdir Command

mkdir - stand for Make Directory . Command is used to create directories on a file system . If the specified DIRECTORY does not already exist, mkdir creates it. More than one DIRECTORY may be specified when calling mkdir.

Example 1 -

Run below mkdir command . Creates a new directory called myprogs whose parent is the current directory..

   mkdir myprogs      

Example 2 - set permission on directory while creating it ( -m option)

Create the myprogs directory, and set its permissions such that all users may read, write, and execute the contents. Use the -m option with mkdir to assign permission while creating a directory .

   mkdir -m a=rwx myprogs    

Example 3 - Creating directory structure ( tree) in single stroke ( -p option )

The -p option allows us to create directory structure in single key stroke .Below command Creates the directory /home/my_progs/shell_scripts/basic_example. If the parent directory/home/my_progs/shell_scripts/ does not already exist, mkdir will create that directory first.

   mkdir -p /home/my_progs/shell_scripts/basic_example  

Example 4 - Create a number of subdirectory with one mkdir command

Run the below command it will create 3 directories in current directory

  mkdir log output script 
Untitled Document