1 / 22

Advanced UNIX

Advanced UNIX. 240-491 Special Topics in Comp. Eng. 1 Semester 2, 2000-2001. Objectives to supplement the “Introduction to UNIX” slides with extra information on files. 1. The File Structure (Ch.4, Sobell). Overview. 1. Access Permissions 2. Links. 1. Access Permissions.

parry
Download Presentation

Advanced UNIX

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. Advanced UNIX 240-491 Special Topics in Comp. Eng. 1Semester 2, 2000-2001 • Objectives • to supplement the “Introduction to UNIX” slides with extra information on files 1. The File Structure(Ch.4, Sobell)

  2. Overview 1. Access Permissions 2. Links

  3. 1. Access Permissions 1.1 Types of Users and Access 1.2 More File Information 1.3 Access Permission Characters 1.4 Changing Permissions

  4. 1.1. Types of User and Access • Types of user: • creator / owner u • group g • others o • Types of access: • read r • write w • execute x

  5. 1.2. More File Information $ ls -lF-rwxr-xr-x 1 ad users 443275 Sep 26 15:02 BLP.gz*-rwxr-xr-x 2 ad users 852 May 5 14:03 check_spelldrwxr-xr-x 2 ad users 1024 Sep 26 16:04 curses/-rw-r--r-- 1 ad users 3355 May 2 10.52 letter.txt • Meaning (left to right): • file type (first char) • file access permission (9 chars) • number of links • owner’s name • group name - byte size of file- creation time/ last modified- name, with / or * ending

  6. 1.3. Access Permission Chars • First 3 chars: • refer to creator/owner (u) • Middle 3 chars: • refer to group (g) • Last 3 chars: • refer to everyone else (o)

  7. The 3 characters for u, g, and o have the same format: • First characterindicates whether the file can be read (r). For a directory, this means you can do a ls. • Second characterindicates whether the file can be written to (w). For a directory, you can add/remove files. • Third characterindicates whether the file can be executed (x). For a directory, you can do a cd. A bit hard to remember

  8. 1.4. Changing Permissions chmod who+what file // add a permissionchmod who-what file // remove who: u, g, o, a (all)what: r, w, x and combinations • Examples: chmod u+x foo-p chmod a+rw letter.txt chmod o-rx check_spell

  9. $ chmod a+rw letter.txt$ ls -lg letter.txt-rw-rw-rw- 1 ad staff 3355 May 2 10:52 letter.txt$ chmod o-rx check_spell$ ls -lg check_spell-rwxr-x--- 2 ad staff 852 May 5 14:03 check_spell

  10. Warning • Your files and directories are automatically protected correctly. • Don’t change their permissions unless you really know what you are doing.

  11. Directory Access • Let everyone ls, add/remove and cd to my infodirectory: $ chmod a+rwx /home/ad/info • Check permissions: $ ls -ldF /home/ad/infodrwxrwxrwx 3 ad staff 112 Apr 15 11:05 /home/ad/info

  12. 2. Links 2.1 What is a Link? 2.2 Creating a Link 2.3 Seeing Links 2.4 Removing a Link 2.5 Symbolic Links

  13. 2.1. What is a Link? • A link is a pointer to a file. • Useful for sharing files: • a file can be shared by giving each person their own link (pointer) to it.

  14. 2.2. Creating a Link ln existing-file new-pointer • Jenny types: ln draft /home/ad/letter / /home/jenny/draftand /home/ad/letter home ad jenny memo planning

  15. Changes to a file affects every link: $ cat file_aThis is file A.$ ln file_a file_b$ cat file_bThis is file A. $ vi file_b : $ cat file_bThis is file B after the change.$ cat file_aThis is file B after the change.

  16. 2.3. Seeing Links • Compare status information: $ ls -l file_a file_b file_c file_d-rw-r--r-- 2 ad 33 May 24 10:52 file_a-rw-r--r-- 2 ad 33 May 24 10:52 file_b-rw-r--r-- 1 ad 16 May 24 10:55 file_c-rw-r--r-- 1 ad 33 May 24 10:57 file_d • Look at inode number: $ ls -i file_a file_b file_c file_d3534 file_a 3534 file_b 5800 file_c 7328 file_d

  17. Directories may appear to have many links: drwxr-xr-x 23 ad users 1024 Jan 12 2000 BLP/ • This is because subdirectories (e.g. directories inside BLP/) have a link back to their parent.

  18. 2.4. Removing a Link • Deleting a link does not remove the file. • Only when the file and every link is gone will the file be removed.

  19. 2.5. Symbolic Links • The links described so far are often called hard links • a hard link is a pointer to a file which must be on the same filesystem • A symbolic link is an indirect pointer to a file • it stores the pathname of the pointed-to file • it can link across filesystems

  20. Jenny types: ln -s shared /home/ad/project / /home/jenny/sharedand /home/ad/project home ad jenny separate filesystem memo planning

  21. Symbolic links are listed differently: $ ln -s pics /home/ad/images$ ls -lF pics /home/ad/imagesdrw-r--r-- 1 ad staff 981 May 24 10:55 picslrwxrwxrxw 1 ad staff 4 May 24 10:57 /home/ad/images --> pics

  22. Symbolic links can confuse: $ ln -s /home/ad/grades /tmp/grades-old$ cd /tmp/grades-old$ pwd/home/ad/grades$ echo $cwd (C Shell only)/tmp/grades-old$ cd ..$ echo $cwd/home/ad

More Related