What is a Path?
- "Directions" ("route") to a file
(or directory/folder)
- Based on the Directory Tree
Root Directory
Top Level Directory - "Root of the tree"
Macintosh:
Macintosh HD
(Or whatever you've named your hard disk)
Windows:
c:
Unix, Linux, Mac OS X, Web Servers:
/
Home directory
-
Where you start when you login
(sometimes referred to as "login directory", too)
-
Directory name is same as userid
-
Place to create files and subdirectories
Typical home directory on CS server:
/home/students/userid
Current Working Directory
-
You are always "in a directory"
"Current working directory"
-
Same as active folder on Mac or PC
-
Where current work is performed
-
You can move to any directory (or "Change your current
working directory")
-
Home or login directory
is your initial current working directory
pwd - print working directory
-
Displays current working directory
-
Easy to lose track of current directory
-
pwd tells you where you are
ls -l
Example:
zimmer@cslab103:~/mystuff$ ls -l
total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/
Changing the permissions chmod - change mode command is
used to change the permissions
or
privileges on a file.
r - read permission
w - write permission
x - execute permission
u -user permissions - first set of three letters
(applies to owner of file) g -
group permissions - second set of three letter (applies to group that owner belongs
to) o -
other permissions - third set of three letters
(applies to the world) Directories and permissions:
r - Can do a listing of the contents
w - Can create a file or dir in this
dir or delete something in the dir
x - Can move into or through this directory
Example:
zimmer@cslab103:~/mystuff$ chmod o+wx f3.txt
zimmer@cslab103:~/mystuff$ ls -l
total 4
-rw-r--rwx 1 zimmer users 0 Aug 25 2003 f3.txt
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/
zimmer@cslab103:~/mystuff$ chmod u-rw f4.txt
zimmer@cslab103:~/mystuff$ ls -l
total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
----r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/
zimmer@cslab103:~/mystuff$ chmod ug+rw f4.txt
zimmer@cslab103:~/mystuff$ ls -l
total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
-rw-rw-r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/
zimmer@cslab103:~/mystuff$ chmod go-rwx old
zimmer@cslab103:~/mystuff$ ls -l
total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
----r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwx------ 2 zimmer users 4096 Aug 27 2003 old/
Moving Around cd - change directory
- Allows user to move among directories
- You must have access rights to the directory
Example:
zimmer@cslab103:~/mystuff$ cd
go to home directory
zimmer@cslab103:~/mystuff$ cd /
go to root directory
zimmer@cslab103:~/mystuff$ cd old/files/
go to old/files/ directory
Creating Directories mkdir - make directory command
- Creates directories within your account
Example:
zimmer@cslab103:~/mystuff$ mkdir stuff
Creates a directory named "stuff" in the current working directory
Deleting Directories rmdir - remove directory command
Example:zimmer@cslab103:~/mystuff$ rmdir stuff
Delete the directory "stuff" from the current working directory
Relative vs. Absolute References Absolute reference
- Path from the root directory to destination directory
- Full pathname
/home/students/a123456z/mystuff/file.txt
Relative reference
- path from current working directory to destination directory
If current directory = /home/students/a123456z/
Relative path = mystuff/file.txt
Parent Directory
- Every directory has only one parent directory
- The shorthand for the parent directory is ‘..’
If current directory = /home/students/a123456z/mystuff
cd ..
Now current directory = /home/students/a123456z/
|