Open main menu

CDOT Wiki β

Changes

OPS705 Lab 2 (2227)

1,986 bytes added, 17:16, 20 September 2022
Adds absolute and relative pathing key concepts.
When you log into your Linux user account, you are automatically directed to your '''home''' directory. This directory is where the user can store files and create subdirectories to organize their files.
 
=== Pathname Types ===
There are different types of file pathnames that we can use to access a directory or text file.
 
For Example:
* '''Absolute Pathname''': <code>/home/userid/uli101/cars.txt</code>
* '''Relative Pathname''': <code>uli101/cars.txt</code> (this assumes you are in your home directory)
* '''Relative-to-Home Pathname''': <code>~/uli101/cars.txt</code>
 
These types of file pathnames can make it more efficient (i.e. less keystrokes for users to type) when issuing Unix and Linux commands.
 
==== Absolute Pathnames ====
An '''absolute pathname''' is a path to 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.
 
Advantages of using Absolute Pathnames:
* Useful if you do not know your current directory location
* Understand the location of file within the filesystem.
 
Examples:
* <code>ls /bin</code>
* <code>ls /home/your-user-id/uli101/examples</code>
 
==== Relative Pathnames ====
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''.
 
'''NOTE:''' In order to use relative pathnames, it is absolutely necessary that you know the location of your current directory!
 
Relative Pathname Symbols:
* <code>.</code> A period symbol "." represents the '''current''' directory
* <code>..</code> Two consecutive period symbols ".." represents the '''parent directory''' (i.e. one level up)
 
Advantages of using Relative Pathnames:
* Possible shorter pathname (less typing)
 
Examples:
* <code>ls ../../../bin</code>
* <code>ls examples</code>
* <code>ls ./examples</code>
= INVESTIGATION 1: Creating and Managing Directories =