13,420
edits
Changes
→Pathname Types
===Pathname Types===
A '''pathname''' is a '''fully-specified location''' of a unique filename within the a file system.
The concept of a pathname relates to every operating system including '''Unix''', '''Linux''', '''MS-DOS''', '''MS-Windows''',
It is important to understand file pathnames since you need to '''save or access a file without ambiguity''' because there may be several files by that name in various different directories.
For example: Accessing the '''cars.txt''' file - which file to access? It depends on the location of the file
====Absolute Pathnames====
<table align="right"><tr><td>[[Image:absolute-path-2.png|thumb|right|250px|Directories The directory in red display the FULL path from the '''root''' directory to the '''bin''' directory (i.e. the absolute pathname: '''/bin'''.]]</td><td>[[Image:absolute-path-1.png|thumb|right|250px|Directories in red display the FULL path from the '''root''' directory to the '''examples''' directory (i.e. the absolute pathname: '''/home/userid/uli101/examples'''.]]</td></tr></table>
An '''absolute pathname''' is a path to the a file or directory always '''beginning from the root directory (i.e. / )'''.
This type of pathname is referred to as '''absolute''' because the pathname always begins from the '''root directory, ''', regardless the location or your current directory'''. In other words, this type of pathname requires that you always provide the '''FULL''' pathname starting with the root directory.
''Example:''<br><span style="color:blue;font-family:courier;">mkdir /home/userid/uli101</span> will create the '''uli101''' directory in the home directory of the user called: userid. This command is using an absolute pathname.
<br><br>
<table align="right"><tr><td>[[Image:relative-pathname-1.png|thumb|right|250px|Directories in red display the path from the current directory location (which is '''xyz100''') to the '''bin''' directory (i.e. the relative pathname: '''../../../bin'''.]]</td><td>[[Image:relative-pathname-2.png|thumb|right|250px|Directories in red display the path from the current directory location (which is '''uli101''') to the '''examples''' directory (i.e. the relative pathname: '''uli101/examples''' or ./uli101/examples]]</td></tr></table>
A relative pathname is a path to a file or directory that begins from your '''current''' directory. This is called relative because it is used to locate a specific file <u>relative </u> to your current directory.
'''NOTE:''' In order to use relative pathnames, it is <u>absolutely necessary</u> that you know the '''location''' of your '''current directory'''!
''Relative Pathname Symbols:''
:'''.''' A period symbol "." represents the '''current ''' directory:'''..''' Two consecutive period symbols ".." represents the '''parent ''' directory (one level up)
<br><br>
''Examples:''<br><br><span style="color:blue;font-family:courier;">mkdir ~uli101</span> will create the uli101 directory in '''current user's home directory'''.<br><span style="color:blue;font-family:courier;">ls ~jane</span> will display contents of '''jane's home directory''' ('''/home/jane''').