Presentation is loading. Please wait.

Presentation is loading. Please wait.

Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 5 File.

Similar presentations


Presentation on theme: "Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 5 File."— Presentation transcript:

1 Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 5 File and Directory Permissions

2 © Copyright IBM Corporation 2008 Unit Objectives After completing this unit, you should be able to: Describe how permissions are used List the permissions required to perform several common commands Change permissions using symbolic and octal notation Describe how default permissions are calculated

3 © Copyright IBM Corporation 2008 tux1 alan linus richard tux2 Group: penguins Group: people /groups/penguins/herring.txt Each file has an owner Each file is assigned to a group X Users and Groups

4 © Copyright IBM Corporation 2008 File permissions are assigned to: 1.The owner of a file 2.The members of the group the file is assigned to 3.All other users Permissions can only be changed by the owner and root! Permissions

5 © Copyright IBM Corporation 2008 To show the permissions of a file, use the ls command with the -l option. $ ls -l -rw-r--r-- 1 tux1 penguins 101 Jan 1 10:03 file1 -rw-r--r-- 1 tux2 penguins 171 Jan 4 10:23 file2 drwxr-xr-x 2 tux1 penguins 1024 Jan 2 11:13 mydir File type link counter name mtime (modification time) size group owner permissions Viewing Permissions

6 © Copyright IBM Corporation 2008 rwxrwxrwx owner group other rread w write xexecute Regular files: rfile is readable wfile is writeable xfile is executable ( if in an executable format ) Directories: rcontents of directory can be listed (ls) wcontents can be modified (add/delete files) xchange into directory is possible (cd) Permissions Notation

7 © Copyright IBM Corporation 2008 CommandSource directorySource fileTarget directory cdxN/A lsx, rN/A mkdir, rmdirx, wN/A cat, lessxrN/A cpxrx, w cp -rx, rrx, w mvx, wnone!!!x, w vix, rr, wN/A rmx, wnone!!!N/A Required Permissions

8 © Copyright IBM Corporation 2008 $ ls -ld /home/tux1 drwx------ 4 tux1 penguins 1024 Jan 5 12:43 /home/tux1 Who Can Change Permissions? The owner of the file or directory The root user

9 © Copyright IBM Corporation 2008 $ chmod go-rx /home/tux1 $ ls -ld /home/tux1 drwx------ 4tux1penguins 1024 Jan 5 12:43 /home/tux1 $ chmod 700 /home/tux1 $ ls -ld /home/tux1 drwx------ 4tux1penguins 1024 Jan 5 12:43 /home/tux1 Changing Permissions (1 of 2) To change the permission of a file use the chmod command Syntax:chmod Mode can be symbolic... or octal:

10 © Copyright IBM Corporation 2008 rwxr-x --- r = 4 w = 2 x = 1 if unset, 0 is used 4+2+1=7 0+0+0=0 4+0+1=5 mode is 750 Changing Permissions (2 of 2)

11 © Copyright IBM Corporation 2008 default permissionsrw-rw-rw-666 umask ( - )----w--w-022 resulting permissionsrw-r--r--644 regular files: default permissionsrwxrwxrwx777 umask ( - )----w--w-022 resulting permissionsrwxr-xr-x755 directories: Syntax: umask 022 umask New files should not be created with 666! To avoid this problem, a permission mask exists.

12 © Copyright IBM Corporation 2008 $ pwd /groups/ $ ls -l drwxrwxr-x 2 root penguins 1024 Jan 1 10:03 penguins $ ls -l penguins -rw-r--r-- 1 tux1 penguins 544 Jan 1 10:15 hello.c -rw-r--r-- 1 tux1 penguins 544 Jan 1 10:15 task.c -rw-r--r-- 1 tux1 penguins 544 Jan 1 10:15 zip.c Can tux2 (who is also a member of the penguins group) successfully execute the following commands? 1. cd /groups/penguins 2. mkdir /groups/penguins/mydir 3. cp /groups/penguins/task.c ~/task.c 4. vi /groups/penguins/zip.c 5. vi /groups/penguins/newfile.c 6. rm /groups/penguins/hello.c Checkpoint

13 © Copyright IBM Corporation 2008 Unit Summary Permissions determine whether a user is able to do something with a file or directory. Permissions can be set for the user, the group, and all others. Three base permissions exist: read, write, and execute. To view the permissions, use ls –l. Permissions can be changed only by the owner of the file or directory, and by root. The umask determines the default permissions on a file.


Download ppt "Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 5 File."

Similar presentations


Ads by Google