Difference between revisions of "Tutorial3: Advanced File Management / Quoting Special Characters"

From CDOT Wiki
Jump to: navigation, search
(Relative Pathnames)
(Relative Pathnames)
Line 85: Line 85:
  
 
<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>
 
<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
+
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
+
This is called relative because it is used to locate a specific file relative to your current directory.
  
 
For example: mkdir uli101
 
For example: mkdir uli101

Revision as of 15:37, 13 January 2020

ADVANCED UNIX / LINUX FILE MANAGEMENT

Main Objectives of this Practice Tutorial

  • Understand the difference between absolute / relative / relative-to-home pathnames
  • Become productive using various pathname types for Unix/Linux File Management
  • Understand the following Ambiguous Filename expansion (FNE) Symbols: * / ? / [ ] / [! ]
  • Become productive using FNE for Unix/Linux File Management
  • Understanding quotation symbols: Backslash \ , single quotes ' ' , double quotes " "
  • Understand the purpose of quoting special characters for File Management and issuing Linux commands


Tutorial Reference Material

Course Notes
Pathname Type / Filename Expansion / Quoting Reference
YouTube Videos
Course Notes:


Pathname Types

Ambiguous Filename Expansion Symbols

  • Asterisk * , Question ? ,
    Character Class [ ] and [! ]


Quotation Symbols Instructional Videos:
  • Using Pathname Types
  • Filename Expansion
  • Quoting Special Characters

Pathname Types

A pathname is a fully-specified location of a unique filename within the file system.

The concept of a pathname relates to every operating system including Unix, Linux, MS-DOS, MS-Windows, Apple-Macintosh, etc.


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 directories. For example: Accessing the cars.txt file - which file to access? It depends on the location of the file

/home/userid/uli101/cars.txt
/public/uli101/samples/cars.txt
/etc/data/cars.txt


Absolute Pathnames

Directories in red display the FULL path from the root directory to the bin directory (i.e. the absolute pathname: /bin.
Directories in red display the FULL path from the root directory to the examples directory (i.e. the absolute pathname: /home/userid/uli101/examples.

An absolute pathname is a path to the 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
  • Easier to understand the FULL layout of pathname


Example:
mkdir /home/userid/uli101 will create the uli101 directory in the home directory of the user called: userid. This command is using an absolute pathname.

Relative Pathnames

Directories in red display the path from the current directory location (which is xyz100) to the bin directory (i.e. the relative pathname: ../../../bin.
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

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.

For example: mkdir uli101 will create the uli101 directory in your current directory!

Relative-to-home Pathnames

You can specify a pathname as relative-to-home by using a tilde and slash at the start, e.g. ~/uli101/notes.html

The tilde ~ is replaced by your home directory (typically /home/username) to make the pathname absolute.

You can immediately place a username after the tilde to represent another user’s home directory.

For example: ~jane = /home/jane




Ambiguous Filename Expansion

x

Quoting Special Characters

x

INVESTIGATION 1: ABSOLUTE / RELATIVE / RELATIVE-TO-HOME PATHNAMES

X


Perform the Following Steps:


  1. X


INVESTIGATION 2: FILENAME EXPANSION

x

Perform the following steps:
  1. X

INVESTIGATION 3: QUOTING SPECIAL CHARACTERS

x


Perform the Following Steps:
  1. X



LINUX PRACTICE QUESTIONS

The purpose of this section is to obtain extra practice to help with your assignment #1, quizzes, your midterm, and your final ezam.

Here is a link to the MS Word Document of ALL of the questions displayed below but with extra room to answer on the document to simulate a quiz:

https://ict.senecacollege.ca/~murray.saul/uli101/uli101_week3_practice.docx

Your instructor may take-up these questions during class. It is up to the student to attend classes in order to obtain the answers to the following questions. Your instructor will NOT provide these answers in any other form (eg. e-mail, etc).


Review Questions:

  1. X
  2. X
  3. X
  4. X
  5. X
  6. X
  7. X
  8. X