Tutorial Sheet 4.doc

advertisement
CST334
Tutorial Sheet 4
Chapter 4
SECURITY & FILE PERMISSIONS
FILE ACCESS PERMISSIONS -- only the user (owner) of a file can change
1. find out the access codes for a file:
ls -l
2. example access codes, who has permission to read write and execute:
3. change the access permission for a file:
chmod cntrl file
cntrl is a combination of field selector (u,g,o,a) change specifier ( +, -, =) and access (r, w, x)
For example: ug+w turns on write access for user and group, other permissions are unchanged
ug=w sets user and group access to write only. all other permission is disabled
a=rx Sets read and execute permission for all -- user, group, and other
4. turn off all access to a file for group and others: chmod go= file
5. turn off read access to a file for user:
(access field is blank)
chmod u-r file
6. turn on read, write, and execute permission for group: chmod g+rwx, or chmod g=rwx
7. verify changes to access permission: ls -l
================================
DIRECTORY ACCESS PERMISSIONS
8. show the access permission of a directory
ls -ld
9. visit trebold's home directory: cd ~trebold
10. access to allow ONLY listing the contents of a directory: r-11. access to allow listing and reading the files in a home directory, but not write: r-x
===================================
LINKING FILES – Hard Links:
ln
Soft Links: ln –s (soft are like shortcuts in Microsoft)
12. create a hard link to a file: ln old_file new_link
13. create a soft link to a file: ln –s old_file new_link
ln bio bio.lnk
ln –s bio bio.slnk
Download