0
Lesson 9-Setting and Using Permissions
Overview  <ul><li>Describing file permissions. </li></ul><ul><li>Using execute permissions with a file. </li></ul><ul><li>...
Overview  <ul><li>Changing permissions for group and other. </li></ul><ul><li>Exploring the effect of granting different p...
Describing File Permissions  <ul><li>The permissions read, write, and execute govern access to files and directories. </li...
Describing File Permissions  <ul><li>Examining the permissions field. </li></ul><ul><li>Employing read and write permissio...
Examining the Permissions Field  <ul><li>The “ls –l” command displays the permissions for regular files and directories. <...
Examining the Permissions Field  <ul><li>The first slot indicates whether the listing is for a directory, a plain file, or...
Examining the Permissions Field  Permission Field For Users
Examining the Permissions Field  <ul><li>File permissions: </li></ul><ul><ul><li>An owner has full powers over the assignm...
Employing Read and Write  Permissions  <ul><li>To access the contents of a file, a user must have read permissions for tha...
Changing Permissions for a File to Read Only  Assigning Read Only Permission
Changing Permissions for a File to Write Only  Assigning Write Permission
Using Execute Permissions with a  File  <ul><li>The “vi” editor can be used for creating a shell script. </li></ul><ul><li...
Using Execute Permissions with a  File  <ul><li>A file with the appropriate execute permission can run a shell script like...
Using Execute Permissions with a  File  <ul><li>The read permission is sufficient when sourcing a script, because the curr...
Changing File Permissions Using Mnemonics  <ul><li>The “chmod” command can accept permission settings in the form of lette...
Changing File Permissions Using Mnemonics  <ul><li>Assigning specific permissions. </li></ul><ul><li>Adding and deleting p...
Assigning Specific Permissions  Assigning All Permissions to All Users
Assigning Specific Permissions  Assigning Specific Permissions to Specific Users
Adding and Deleting Permissions  Denying Specific Permission to Specific Users
Changing File Permissions  Numerically  <ul><li>Numbers can also be used for conveying permissions information for all the...
Changing File Permissions  Numerically  <ul><li>Combination permissions are specified using the sum of the values for the ...
Changing File Permissions  Numerically  Numerical Combination of Permissions
Changing File Permissions  Numerically  Permission Values
Changing File Permissions  Numerically  Basic File Permissions
Changing Permissions for Group and Other  <ul><li>Permissions are usually most restrictive for other, less so for group, a...
Exploring the Effect of Granting Different Permissions  <ul><li>Changing the permissions of a file does not impact the cur...
Modifying Directory Permissions  <ul><li>Directories have the same kind of permissions fields as regular files, except tha...
Modifying Directory Permissions  <ul><li>Using permissions to control directory access. </li></ul><ul><li>Listing the file...
Using Permissions to Control Directory Access  <ul><li>The owner of a directory has the power and responsibility for setti...
Using Permissions to Control Directory Access  <ul><li>The inode contains all the information about a file, including perm...
Listing the Files in a Directory  <ul><li>Permissions for a directory are contained in the inode listed next to the curren...
Denying Write Permissions for a Directory  <ul><li>Write permissions must be granted before a user can modify the contents...
Examining the Need for Execute Permissions  <ul><li>Execute permissions have a different impact on a directory than on a f...
Examining the Need for Execute Permissions  <ul><li>The files in a subdirectory within the parent directory cannot be acce...
Changing Permissions for Files in all Subdirectories  <ul><li>The “chmod” utility can be used to change the permissions fo...
Identifying Other System  Permissions  <ul><li>The “s” and “t” are some of the permissions that can only be set by the sup...
Identifying Other System  Permissions  <ul><li>The root user has “s” and “r” permissions on the passwd file, where s in th...
<ul><li>The group ID of the program needs to be turned on if an administrator wishes to restrict users from executing spec...
Identifying Other System  Permissions  <ul><li>A user cannot remove a file even though they have write permissions on the ...
Setting Permissions when Files and Directories are Created  <ul><li>The three ways of creating files in UNIX are: </li></u...
Setting Permissions when Files and Directories are Created <ul><li>Examining the default permissions. </li></ul><ul><li>Sp...
Examining the Default Permissions  <ul><li>The operating system initially sets permissions for the owner as read and write...
Examining the Default Permissions  <ul><li>The umask setting determines the value of permissions for new files as they are...
Specifying Default Permissions for Directories with umask  <ul><li>A directory created while umask is 000 has full permiss...
Specifying Default Permissions for Directories with umask  Umask Values
Examining the Impact of umask on Other Operations  <ul><li>The value of umask determines the initial permissions when file...
Examining the Impact of umask on Other Operations  <ul><li>The “cat” utility can also be used for duplicating a file with ...
Summary  <ul><li>Read permission is needed to access a file’s contents with a utility. </li></ul><ul><li>Write and execute...
Summary  <ul><li>Letters or numbers can be used for specifying permissions information in the chmod command. </li></ul><ul...
Upcoming SlideShare
Loading in...5
×

intro unix/linux 09

2,414

Published on

setting and using permissions

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • thanks...Good work
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total Views
2,414
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
291
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "intro unix/linux 09"

  1. 1. Lesson 9-Setting and Using Permissions
  2. 2. Overview <ul><li>Describing file permissions. </li></ul><ul><li>Using execute permissions with a file. </li></ul><ul><li>Changing file permissions using mnemonics. </li></ul><ul><li>Changing file permissions numerically. </li></ul>
  3. 3. Overview <ul><li>Changing permissions for group and other. </li></ul><ul><li>Exploring the effect of granting different permissions. </li></ul><ul><li>Modifying directory permissions. </li></ul><ul><li>Setting permissions when files and directories are created. </li></ul><ul><li>Examining the impact of umask on other operations. </li></ul>
  4. 4. Describing File Permissions <ul><li>The permissions read, write, and execute govern access to files and directories. </li></ul><ul><li>The owner can modify the permissions on a file for three classes of users. </li></ul><ul><li>The owner or user, the members of the owner’s group, and other users are the three classes of users. </li></ul>
  5. 5. Describing File Permissions <ul><li>Examining the permissions field. </li></ul><ul><li>Employing read and write permissions. </li></ul><ul><li>Changing permissions for a file to read only. </li></ul><ul><li>Changing permissions for a file to write only. </li></ul>
  6. 6. Examining the Permissions Field <ul><li>The “ls –l” command displays the permissions for regular files and directories. </li></ul><ul><li>Every slot in the permissions field is occupied by either a dash or a letter. </li></ul><ul><li>A minus sign indicates that a particular permission is denied. </li></ul><ul><li>The “t” field in the directory permissions is a special permission called the sticky bit. </li></ul>
  7. 7. Examining the Permissions Field <ul><li>The first slot indicates whether the listing is for a directory, a plain file, or a special UNIX file. </li></ul><ul><li>A “c” or “b” at the beginning of many permissions fields indicates whether the device processes data in units of single characters or in whole blocks. </li></ul><ul><li>The remainder of the permissions field is divided into three sets of three slots each. </li></ul>
  8. 8. Examining the Permissions Field Permission Field For Users
  9. 9. Examining the Permissions Field <ul><li>File permissions: </li></ul><ul><ul><li>An owner has full powers over the assignment of permissions to self, its group members, and others. </li></ul></ul><ul><ul><li>The rwx value for the first slot indicates that the user has read, write, and execute permissions for the file. </li></ul></ul><ul><ul><li>Every file has an associated permissions field for user, group, and all others on the system. </li></ul></ul>
  10. 10. Employing Read and Write Permissions <ul><li>To access the contents of a file, a user must have read permissions for that file. </li></ul><ul><li>To make changes to or modify a file, a user needs write permissions for that file. </li></ul>
  11. 11. Changing Permissions for a File to Read Only Assigning Read Only Permission
  12. 12. Changing Permissions for a File to Write Only Assigning Write Permission
  13. 13. Using Execute Permissions with a File <ul><li>The “vi” editor can be used for creating a shell script. </li></ul><ul><li>The “source” command in the C shell and the “dot” (.) command in the Korn or Bourne shell instruct the shell to read the file and execute each commands in it. </li></ul><ul><li>The process id (PID) of the current shell can be determined with the help of the “$$” sign. </li></ul>
  14. 14. Using Execute Permissions with a File <ul><li>A file with the appropriate execute permission can run a shell script like any other UNIX command by typing its name and pressing the ENTER key. </li></ul><ul><li>The “+x” option instructs chmod to grant execute permission for a file. </li></ul><ul><li>When a script is run by entering its name, the current shell starts a child shell that reads the script file and runs the listed commands. </li></ul>
  15. 15. Using Execute Permissions with a File <ul><li>The read permission is sufficient when sourcing a script, because the current shell needs to read it. </li></ul><ul><li>A user must have both, execute and read permissions, to run a script in a child process. </li></ul><ul><li>Only the owner of a file or directory can modify the permissions that are attached to it. </li></ul>
  16. 16. Changing File Permissions Using Mnemonics <ul><li>The “chmod” command can accept permission settings in the form of letter arguments or numbers. </li></ul><ul><li>The mnemonic assignment method allows a user to set permissions for each type of user in several ways. </li></ul>
  17. 17. Changing File Permissions Using Mnemonics <ul><li>Assigning specific permissions. </li></ul><ul><li>Adding and deleting permissions. </li></ul>
  18. 18. Assigning Specific Permissions Assigning All Permissions to All Users
  19. 19. Assigning Specific Permissions Assigning Specific Permissions to Specific Users
  20. 20. Adding and Deleting Permissions Denying Specific Permission to Specific Users
  21. 21. Changing File Permissions Numerically <ul><li>Numbers can also be used for conveying permissions information for all the three types of users. </li></ul><ul><li>The number 700 specifies the rwx permissions only for the owner of a file. </li></ul><ul><li>The numerical approach allows a user to specify the exact permissions to be granted regardless of the current permission. </li></ul>
  22. 22. Changing File Permissions Numerically <ul><li>Combination permissions are specified using the sum of the values for the specific permissions. </li></ul><ul><li>The primitives (0, 1, 2, and 4) can be added to grant any combination of permissions. </li></ul><ul><li>The combination of the three numbers 1, 2, and 4 can be used to express the eight possible combinations of execute, write, and read permissions. </li></ul>
  23. 23. Changing File Permissions Numerically Numerical Combination of Permissions
  24. 24. Changing File Permissions Numerically Permission Values
  25. 25. Changing File Permissions Numerically Basic File Permissions
  26. 26. Changing Permissions for Group and Other <ul><li>Permissions are usually most restrictive for other, less so for group, and least restrictive for the owner of a file. </li></ul><ul><li>The process of determining the impact of permissions for a file or directory begins with the determination of the owner of the file, followed by all sets of permissions assigned to it. </li></ul>
  27. 27. Exploring the Effect of Granting Different Permissions <ul><li>Changing the permissions of a file does not impact the current directory or the inode. </li></ul><ul><li>The permissions of a file are recorded in the inode. </li></ul><ul><li>Write permissions are required for removing a file. </li></ul>
  28. 28. Modifying Directory Permissions <ul><li>Directories have the same kind of permissions fields as regular files, except that there is a “d” in the leftmost position. </li></ul><ul><li>Permissions are assigned to directories with the same letters and numbers that assign permissions to files. </li></ul><ul><li>Directories are special files containing the name of each file or directory along with its associated inode number. </li></ul>
  29. 29. Modifying Directory Permissions <ul><li>Using permissions to control directory access. </li></ul><ul><li>Listing the files in a directory. </li></ul><ul><li>Denying write permissions for a directory. </li></ul><ul><li>Examining the need for execute permissions. </li></ul><ul><li>Changing permissions for files in all subdirectories. </li></ul><ul><li>Identifying other system permissions. </li></ul>
  30. 30. Using Permissions to Control Directory Access <ul><li>The owner of a directory has the power and responsibility for setting the directory access permissions. </li></ul><ul><li>Like file permissions, directory permissions include read, write, and execute. </li></ul><ul><li>The “d” option instructs ls to provide a listing of information about the directory. </li></ul>
  31. 31. Using Permissions to Control Directory Access <ul><li>The inode contains all the information about a file, including permissions, owner, date of creation, links, and addresses of data blocks on the hard drive where the file’s content resides. </li></ul><ul><li>A file is accessed by first retrieving its inode number, then examining its permissions, accessing the data block addresses, and then accessing the file itself. </li></ul>
  32. 32. Listing the Files in a Directory <ul><li>Permissions for a directory are contained in the inode listed next to the current directory. </li></ul><ul><li>Permissions for files are listed in the inodes listed next to the filenames in the current directory. </li></ul><ul><li>Read permissions are required for reading the directory contents as well as to get a listing of its files. </li></ul>
  33. 33. Denying Write Permissions for a Directory <ul><li>Write permissions must be granted before a user can modify the contents of the file or directory. </li></ul><ul><li>A new file cannot be added or an existing file cannot be removed if appropriate write permissions are not assigned. </li></ul>
  34. 34. Examining the Need for Execute Permissions <ul><li>Execute permissions have a different impact on a directory than on a file. </li></ul><ul><li>A directory cannot be listed if it does not have execute permissions. </li></ul><ul><li>A file cannot be accessed if the directory does not have execute permissions. </li></ul>
  35. 35. Examining the Need for Execute Permissions <ul><li>The files in a subdirectory within the parent directory cannot be accessed if there are no execute permissions on the parent directory. </li></ul><ul><li>With only execute permission on a directory, a user can “cd” into it, but cannot get a listing of its files. </li></ul><ul><li>The permissions on directories are specified for user, group, and other in the same fields of the long listing that are associated with file permissions. </li></ul>
  36. 36. Changing Permissions for Files in all Subdirectories <ul><li>The “chmod” utility can be used to change the permissions for all files in a directory and even for all its subdirectories. </li></ul><ul><li>The “–R” option, when specified with the chmod utility, allows permissions to be applied recursively to all child directories and files encountered. </li></ul>
  37. 37. Identifying Other System Permissions <ul><li>The “s” and “t” are some of the permissions that can only be set by the super user. </li></ul><ul><li>The executable passwd file is a program that users run to change their passwords. </li></ul><ul><li>Encrypted passwords are kept in the password file /etc/passwd or in /etc/shadow, depending on the system. </li></ul><ul><li>Ordinary users do not have write permissions on the password files. </li></ul>
  38. 38. Identifying Other System Permissions <ul><li>The root user has “s” and “r” permissions on the passwd file, where s in the owner field indicates that anyone who has permission to execute the program executes it, the program runs as though root is running it. </li></ul><ul><li>When an ordinary user runs passwd, the s tells the system that while running the passwd program, the user has root’s identity. </li></ul>
  39. 39. <ul><li>The group ID of the program needs to be turned on if an administrator wishes to restrict users from executing specific programs. </li></ul><ul><li>A “t” in the last permission slot for a directory puts limits on who can remove files. </li></ul>Identifying Other System Permissions
  40. 40. Identifying Other System Permissions <ul><li>A user cannot remove a file even though they have write permissions on the directory. </li></ul><ul><li>The t bit is a sticky bit, which, when set, permits only the owner of a file to delete or change the name of the file in the directory. </li></ul>
  41. 41. Setting Permissions when Files and Directories are Created <ul><li>The three ways of creating files in UNIX are: </li></ul><ul><ul><li>By copying an existing file. </li></ul></ul><ul><ul><li>Using a “tee” utility. </li></ul></ul><ul><ul><li>Redirection from a shell command. </li></ul></ul>
  42. 42. Setting Permissions when Files and Directories are Created <ul><li>Examining the default permissions. </li></ul><ul><li>Specifying default permissions for directories with umask. </li></ul>
  43. 43. Examining the Default Permissions <ul><li>The operating system initially sets permissions for the owner as read and write when a file is created. </li></ul><ul><li>These default permission settings are determined by the umask value. </li></ul><ul><li>The umask value determines which permissions are masked from being set. </li></ul>
  44. 44. Examining the Default Permissions <ul><li>The umask setting determines the value of permissions for new files as they are created. </li></ul><ul><li>Changing the umask has no effect on an existing file. </li></ul><ul><li>The umask setting is initially determined by default on the system, but can be modified from the shell command-line. </li></ul>
  45. 45. Specifying Default Permissions for Directories with umask <ul><li>A directory created while umask is 000 has full permissions granted to user, group, and other. </li></ul><ul><li>A directory once created with umask can be modified with the chmod command. </li></ul>
  46. 46. Specifying Default Permissions for Directories with umask Umask Values
  47. 47. Examining the Impact of umask on Other Operations <ul><li>The value of umask determines the initial permissions when files and directories are created. </li></ul><ul><li>The “cp” command directly copies the permissions of the source file to the destination file if the umask is not set. </li></ul><ul><li>The “–p” option, when specified, instructs the cp utility to ignore the umask when copying files. </li></ul>
  48. 48. Examining the Impact of umask on Other Operations <ul><li>The “cat” utility can also be used for duplicating a file with the original permissions without applying the umask effect. </li></ul><ul><li>The shell follows umask instructions when creating files. </li></ul><ul><li>Permissions are added up to the limit set by umask when mnemonic arguments are used for specifying permissions in the chmod command. </li></ul>
  49. 49. Summary <ul><li>Read permission is needed to access a file’s contents with a utility. </li></ul><ul><li>Write and execute permissions are required for adding a file, removing a file, or changing a file’s name in a directory. </li></ul><ul><li>A user must have the execute permission to cd into a directory or include the directory in a path. </li></ul>
  50. 50. Summary <ul><li>Letters or numbers can be used for specifying permissions information in the chmod command. </li></ul><ul><li>Read and execute permissions are required by a script file to execute as a child process. </li></ul><ul><li>Files and directories are granted initial permissions at creation determined by the umask setting at the time that the file or directory is created. </li></ul>
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×