Difference between revisions of "Tutorial3: Advanced File Management / Quoting Special Characters"
(→INVESTIGATION 1: ABSOLUTE / RELATIVE / RELATIVE-TO-HOME PATHNAMES) |
(→INVESTIGATION 1: ABSOLUTE / RELATIVE / RELATIVE-TO-HOME PATHNAMES) |
||
Line 145: | Line 145: | ||
# '''Login''' your matrix account.<br><br> | # '''Login''' your matrix account.<br><br> | ||
− | # Issue a command to '''confirm''' you are located in your home directory | + | # Issue a command to '''confirm''' you are located in your home directory.<br><br> |
# x | # x | ||
Revision as of 15:59, 13 January 2020
Contents
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
|
Quotation Symbols | Instructional Videos:
|
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
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
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:
- . A period symbol "." represents the current directory
- .. Two consecutive period symbols ".." represents the parent directory (one level up)
Advantages of using Relative Pathnames:
- Possible shorter pathname (less typing)
For example: mkdir uli101 or 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 character ~' is replaced by your home directory (typically /home/current-user-id)
You can immediately place a username after the tilde to represent another user’s home directory. For example: ~jane = /home/jane
Advantages of using Relative-to-home Pathnames:
- Possible shorter pathname
Examples:
mkdir ~uli101 will create the uli101 directory in current user's home directory.
ls ~jane will display contents of jane's home directory (/home/jane).
NOTE: Deciding which type of pathname to use depends on many factors including: knowledge of current directory, knowledge of directory structure, currently directory location, and type of file management command that is being used.
Ambiguous Filename Expansion
x
Quoting Special Characters
x
INVESTIGATION 1: ABSOLUTE / RELATIVE / RELATIVE-TO-HOME PATHNAMES
The best method to learn about pathname types is to issue many Linux file management commands using each type (absolute, relative, relative-to-home) and see which ones (or combination) is the most efficient (requiring the least number of keystrokes).
Perform the Following Steps:
- Login your matrix account.
- Issue a command to confirm you are located in your home directory.
- x
INVESTIGATION 2: FILENAME EXPANSION
x
- Perform the following steps:
- X
INVESTIGATION 3: QUOTING SPECIAL CHARACTERS
x
- Perform the Following Steps:
- 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:
- X
- X
- X
- X
- X
- X
- X
- X