Presentation is loading. Please wait.

Presentation is loading. Please wait.

1Week 4 - Sep 26, 2005 Week 4 Agenda UNIX Directory Structure Absolute pathname Relative pathname Permissions chmod (symbolic/absolute)

Similar presentations


Presentation on theme: "1Week 4 - Sep 26, 2005 Week 4 Agenda UNIX Directory Structure Absolute pathname Relative pathname Permissions chmod (symbolic/absolute)"— Presentation transcript:

1 1Week 4 - Sep 26, 2005 Week 4 Agenda UNIX Directory Structure Absolute pathname Relative pathname Permissions chmod (symbolic/absolute)

2 2Week 4 - Sep 26, 2005 UNIX Directory Structure The UNIX system is structured hierarchically (upside down tree-like). You can have any number of files and subdirectories under it organized in any way. This structure leads to a parent-child relationship between a directory and its sub-directories. http://cs.senecac.on.ca/~ling.zhu/ULIIntroUnix.html

3 3Week 4 - Sep 26, 2005 UNIX Directory Structure The file system structure starts with one main directory, called the root directory. The file system structure starts with one main directory, called the root directory. From the root. At the end of each path is an ordinary file or a directory file. From the root. At the end of each path is an ordinary file or a directory file.

4 4Week 4 - Sep 26, 2005 Ordinary file VS Directory File Ordinary files (files) are at the end of paths and cannot support other paths while Directory files (directories) are the points that other paths can branch from. Directories directly connected by a path called parents (closer to the root) and children (farther from the root) Directory files (directories) are the points that other paths can branch from. Directories directly connected by a path called parents (closer to the root) and children (farther from the root)

5 5Week 4 - Sep 26, 2005 / Root directory – Root directory – the ancestor of all directories and the start of all absolute pathnames. ~ or $HOME ~ or $HOME Your Home directory - Your Home directory - the working directory when you first login Different Directories

6 6Week 4 - Sep 26, 2005 Different Directories. Current working directory – t Current working directory – t he directory under which you are working.... Parent directory – t Parent directory – t he directory above the working directory

7 7Week 4 - Sep 26, 2005 Pathname – Absolute VS Relative Absolute pathname – A pathname that. It locates a file Absolute pathname – A pathname that. It locates a file without regard to the working directory. without regard to the working directory. Relative pathname – A pathname that. Relative pathname – A pathname that. starts with root directory starts from the working directory

8 8Week 4 - Sep 26, 2005 Your working directory is the_joker and home directory is action_heros 1. Copy flinstones to your working directory by using relative pathname 2. Copy flinstones to your working directory by using absolute pathname 3. Delete simpsons by using relative pathname 4. Rename cartoons to animation by using absolute pathname 5. Create file1, file2 and file3 in your home directory using relative pathname Pathname – Examples

9 9Week 4 - Sep 26, 2005 You don’t know where is your home directory and working directory 1. Copy flinstones to your working directory 2. Copy flinstones to your home directory 3. Create file1, file2 and file3 in your home directory Pathname – Examples

10 10Week 4 - Sep 26, 2005 Pathname – Example Pathname Practice1 Pathname Practice1 Pathname Practice2 Pathname Practice2

11 Week 4 - Sep 26, 2005 11 Permissions - objectives 1.How do you find out what permissions are on a file? 2.How do you change permissions 3.Directory Permissions 4.Default Permissions 5.What permissions do you need to do the following tasks...?

12 12Week 4 - Sep 26, 2005 Key Concepts – File Permissions UNIX security for users and for the system is based on who has access to files and directories Setting “permissions” on a file controls who can read, write to or execute a file. Use the ls -l command to see the permissions on a file

13 13Week 4 - Sep 26, 2005 Your grocery lists and your Top Secret Buried Treasure maps should probably have different permissions! Warning !

14 14Week 4 - Sep 26, 2005 The output of the ls - l command will look like this: total 66 -r-xr-x- - - 1 ling.zhu users30 Mar26 19:49 colours drwxr-xr-x 4 ling.zhusys 512 Apr 1 17:41 comfind Key Concepts - File Permissions

15 15Week 4 - Sep 26, 2005 It is10 characters long. example: ling.zhu@matrix:~> ls -l -r-xr-x- - - 1 ling.zhu users54 Sep 26 19:49 lab2 Permissions Field The Permission Field - the first field in the long listing entry

16 16Week 4 - Sep 26, 2005 -r-xr-x- - - 1 ling.zhu users30 Mar26 19:49 colours drwxr-xr-x 4 ling.zhusys 512 Apr 1 17:41 comfind file type - r-x r-x - - - The Permission Field - The first character position

17 17Week 4 - Sep 26, 2005 The first character position represents the file type: -a normal file d a directory la soft or symbolic link sa socket ca character-special device ba block-special device The Permission Field

18 18Week 4 - Sep 26, 2005 -r-xr-x- - - 1 ling.zhu staff30 Mar26 19:49 colours drwxr-xr-x 4 ling.zhusys 512 Apr 1 17:41 comfind - r-x r-x - - - The next 9 characters in the Permissions Field are read as groups of 3 The Permission Field

19 19Week 4 - Sep 26, 2005 Each set of three characters is read the same way: r w x an “r” in the first position gives read permission for the file a “w” in the second position gives write permission for the file an “x” in the third position gives execute permission for the file The next 9 characters in the Permissions Field are read as groups of 3 The Permission Field

20 20Week 4 - Sep 26, 2005 Similarly for each set of three characters.... - - - a “-” in the first position means no read permission for the file a “-” in the second position means no write permission for the file a “-” in the third position means no execute permission for the file

21 21Week 4 - Sep 26, 2005 Warning! For normal files execute permission means it is executable! In DOS a file would have to have the proper extension in the filename to be executable. (.com,.exe,.bat)

22 22Week 4 - Sep 26, 2005 - r-x r-x - - - user The user that is the owner of a file is found in field 3 of the ls -l output. In this case ling.zhu has read and execute permission, no write permission -r-xr-x- - - 1 ling.zhu users30 Mar26 19:49 colours The first set of three characters - indicates the permissions for the user who owns the file.

23 23Week 4 - Sep 26, 2005 UNIX, If you created it.... you own it! Remember!

24 24Week 4 - Sep 26, 2005 - r-x r-x - - - group The group that the file belongs to is found in field 4 of the ls -l output. In this case group has read & execute permission, but no write permission -r-xr-x- - - 1 ling.zhu users30 Mar26 19:49 colours The second set of three characters - indicates the permissions for the members of the file’s group.

25 25Week 4 - Sep 26, 2005 - r-x r-x - - - others -r-xr-x- - - 1 ling.zhu users30 Mar26 19:49 colours In this case others have no read, no write & no execute permissions... The third set of three characters - indicates the permissions for all others on the system.

26 26Week 4 - Sep 26, 2005 -r-xr-x- - - 1 ling.zhu users30 Mar26 19:49 colours drwxr-xr-x 4 ling.zhusys 512 Apr 1 17:41 comfind - r-x r-x - - - file type user group others Key Concepts - File Permissions

27 27Week 4 - Sep 26, 2005 chmod

28 28Week 4 - Sep 26, 2005 1. add / remove permissions implicitly - symbolic method 2. set permissions explicitly - absolute or octal method 2 ways to specify permissions with the chmod command

29 29Week 4 - Sep 26, 2005 You need to provide 3 pieces of information: 1. WHO are you changing permissions for? 2. what OPERATION do you want to do? 3. WHAT are the permissions you want to add/remove? To add/remove permission implicitly (symbolic method)

30 30Week 4 - Sep 26, 2005 1. WHO are you changing permissions for? ufor the user gfor the group ofor all others afor all three To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

31 31Week 4 - Sep 26, 2005 2. what OPERATION do you want to do? + (plus sign) add the permission - (minus sign)remove the permission = (equal sign)set it to indicated mode To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

32 32Week 4 - Sep 26, 2005 3. WHAT are the permissions you want to add/remove? rread wwrite xexecute To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

33 33Week 4 - Sep 26, 2005 - r-x r-x - - - file type usergroup others To add write permission for user... 1. who? u (user) 2. what operation? + (add) 3. what permission? w(write) To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

34 34Week 4 - Sep 26, 2005 - r-x r-x - - - file type usergroup others To add write permission for user for the file called colours the command would be: chmod u+w colours -r-xr-x- - - 1 ling.zhu users30 Mar26 19:49 colours To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

35 35Week 4 - Sep 26, 2005 - rwx r-x - - - file type usergroup others The chmod u+w colours command results in the following permissions for the file colours: -rwxr-x- - - 1 ling.zhu users30 Mar26 19:49 colours To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

36 36Week 4 - Sep 26, 2005 - rwx r-x - - - file type usergroup others To remove write permission for user, and add write permission for the group for the file called colours the command would be: chmod u-w,g+w colours -rwxr-x- - - 1 ling.zhu users30 Mar26 19:49 colours To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

37 37Week 4 - Sep 26, 2005 - r-x rwx - - - file type usergroup others The chmod u-w,g+w colours command results in the following permissions for the file colours: -r-xrwx- - - 1 ling.zhu users30 Mar26 19:49 colours To add/remove permission implicitly (symbolic method) you need to provide 3 pieces of information:

38 38Week 4 - Sep 26, 2005 Using Implicit or Symbolic Permissions! To get the permissions exactly as you want them you may have to use a series of addition and removal commands.... you can combine them all on one line, just make sure there are no spaces between them!

39 39Week 4 - Sep 26, 2005 There are 2 ways to specify permissions with the chmod command: 1. add / remove permissions implicitly 2. set permissions explicitly Key Concepts - File Permissions

40 40Week 4 - Sep 26, 2005 Assign individual permission letters “point values” r=4 w=2 x=1 deny all= 0 Setting permissions explicitly = octal = absolute

41 41Week 4 - Sep 26, 2005 2. Setting permissions explicitly: r = 4 w = 2x = 1 rwx=4 + 2 + 1 = 7read,write,execute rw-=4 + 2 + 0 = 6read, write r-x=4 + 0 + 1 = 5read, execute r--=4 + 0 + 0 = 4read only -wx = 0 + 2 + 1 = 3write, execute -w-= 0 + 2 + 0 = 2write only --x= 0 + 0 + 1 = 1execute only ---= 0 + 0 + 0 = 0no permission

42 42Week 4 - Sep 26, 2005 chmod 777 colours - rwx rwx rwx -rwxr-x- - - 1 ling.zhu users30 Mar26 19:49 colours rwx=4+2+1=7 -rwxrwxrwx 1 ling.zhu users30 Mar26 19:49 colours Setting permissions explicitly = octal = absolute

43 43Week 4 - Sep 26, 2005 chmod 640 colours - rw- r-- --- -rwxr-x- - - 1 ling.zhu users30 Mar26 19:49 colours rw-=4+2+0=6r--=4+0+0=4---=0+0+0=0 -rw-r----- 1 ling.zhu users30 Mar26 19:49 colours Setting permissions explicitly = octal = absolute

44 44Week 4 - Sep 26, 2005 Using Explicit or Octal Permissions ! allows you need to specify the exact permissions you want... regardless of the current permissions

45 45Week 4 - Sep 26, 2005 Sample Permission Questions Please change the permission of the file fun which is under your current directory to allow others all permissions using relative path. Please change the permission of the file fun which is under your home directory to allow the owner rw, the group r and the rest rwx using absolute path. By Ling zhu

46 46Week 4 - Sep 26, 2005 Directory Permissions Directory permissions are much the same as files the owner of a directory decides who has access to its files directory permissions are assigned using the same letters as for files but the meaning of the letters r,w,x are different.....

47 47Week 4 - Sep 26, 2005 Read permission for a directory means you are allowed to list the files in the directory with ls Write permission for a directory means you can create or remove files in it Execute permission for a directory means you can make it your working directory or pass through it in a path Read & execute = “search” permissions are required to get a long listing. Directory Permissions

48 48Week 4 - Sep 26, 2005 Question: What permission do you need for a directory in order to remove a file under it? Directory Permissions rw- ? -wx? By Ling zhu

49 49Week 4 - Sep 26, 2005 Warning! For directories, you need “execute” permission to search them!... without “search” permission in a directory you need to know the exact name of a file to read it

50 50Week 4 - Sep 26, 2005 Homework 1.What is the minimum permission needed to view hiding.html under public_html/sub1/subsub1/week4 ? 2. 3. Pathname Practice1 Pathname Practice1 Pathname Practice2 Pathname Practice2


Download ppt "1Week 4 - Sep 26, 2005 Week 4 Agenda UNIX Directory Structure Absolute pathname Relative pathname Permissions chmod (symbolic/absolute)"

Similar presentations


Ads by Google