Open main menu

CDOT Wiki β

Changes

OPS705 Lab 2 (2227)

1,536 bytes added, 16:29, 20 September 2022
KEY CONCEPTS
==== Absolute Pathnames ====
<table align="right"><tr><td>[[Image:absolute-path-2.png|thumb|right|250px|The directory in red displays 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/your-user-id/uli101/examples'''.]]</td></tr></table>
An '''absolute pathname''' is a path to a file or directory '''always beginning from the root directory''' (i.e. <code>/</code>).
==== Relative Pathnames ====
<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 ''relative to your current directory''.
==== Relative-to-Home Pathnames ====
<table align="right"><tr><td>[[Image:relative-to-home-1.png|thumb|right|250px|Directories in red display the path from the home directory of the current user (which is '''userid''') to the '''examples''' directory (i.e. the relative-to-home pathname: '''~/uli101/examples'''.]]</td><td>[[Image:relative-to-home-2.png|thumb|right|250px|Directories in red display the path from another user's home directory location to their '''notes''' directory (i.e. the relative-to-home pathname: '''~otheruserid/uli101/notes''']]</td></tr></table>
A '''relative-to-home''' pathname begins with the tilde character ( i.e. '''~''') to represent the user’s home directory.
The tilde character <code>~</code> stores the path of the user’s home directory (i.e. '''~''' = '''/home/current-user-id''')
You can immediately place a username after the tilde to represent another user’s home directory (e.g. '''~cjohnson30otheruserid''' = '''/home/cjohnson30otheruseid''')
Examples:
* <code>ls ~/uli101/examples</code>
* <code>ls ~cjohnson30otheruserid/uli101/notes</code>
'''NOTE''': Deciding which '''type of pathname''' to use depends on many factors including: