Creation of Directories in Unix file system(Session -04) .

Creation of Directories in Unix file system.

What exactly is a directory ?

we can say a directory is collection of files

where files can be stored which will be helpful for the user to search the file

Directory name         Typical contents
/bin                              Commands and programs used by all the users of the system
/boot                            Files required by the boot loader
/dev                             CD/DVD-ROM, floppy drives, USB devices, etc.
/etc                              System configuration files
/home                          User data files

Syntax :

$mkdir <option> <directory name>

To check what options are available in mkdir we have man command

 

How to create Directory ?

$mkdir <dir name>

This will create a directory in the present location where the user is

  • $mkdir -p <dir1/dir2/dir3/>

Using this command we can create sub level directories

We have created directory under another directory.

  • $mkdir -m <permissions tag> <dir name>

At the time of creation we can create directory by assigning permissions to it

  • Command CD stands for change directory .It is used to change the directory locations.
  • $cd <dir name>

This command is used to enter from one directory to other directory

  • $ls -ld <dir name>

To list the permissions of directory.

ABSOLUTE PATH AND RELATIVE PATHS

ABSOLUTE PATH :

What ever the action performed by the user from the home directory by giving the exact address locations of the file or directory is known as absolute path

RELATIVE PATH :

What ever the action performed by the user from the present working directory by giving the exact address locations of the target file or directory is known as relative path

 

The Difference between Absolute  and Relative paths :

 

To know the present directory location we have command called “PWD”

Create directory called  ‘d1’

List out the files under ‘d1’ directory.

When we gave ls command it shows only d2 directory but we have two hidden directories

. is command which indicates current directory.

.. is command which indicates parent  directory.

–  is one of the option in cd command to go for previous working directory.

~ is one of the option in cd command to go for user home location.

 

Thank you…

Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading...

Add Comment