Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.

Similar presentations


Presentation on theme: "UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To."— Presentation transcript:

1 UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To learn the Unix commands for files / directories’ manipulations 4. To learn the security & access permission for files / directories in Unix System

2 COMP111 Lecture 3 / Slide 2 File Systems  What is a file system? A means of organizing information on the computer. A file system is a logical view, not necessarily a physical view.  What does the file system provide:  Ways to create, move, and remove files  Ways to order files  Security  Examples of file systems:  DOS, Macintosh, CD-ROM, UNIX, NFS (networked file system) / binlibhomes horner.mailrctop10111 jbond...

3 COMP111 Lecture 3 / Slide 3 Directory Shorthands  “.” is the directory itself  “..” is the parent directory  In most shells “~” means your home directory)  ~user means user’s home directory, so: $ more ~jbond/.plan  looks at the file.plan in /home/jbond, which is jbond ’s home directory.

4 COMP111 Lecture 3 / Slide 4 Special Directories  “ / ” (pronounced “slash” and also called “the “root”) is the ancestor of all files in the file system  /bin and /usr/bin contain UNIX utilities (e.g., cat )  /dev contains special files which describe “devices” such as terminals and printers  /etc has administrative programs like password files  /tmp is for temporary files; periodically deleted  Every directory has at least two entries: “.” is the directory itself, and “..” is the directory’s parent

5 COMP111 Lecture 3 / Slide 5 Pathnames  Simple filenames Can only be used if files are in working directory  Relative pathname A string of directory references, beginning with the working directory. Examples:./secret1../007/names top10/LG7soBad  Absolute pathname A pathname beginning at the root. e.g.,: /homes/jbond/.plan /etc/passwd  mkdir makes a new directory (if you have permission to do so). With a simple pathname, rmdir removes a directory Directory Commands

6 COMP111 Lecture 3 / Slide 6 Directory Commands  You can copy a directory tree to another tree $ cp -R secret secret2  You can delete a whole directory tree (Be careful!) $ rm -R secret2  You may want to use the -i option for prompting: $ rm -Ri secret2 rm: examine files in directory secret2 (yes/no)? y rm: remove secret2/letter1 (yes/no)? y rm: remove secret2/letter2 (yes/no)? y rm: remove secret2: (yes/no)? y

7 COMP111 Lecture 3 / Slide 7 Security and Access Permissions (1)  There are three types of users:  The owner of the file (user)  The group of the file (group)  Anyone else (other)  There are three types of permission (independent of each other):  Read permission  Write permission  Execute permission

8 COMP111 Lecture 3 / Slide 8  Use ls -l to see file permissions -rw-r--r-- 1 jbond cs 154 Feb 4 15:00 letter3  There are four sets of items in the permissions: -rw-r--r--  The type is: “ - ” regular files, “ d ” directories, “ l ” symbolic links.  The next nine characters indicate if the file is readable, writable, or executable for the file owner, the file group, or other users, respectively. Security and Access Permissions (2) PermissionsUser Group Byte size Last modification Name #links usergroupother type

9 COMP111 Lecture 3 / Slide 9 Security and Access Permissions (3)  ls -l $ ls -l total 34 -r-xr-xr-x 1 jbond cs 9388 Feb 4 16:31 cat* -rw-r--r-- 1 jbond cs 154 Feb 4 15:00 letter1 -rw------- 1 jbond cs 64 Feb 4 15:00 names drwxr-xr-x 2 jbond cs 512 Feb 4 15:41 newdir/ drwxr-xr-x 2 jbond cs 512 Feb 4 16:38 secret/ d--------- 2 jbond cs 512 Feb 4 16:39 secret1/ dr--r--r-- 2 jbond cs 512 Feb 4 16:39 secret2/ d--x--x--x 2 jbond cs 512 Feb 4 16:38 secret3/

10 COMP111 Lecture 3 / Slide 10 Directory Permissions (1)  Can use ls -ld to lists a directory’s information (instead of its contents): $ ls -l secret total 4 -rw-r--r-- 1 jbond cs 154 Feb 4 16:38 letter1 -rw-r--r-- 1 jbond cs 34 Feb 4 15:00 letter4 $ ls -ld secret drwxr-xr-x 2 jbond cs 512 Feb 4 16:38 secret/ $ ls -ld secret* drwxr-xr-x 2 jbond cs 512 Feb 4 16:38 secret/ d--------- 2 jbond cs 512 Feb 4 16:39 secret1/ dr--r--r-- 2 jbond cs 512 Feb 4 16:39 secret2/ d--x--x--x 2 jbond cs 512 Feb 4 16:38 secret3/

11 COMP111 Lecture 3 / Slide 11 Directory Permissions (2) PermissionFor a FileFor a Directory r (read)Contents can be viewed or printed. Contents can be read, but not searched. Normally r and x are used together. w (write)Contents can be changed or deleted. Entries can be added or removed. x (execute)File can be used as a program. Directory can be searched.

12 COMP111 Lecture 3 / Slide 12 Changing Permissions (1)  The chmod command is used to modify permissions.  chmod can only be used by the owner of a file/dir (or the administrator root).  The arguments are: chmod [ugoa] [+-=] [rwxdd] [file/dir] In other words:  Optionally, one of the characters: u (user/owner), g (group), o (other), or a (all).  Optionally, one of the characters: + (add permission), - (remove permission), or = (set permission).  Any combination of the characters r (read), w (write), or x (execute).

13 COMP111 Lecture 3 / Slide 13 Changing Permissions (2)  Another way to change permission is to use numbers representing the permissions. The arguments are: chmod n u n g n o [file/dir] n u - user’s permission code n g - group’s permission code n o - other’s permission code -rwxrwxrwx Code table (3 bits) --- 0 r-- 4 --x 1 r-x5 -w- 2 rw-6 -wx 3 rwx7

14 COMP111 Lecture 3 / Slide 14 Permission Example  To let everybody read or write the file letter1 $ chmod a+rw letter1 (chmod 666 letter1) $ ls -l letter1 -rw-rw-rw- 1 jbond cs 154 Feb 4 15:00 letter1  To allow user to execute file letter1 $ chmod u+x letter1(chmod 766 letter1) $ ls -l letter1 -rwxrw-rw- 1 jbond cs 154 Feb 4 15:00 letter1*  To not let “other” to read or write file letter1 $ chmod o-rw letter1(chmod 760 letter1) $ ls -l letter1 -rwxrw---- 1 jbond cs 154 Feb 4 15:00 letter1*  To let “group” only read the file letter1 $ chmod g=r letter1(chmod 740 letter1) $ ls -l letter1 -rwxr----- 1 jbond cs 154 Feb 4 15:00 letter1*


Download ppt "UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To."

Similar presentations


Ads by Google