Path Name in Unix

Files are located in directories or subdirectories. We can find these by using their pathname. A  path  name consists of a slash followed by a  sequence  of slashes and directory names. The target file is the file you want to specify.

The first slash before the directory tree route makes a  big difference in how this path is interpreted.

 

Two kinds of path names:

 

       1. Full path name/ Absolute path name

       2. Relative path name.

 

ADVANTAGES:

It's easier to find any particular file if your home directory  is well stored.

  1. Access files much faster when directories are relatively small ; ideally directories should have  almost 60 (or so) files in them.
  2. Important  part  of  Unix  file protection

 

ABSOLUTE PATH NAME:

  1. Start at the root directory.
  2. Always start with a slash.
  3. The absolute path name to some object file, etc is always  the  same.

 

RELATIVE PATH NAME:

  1. Start at your current directory.
  2. Never start with slash.
  3. The  relative path name to an Object depends on  your  current directory.

 

             Full  path  name  begins  with  slash (/)  followed  by  the  sequence  of directories from the root to the target file or directory. Relative path name does not begin with a slash (/) and assumes a starting location of the current working directory.

 

To make an Absolute path name

  • Start at the root directory slash (/) and work down.
  • Put a slash(/) after every directory name though if  the  path ends  at a directory the slash after the last name  is  optional.

 

 Example:-    $ ls /home/alpha/data

                       a, b , c,   -  files

                       data      -  current directory

                       work     -  home directory

 

To make as Relative path name

  • Start at your current directory.
  • As you move down the tree away from the root, add  subdirectory  names.
  • As  you move up the tree towards root, add .. (two  dots)  for  each directory.
  • Put a slash(/) after every directory name though If the path is to a directory the slash after  the last name is optional

 

     Example:

         List the subdirectory sub,  it contains  d ,e  and f  as files.

          $ ls  sub

             d

             e

             f

         $

           Obviously d  file  stored in the sub directory sub. can read the file d  directly from  our current working directory by:          

 $cat  sub/d

 d

$      

          $cd../../ram - change the current directory

          $more ../. setup

          $pwd       -   Print working directory/  display path name.

          $ls - F       -  Display directory /Subdirectory

 

 

Upload Content

Upload your original content. We will publish your material under your name on W3Professors after review.

Feedback

Without your feedback, such words as Improvement, Achievement and Success have no meaning for us.


W3Professors is only to provide online education. We do not warrant oraginality of any content. Whole content is uploaded by someone so if you feel that particular content is copied or not upto mark. You can click on Copied Content link. We will remove that content Immediately. You agree to have read and accept our Terms of Use and Privacy Policy. © Copyright 2008-2015 W3Professors.Com All Rights Reserved.

Designed and Maintained by Kanwer Technologies