1 / 14

UNIX file systems

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

jborelli
Download Presentation

UNIX file systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. / bin homes lib . . . horner jbond . . . .mailrc 111 top10 . . . 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)

  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. 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. 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 Pathnames Directory Commands

  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. 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. Security and Access Permissions (2) • 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. Byte size Name #links Group Last modification Permissions User type user group other

  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. 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. Directory Permissions (2)

  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. Changing Permissions (2) • Another way to change permission is to use numbers representing the permissions. The arguments are: chmod nungno [file/dir] Code table (3 bits) --- 0 r-- 4 --x 1 r-x 5 -w- 2 rw- 6 -wx 3 rwx 7 nu - user’s permission code ng - group’s permission code no - other’s permission code -rwxrwxrwx

  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*

More Related