Download presentation
Presentation is loading. Please wait.
Published byMeghan Copeland Modified over 8 years ago
1
240-491 Adv. UNIX: FileStr/11 Advanced UNIX v Objectives –to supplement the “Introduction to UNIX” slides with extra information on files 240-491 Special Topics in Comp. Eng. 1 Semester 2, 2000-2001 1. The File Structure (Ch.4, Sobell)
2
240-491 Adv. UNIX: FileStr/12 Overview 1.Access Permissions 2.Links
3
240-491 Adv. UNIX: FileStr/13 1. Access Permissions 1.1Types of Users and Access 1.2More File Information 1.3Access Permission Characters 1.4Changing Permissions
4
240-491 Adv. UNIX: FileStr/14 1.1. Types of User and Access v Types of user: –creator / owneru –groupg –otherso v Types of access: –readr –writew –executex
5
240-491 Adv. UNIX: FileStr/15 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_spell drwxr-xr-x 2 ad users 1024 Sep 26 16:04 curses/ -rw-r--r-- 1 ad users 3355 May 2 10.52 letter.txt v 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
240-491 Adv. UNIX: FileStr/16 1.3. Access Permission Chars v First 3 chars: –refer to creator/owner (u) v Middle 3 chars: –refer to group (g) v Last 3 chars: –refer to everyone else (o)
7
240-491 Adv. UNIX: FileStr/17 v The 3 characters for u, g, and o have the same format: –First character indicates whether the file can be read (r). For a directory, this means you can do a ls. –Second character indicates whether the file can be written to (w). For a directory, you can add/remove files. –Third character indicates whether the file can be executed (x). For a directory, you can do a cd. A bit hard to remember
8
240-491 Adv. UNIX: FileStr/18 1.4. Changing Permissions chmod who+what file // add a permission chmod who-what file // remove who:u, g, o, a (all) what:r, w, x and combinations v Examples: chmod u+x foo-p chmod a+rw letter.txt chmod o-rx check_spell
9
240-491 Adv. UNIX: FileStr/19 $ 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
240-491 Adv. UNIX: FileStr/110 Warning v Your files and directories are automatically protected correctly. v Don’t change their permissions unless you really know what you are doing.
11
240-491 Adv. UNIX: FileStr/111 Directory Access Let everyone ls, add/remove and cd to my info directory: $ chmod a+rwx /home/ad/info v Check permissions: $ ls -ldF /home/ad/info drwxrwxrwx 3 ad staff 112 Apr 15 11:05 /home/ad/info
12
240-491 Adv. UNIX: FileStr/112 2. Links 2.1What is a Link? 2.2Creating a Link 2.3Seeing Links 2.4Removing a Link 2.5Symbolic Links
13
240-491 Adv. UNIX: FileStr/113 2.1. What is a Link? v A link is a pointer to a file. v Useful for sharing files: –a file can be shared by giving each person their own link (pointer) to it.
14
240-491 Adv. UNIX: FileStr/114 2.2. Creating a Link ln existing-file new-pointer v Jenny types: ln draft /home/ad/letter / home adjenny memoplanning /home/jenny/draft and /home/ad/letter
15
240-491 Adv. UNIX: FileStr/115 v Changes to a file affects every link: $ cat file_a This is file A. $ ln file_a file_b $ cat file_b This is file A. $ vi file_b : $ cat file_b This is file B after the change. $ cat file_a This is file B after the change.
16
240-491 Adv. UNIX: FileStr/116 2.3. Seeing Links v 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 v Look at inode number: $ ls -i file_a file_b file_c file_d 3534 file_a 3534 file_b 5800 file_c 7328 file_d
17
240-491 Adv. UNIX: FileStr/117 v 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
240-491 Adv. UNIX: FileStr/118 2.4. Removing a Link v Deleting a link does not remove the file. v Only when the file and every link is gone will the file be removed.
19
240-491 Adv. UNIX: FileStr/119 2.5. Symbolic Links v 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 v 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
240-491 Adv. UNIX: FileStr/120 v Jenny types: ln -s shared /home/ad/project / home adjenny memoplanning /home/jenny/shared and /home/ad/project separate filesystem
21
240-491 Adv. UNIX: FileStr/121 v Symbolic links are listed differently: $ ln -s pics /home/ad/images $ ls -lF pics /home/ad/images drw-r--r-- 1 ad staff 981 May 24 10:55 pics lrwxrwxrxw 1 ad staff 4 May 24 10:57 /home/ad/images --> pics
22
240-491 Adv. UNIX: FileStr/122 v 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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.