Changes

Jump to: navigation, search
no edit summary
When '''directories''' and r'''egular files''' are created, they are assigned to an '''owner'''<br>(typically the username which is the creator).
To ''allow'' or ''limit'' '''access''' to those<br>files and directories, those files and directories are assigned to an <br>initial '''group''' referred to as a "'''primary group'''".[[Image:directory-permissions.png|thumb|right|350px|Permissions of a '''directory''' that contain subdirectories and regular files.]]Users that <u>own</u> those ''directories'' and ''regular files'' are referred to as '''users''', users that belong within the <u>same group</u> are referred to as '''same group members''', and those users that do <u>NOT</u> belong to a particular group are referred to as '''other group members'''.
Users that <u>own</u> those ''directories'' and ''regular files'' are referred to as '''users''', users that belong within<br>the <u>same group</u> are referred to as '''same group members''', and those users that<br>do <u>NOT</u> belong to a particular group are referred to as '''other group members'''. '''NOTE:''' In this course, we CANNOT create groups or assign users to groups in the '''Matrix''' server.<br>Instead, you may learn how to those tasks when or if you take a Unix/Linux administration course.<br>On the other hand, you can change which '''user''', '''same group members''' or '''other group members'''<br>can access or NOT access a directory or regular file.<br><br>[[Image:directoryfile-permissions.png|thumb|right|350px|Permissions of a '''directoryregular file''' that contain subdirectories and regular filescontained within a directory.]]
File Permissions consist of '''two-layers''':<br><br>'''First''', the permissions of a '''directory''' that contains regular files, and '''second''', permissions of the ''subdirectories and/or regular files'' within that directory.
A symbol ''dash'' "'''-'''" indicates that the permission has '''NOT''' been granted.
[[Image:file-permissions.png|thumb|right|350px|Permissions of a '''regular file''' contained within a directory.]]The permissions of '''newly-created''' directories and regular files are automatically assigned<br>via a '''user mask''' (we will discuss this shortly). In order to change permissions for <br>directories and regular files, you would use the '''chmod''' command.
'''Changing File Permissions with "chmod" command:'''
[[Image:symbolic-chart.png|thumb|right|550px|Examples of adding, removing and setting permissions using the '''chmod''' command with the '''Symbolic''' method.]]
 
'''<span style="font-style:italic">Symbolic Method:</span>'''
The chmod can use '''symbols''' to ''add'', ''remove'', and ''set'' <span style="font-family:courier;font-weight:bold;">rwx</span> permissions for the '''user''',<br>'''same group members''', and/or o'''ther group members''' for a directory or reqular file.
 [[Image:symbolic-chart.png|thumb|left|550px|Examples of adding, removing and setting permissions using the '''chmod''' command with the '''Symbolic''' method.]]<br><br><br><br><br><br><br><br><br><br><br>
'''<span style="font-style:italic">Octal (Absolute) Method:</span>'''
[[Image:octal-permissions.png|thumb|right|150px|Using octal numbers to represent setting file permissions.]]
Since 1 octal digit represents 3 binary digits, one octal digit can represent the <span style="font-family:courier;font-weight:bold;">rwx</span> permission granted or NOT granted. The permissions '''rwx''' are be in the form of 3 binary digits (1 represents the permission granted and 0 represents the permission NOT granted).
[[Image:absolute-chart.png|thumb|left|550px|Examples of adding, removing and setting permissions using the '''chmod''' command with the '''Absolute / Octal''' method.]]
<br><br><br><br><br><br><br><br><br>
'''NOTE:''' You can use the '''-R''' option to set permissions for directory, subdirectory and directory contents '''recursively'''.
  <table align="right"br><trbr><td>[[Image:umask-directory.png|thumb|right|200px|Setting '''umask''' for newly-created '''directories'''.]]</td><td>[[Image:umask-file.png|thumb|right|200px|Setting '''umask''' for newly-created '''regular files''']]</td></tr></tablebr>
'''Setting Permissions for Newly-Created Directories and Regular Files (umask):'''
<table align="right"><tr><td>[[Image:umask-directory.png|thumb|right|150px|Setting '''umask''' for newly-created '''directories'''.]]</td><td>[[Image:umask-file.png|thumb|right|150px|Setting '''umask''' for newly-created '''regular files''']]</td></tr></table>
The '''umask''' command is used to set the permissions of newly-created directories and regular files.
 
Issuing the '''umask''' command without arguments will display the current umask value.
=INVESTIGATION 1: NUMBERING CONVERSIONS=
<span style="color:red;">'''ATTENTION''': Depending on your ULI101 instructor, you may be required to complete this tutorial for '''marks''' in this course.<br>Please refer to your instructor's course notes and lecture notes regarding evaluation for this course.<br><br>The due date for successfully completing this tutorial (i.e. '''tutorial 4''') is by '''Friday by midnight''' next week (i.e. '''Week 5''').<br>If your instructor has NOT assigned marks for completing this tutorial, you can perform it for '''practice'''.</span><br><br>
For this investigation, we will NOT be logged into our Matrix account, but it is recommended to have an '''MS Word document'''<br>open to manually perform numbering conversions.
[[Image:file-permission-practice-1.png|right|250px|thumb|]]
In this sectioninvestigation, you will get experience using the '''chmod''' command to '''change permissions'''<br>for <u> existing</u> files and the using '''umask''' command to automatically set permissions<br>for <u>newly-created</u> files.
# '''Login''' to your matrix account and issue a command to '''confirm''' you are located in your '''home''' directory.<br><br>
# Issue a single Linux command to create the following directory structure displayed in the diagram to the right.<br><br>'''NOTE:''' You will now run a shell script to confirm that you properly created that directory structure<br>in your ''Matrix'' account.<br><br>
# Issue the following Linux command to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts~uli101/week4-check-1</span><br><br>
# If you encounter errors, make corrections and '''re-run''' the checking script until you<br>receive a congratulations message, then you can proceed.<br><br>[[Image:file-permission-practice-2.png|right|450px|thumb|]]
# Issue Linux commands to create '''<u>empty</u> files''' for each of those newly created '''directories''' as shown in diagram to the right:<br><br>'''NOTE:''' You will now run another shell script to confirm that you properly created those empty files within those specified directories.<br><br>
# Issue the following Linux command to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts~uli101/week4-check-2</span><br><br>
# If you encounter errors, make corrections and '''re-run''' the checking script until you<br>receive a congratulations message, then continue the remaining steps.<br><br>Let's get practice '''viewing permissions''', '''changing permissions''', and <u>automatically</u> '''setting permissions for newly created files'''.<br><br>
# Issue the following Linux commands:<br><span style="color:blue;font-weight:bold;font-family:courier;">ls -ld ~/documents ~/clients ~/vendors<br>ls -lR ~/documents ~/clients ~/vendors</span><br><br>'''NOTE:''' You should see permissions already set for those newly created directories and regular files.<br>What do these permissions mean for '''same group member''' and '''other group member''' access to those directory and regular files?<br><br>
# Issue the following Linux commands: <br><span style="color:blue;font-weight:bold;font-family:courier;">chmod 640 ~/documents/memos/memo*.txt<br>chmod 640 ~/documents/reports/report*.txt<br>chmod 640 ~/documents/contracts/contract*.txt</span><br><br>
# Issue the <span style="font-weight:bold;font-family:courier;">ls -lR</span> command for the '''~/documents''' directory to confirm that those regular file permission have changed.<br><br>Let's run a checking script to make certain you correctly set permissions for those directories and files.<br><br>
# Issue the following: <span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts~uli101/week4-check-3</span><br><br>
# If you encounter errors, make corrections and then re-run the checking script until you receive a congratulations message<br>and then continue with this tutorial.<br><br>Let's get some practice setting permissions to allow users to make editing changes to regular files.<br><br>
# Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">chmod ugo-w ~/documents/memos/memo*.txt</span><br><br>
# To <u>'''abort'''</u> your editing session in '''vi''': type <span style="color:blue;font-weight:bold;font-family:courier;">:q!</span> and press '''ENTER'''.<br>To <u>'''abort'''</u> your editing changes in '''nano''': type <span style="color:blue;font-weight:bold;font-family:courier;">ctrl-x</span><br>type <span style="color:blue;font-weight:bold;font-family:courier;">n</span> and then press '''ENTER''' when prompted to save editing changes.<br><br>
# Issue the following Linux command to add write permissions for all files in the '''memos''' directory<br>for yourself (i.e. user): <span style="color:blue;font-weight:bold;font-family:courier;">chmod u+w ~/documents/memos/*</span><br><br>
# Repeat steps to edit the file '''~/documents/memos/memo1.txt''' (as you did in ''step #20''). <br>Were you able to edit the file and save your editing changes?<br><br># Issue a Linux command to view the <u>contents</u> of the '''~/documents/memos/memo1.txt'''<br>text file that you were able to edit.<br><br>
# Issue the following Linux command to view permissions for your '''home''' directory: <span style="color:blue;font-weight:bold;font-family:courier;">ls -ld ~</span><br><br>What does execute permissions mean for same group members and other group members<br>in terms of your '''home''' directory?<br><br>
# Issue the following Linux command to create a new subdirectory: <span style="color:blue;font-weight:bold;font-family:courier;">mkdir ~/shared</span><br><br>
# Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls -ld ~/shared2</span><br><br>Do the permissions for this newly created directory match the predicted permissions that you calculated in '''step #30'''?<br><br>
# Issue the following Linux command to create an empty regular file called '''myfile.txt''' in the '''~/shared2''' directory:<br> <span style="color:blue;font-weight:bold;font-family:courier;">touch ~/shared2/myfile.txt</span><br><br>
# Use the <span style="font-weight:bold;font-family:courier;">ls -l</span> command to view the permissions for this newly created regular file.<br><br>What do you notice about those permissions?<br><br>Let's run a checking script to make certain you correctly set permissions for those recently-created directories and files.<br><br># Issue the following: <span style="color:blue;font-weight:bold;font-family:courier;">~uli101/week4-check-4</span><br><br>If you encounter errors, make corrections and then re-run the checking script until you receive a congratulations message<br>and then continue with this tutorial.<br><br>
# Logout of your Matrix account, and then log-back into your Matrix account.<br><br>
# Issue the following Linux command (without arguments): <span style="color:blue;font-weight:bold;font-family:courier;">umask</span><br><br>What happened? Referring to your notes, what do you need to do to make that umask value persistent?<br><br><span style="color:red;">'''WARNING''':<br>You should be <u>extremely</u> aware of your permissions since you may perform '''assignments''' for <u>other</u> courses on your '''Matrix''' server.<br>You should NOT set permissions to share your work with '''same group''' or '''other group''' members (unless given '''specific permissions instructions from your course professors''' involving '''assignment submission'''). If students can have access to your directories and assignment files, they could '''copy''' your work and thus make yourself and other student(s) that copied your assignment work<br>to be charged with '''academic dishonesty'''.</span><br><br># : After you complete the Review Questions sections to get additional practice, then work on your '''online assignment 2'''<br>and complete the sections '''1''' and '''2''' labelled: '''Practice Using The vi Text Editor''' and '''Permissions''' respectively.<br><br>
= LINUX PRACTICE QUESTIONS =
13,420
edits

Navigation menu