Changes

Jump to: navigation, search
no edit summary
{{Admon/caution|DO NOT USE THIS VERSION OF THE LAB. This page will no longer be updated.|'''New version here:''' https://seneca-ictoer.github.io/ULI101/A-Tutorials/tutorial4<br />'''Andrew's students please go here:''' http://wiki.littlesvr.ca/wiki/OPS145_Lab_4}}
=Data Representation / Numbering Conversion / File Permissions=
===Main Objectives of this Practice Tutorial===
:* Understand the importance of how digital computers store data (i.e. data representation)
:* Understand the purpose of Define '''decimal''', '''binary''', '''octal''' and '''hexadecimal''' numbers
:* Perform various Manually perform '''numbering conversions''' between the '''decimal''', '''binary''', '''octal''' and '''hexadecimal''' numbering systems<br>by hand (<u>without</u> the use of a computer or calculator)
:* Identify Explain the purpose of '''which numbering system conversion method to usefile permissions''' when required to perform a numbering conversion
:* Understand directory and regular file Explain how permissions work differently for '''directories''' as opposed for '''permissionsregular files'''
:* Learn how to '''set''' directory and regular Change file '''permissions''' with the '''chmod''' command (both ''symbolic '' and octal ''absolute'' methods)
:* Learn how to use Use the '''umask''' command to have automatically assign permissions for '''newly created directories ''' and files automatically set upon their '''creationregular files'''<br><br>
===Tutorial Reference Material===
|- valign="top" style="padding-left:15px;"
|colspan="1" width="22%" |'''Slides:'''<ul><li>Week 4 Lecture 1 Notes:<br> [https://wiki.cdot.senecacollege.ca/uli101/slides/ULI101-4.1.pdf PDF] | [https://ictwiki.cdot.senecacollege.ca/~murrayuli101/slides/ULI101-4.1.pptx PPTX]</li><li>Week 4 Lecture 2 Notes:<br> [https://wiki.cdot.senecacollege.saulca/uli101/slides/ULI101-Week44.2.pdf PDF] | [https://ictwiki.cdot.senecacollege.ca/~murray.saululi101/uli101slides/ULI101-Week44.2.pptx PPTX]<br></li></ul>
| style="padding-left:15px;" | '''Data Representation Definitions:'''
* [https://home.adelphi.edu/~siegfried/cs170/170l1.pdf Data Representation]<br>
* [https://en.wikipedia.org/wiki/Decimal Decimal Numbers]
* [https://en.wikipedia.org/wiki/Hexadecimal Hexadecimal Numbers]<br>
| style="padding-left:15px;"|'''File Permission Concepts:'''
* [https://www.booleanworld.com/introduction-linux-file-permissions/ Introduction to File Permissions]<br><br>
'''File Permission Commands:'''<br>* [httphttps://man7ss64.org/linux/man-pagescom/man1bash/chmod.1.html chmod]<br>* [httphttps://man7ss64.orgcom/linux/man-pages/man1bash/umask.1p.html umask]<br><br>
|colspan="1" style="padding-left:15px;" width="30%"|'''Instructional Videos:'''* [https://www.youtube.com/watch?v=L2zsmYaI5ww 4nGgqLIKU9U Numbering Conversions]
* [https://www.youtube.com/watch?v=SdgiYoOi0CY File Permissions]
|}
= KEY CONCEPTS =
===Why Study Data Representation?===[[Image:binary-number1.png|right|200px|https://creativecommons.org/licenses/by-sa/3.0/ cc]]Digital computers are '''electronic devices''' that contain a series of '''circuits''' and voltage levels that can store / represent data.
<table align="right"><tr valign="top"><td>[[Image:binary-number1.png|thumb|right|220px|A series of '''binary Binary numbers''' form a '''byte''' to can represent '''numbers'''those series of circuits with voltage levels.<br>Image licensed under [https://creativecommons.org/licenses/by-sa/3.0/ cc].]]</td><td>[[Image:Those binary-number-2.png|thumb|right|200px|'''Bytes''' can be used numbers are combined in a sequence to also represent form a '''charactersbyte'''. It is job of a program to know if bytes Bytes are used to represent numbers or characters. Learning to convert numbering systems<br>(like '''Hexadecimal to Binary''') can be used to know how a character is represented in '''binary'''. <br>Image licensed under [https://creativecommons.org/licenses/by-sa/3.0/ cc].]]</td></tr></table>''Data (treated as singular, plural, or as a mass noun) is any sequence of one or more symbols given meaning by specific act(s) of interpretation.Digital data is data that is represented using the binary number system of ones (1) and zeros (0), as opposed to analog representation.''<br>Reference: https://enrepresent numbers or characters.wikipedia.org/wiki/Data_(computing)<br><br>
Therefore, computers process and store information in a binary number system consisting of 0s and 1s. For many aspects of programming and networking, the details of '''data representation''' must be understood.
IT professionals may need to perform '''numbering conversion'''Reasons to Understand Data Representation:use with<br>''programming functions'' or ''OS commands'' to perform common operations on a computer system.
* ''C ProgrammingIT Professionals that Use Data Representation:'' Sending information over networks, files* ''Web Development:'' Setting color codes for webpage background or text * ''Allowing or Limiting Unix / Linux File Access:'' Setting ''permissions'' for files and directories
* ''Network Specialists'': Building Large Networks via Sub-netting
* ''Programmers:'' Sending information over networks, files
* ''Web Developers:'' Setting color codes for webpage background or text
* ''Unix/Linux System Administrators:'' Setting ''permissions'' for files and directories
<br>
In terms of this course, we will learn how ===Numbering Conversion Methods=== ====<u>Method 1: Binary to Decimal</u>==== [[Image:convert-bin-decimal.png|thumb|right|350px|Performing a simple '''binary''' to '''decimal''' conversion.]]When converting '''binary''' numbers to '''decimal ''' numbers, perform the following steps:<br><br># Write down the binary number.<br># Starting from the '''right-side''', draw '''L''''s below the binary number moving to the left<br>(refer to diagram on right).<br># Starting on the ''rightmost'' "'''L'''", multiply the value (integerplaceholder) is stored into by '''2''' to the computer system as a binary numberpower of zero. We will also learn other numbering systems <br># Continually repeat '''step #3''' moving leftwards, increasing the power of ''2'' by '''1'''<br>(refer to diagram on right).<br># Add up the results to obtain the decimal value equivalent.<br><br>'''NOTE:''' To convert ''octal '' and ''hexadecimal'' numbers to '''decimal''', replace the number <span style="color:red;font-weight:bold">2</span> <br>(in red in the diagram to the right) that can be used as a with <span style="color:red;font-weight:bold">8</span> (for ''octal'') or <span style="shortcolor:red;font-cutweight:bold" to represent binary numbers>16</span> (for ''hexadecimal'').
<br><br>
==== <u>Method 2: Decimal / to Binary </ Octal / Hexadecimal Numbering Systemsu> ====
[[Image:decimal-numberto-2bin.png|thumb|right|300px275px|The Performing a '''decimal''' numbering system to '''binary''' conversion.]]When converting '''decimal''' numbers to '''binary''' numbers, perform the following steps:<br><br>Image licensed under [https:# Write down the '''decimal number''' to be converted.# On the ''right-side'', write the number '''1''' and moving '''leftwards''', keep <u>doubling<//creativecommonsu> the numbers until that number is '''greater than''' the decimal number to be converted (refer to the diagram on the right).org/licenses/by<br># Starting on the left-sa/3side of those doubled numbers, compare that number with the decimal number. If that number if less than or equal to the decimal number, then write a '''1''' below and subtract that number from the decimal number to get a remainder.If the number is greater than decimal number (or remainder), then write a '''0/ cc] ''' below.<br><br># Repeat '''step #3''' (modified by authormoving rightwards and comparing the number with the decimal's remainder)<br><br>'''NOTE:''' If you are converting to '''8-bit''', '''32-bit''', etc.]], add '''leading zeros'Decimal Numbers''if necessary.<br><br>
The '''decimal''' numbering system is a numbering system where each digit can be represented by numbers 0 - 9. The reason for this system may be attributed ==== <u>Method 3: Octal to the fact that humans were used Binary / Binary to counting on their fingers and thumbs.Octal</u> ====
The <table align="right"><tr><td>[[Image:bin-to-octal.png|thumb|right|230px|Performing an '''binary to octal''' numbering conversion.]]</td><td>[[Image:octal-to-bin.png|thumb|right|275px|Performing an '''octal to binary''' numbering system is based on sums conversion.]]</td></table> ''Binary to Octal'' # '''One octal number''' represents '''3 binary numbers''', so '''starting from right-side''', group binary digits into '''groups of 3'''<br>(add leading zeros if necessary).# Write '''(4)(2)(1)''' under <u>each</u> '''group of 3 binary numbers'''.# Multiply the value or "placeholder" (i.e. '''0''''s and '''1''''s) by the corresponding '''(4)(2)(1)''' for each group to obtain the power octal number (refer to diagram of 10''binary to octal'' conversion).<br><br>
According ''Octal to the diagram to the rightBinary'' # '''One octal number''' represents '''3 binary numbers''', each digit moving to the left of units value is so space-out<br>the placeholder multiplied octal numbers to the power of tenmake space for a binary number. Units are ten to the power of zero # Write '''(4)(2)(which is 1), tens are ten to the power of one, etc.''' under <bru>each<br/u>[[Image:binary-octal number-3.png|thumb|right|200px|The # Write '''0''''s or '''1''''s for each group of binarynumbers to add up to the<br>corresponding octal number (refer to diagram of ''octal to binary' numbering system' conversion).<br>Image licensed under [https<br> ==== <u>Method 4:Hexadecimal to Binary /Binary to Hexadecimal</creativecommons.org/licenses/by-sa/3.0/ cc].]]''Binary Numbers''u> ====
The <table align="right"><tr><td>[[Image:bin-to-hex.png|thumb|right|275px|Performing a '''binaryto hexadecimal''' numbering system is a numbering system where each digit can be represented by numbers 0 or 1conversion. Digital computers have data]]</td><td>[[Image:hex-to-paths that can represent those 0s and 1s based on voltage levelsbin.png|thumb|right|350px|Performing a '''hexadecimal to binary''' conversion.]]</td></tr></table>''Binary to Hexadecimal''
The numbering system is based on sums # '''One hexadecimal number''' represents '''4 binary numbers''', so starting from right-side, group binary digits into '''groups of 4''' (add leading zeros if necessary).# Write '''(8)(4)(2)(1)''' under <u>each</u> group of 4 binary numbers.# Multiply the values or "placeholders" (i.e. '''0''''s and '''1''''s) by the power of corresponding (8)(4)(2)(1) for each group to obtain the octal number.# Convert values from '''10''' to '''15''' to '''A''' to '''F'''<br>(refer to diagram of ''binary to hexadecimal'' conversion)<br><br>
According to the diagram to the right, each digit moving to the left of units value is the placeholder multiplied to the power of two. Units are ten to the power of zero (which is 1), then two to the power of one (which is 2), etc.<br><br>''Octal / Hexadecimal Numbers''<table align="right"><tr valign="top"><td>[[Image:octal-number-2.png|thumb|right|200px|The '''octal''' numbering system.<br>Image licensed under [https://creativecommons.org/licenses/by-sa/3.0/ cc].]]</td><td>[[Image:hex-number-2.png|thumb|right|420px|The to Binary'''hexadecimal''' numbering system.<br>Image licensed under [https://creativecommons.org/licenses/by-sa/3.0/ cc].]]</td></tr></table>The '''octal''' and ''hexadecimal'' numbering systems are represented by values of 0 - 7 and 0 - F respectively. For hexadecimal numbers, values for 10 to 15 (which can only be represented by a single digit) use letters a to f respectively.
The numbering system is based on sums # '''One hexadecimal number''' represents '''4 binary numbers''',<br>so space-out the hexadecimal numbers to make space for a binary number.# Convert letters '''A''' to '''F''' to '''10''' to 15 (refer to diagram of ''binary to hexadecimal'' conversion)# Write '''(8)(4)(2)(1)''' under <u>each</u> hexadecimal number.# Write '''0''''s or '''1''''s for each group of binary numbers to add up to the power corresponding<br>hexadecimal number (refer to diagram of 2''hexadecimal to binary'' conversion).<br><br>
According to the diagram to the right, each digit moving to the left of units value is the placeholder multiplied to the power of two. Units are ten ==== <u>Method 5: Octal to the power of zero (which is 1), then two Hexadecimal / Hexadecimal to the power of one (which is 2), etc.<br>Octal<br/u>====
===Numbering Conversion Methods===[[Image:octal-hex.png|thumb|right|275px|For conversions between octal and hexadecimal numbers, use binary as a '''bridge'''.]]To convert using the method, simply use binary as a "'''bridge'''".
''Example:''
====Method 1: Binary To convert octal to Decimal====hexadecimal, convert octal to binary, then convert binary to hexadecimal.
[[Image:To convert-bin-decimal.png|thumb|right|350px|Performing a '''binary''' hexadecimal to '''decimal''' conversion.]]When converting '''binary''' numbers octal, convert hexadecimal to '''decimal''' numbers, perform the following steps:<br><br># Write the binary number (space between the digits).<br># Starting from the right-side, draw '''L''''s moving to the left (refer to diagram on right).<br># Starting on the right, multiply the number by 2 to the power of zero.<br># Repeat moving to the left, but increase the power by 1 each time.<br># Add up the calculations to obtain the decimal value equivalent.<br><br><br>'''NOTE: To then convert other numbering system binary to decimal, replace the number <span style="color:red;font-weight:bold">2</span> <br>(in red in the diagram to the right) with <span style="color:red;font-weight:bold">8</span> (for octal) or <span style="color:red;font-weight:bold">16</span> (for hexadecimal)'''.
<br><br>
===File Permissions= Method 2== [[Image: Decimal listing-file-directory.png|thumb|right|400px|Detailed directory listing showing permissions for a '''directory'''<br>and a '''regular file'''.]]Since Unix / Linux operating file systems allow for '''multiple user accounts'''<br>it is essential to Binary ====have a system to '''share''' or '''limit''' access to directories and files contained within the file system.  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'''.
[[Image:decimal-to-bin.png|thumb|right|275px|Performing a '''decimalNOTE:''' In this course, we CANNOT create groups or assign users to groups in the '''binaryMatrix''' conversionserver.]]When converting '''decimal''' numbers Instead, you may learn how to '''binary''' numbers, perform the following steps:<br><br># those tasks when or if you take a Unix/Linux administration course. On the left sideother hand, write the you can change which '''decimal numberuser''' to be converted.# Far to the right, write the '''number 1''' and while moving 'same group members''leftwards'or '', 'other group members''double the number''' until that number is can access or NOT greater than the decimal number to be converted (refer to the diagram)access a directory or regular file.<br><br># If you are converting to 8[[Image:file-bit, 32-bit, etcpermissions., enter png|thumb|right|350px|Permissions of a '''leading zerosregular file''' if those doubled numbers are contained within a directory.]]File Permissions consist of '''greater thantwo-layers''' the decimal number.:<br><br># Moving in a '''rightwardsFirst''' direction, if the doubled number permissions of a '''lessdirectory''' than the decimal numberthat contains regular files, write a '''1''' and subtract the double number's value from the decimal number.<br># If the next doubled number is '''greatersecond''' then , permissions of the remainder, then write a ''subdirectories and/or regular files'zero'''; otherwise, if the number is less than but not zero, repeat the above steps #4 and #5 until you have obtained your binary numberwithin that directory.<br><br><br>
==== Method 3: Octal to Binary / Binary to Octal ====
<table align="right"><tr><td>[[Image:bin-to-octal.png|thumb|right|230px|Performing an Permissions for directories have a different meaning than permissions for '''binary to octalregular files''' numbering conversion.]]</td><td>[[Image:octal-Refer to-bin.png|thumb|the diagrams to the right|275px|Performing an '''octal to binary''' numbering conversionsee the explanation of permissions and how they differ between a directory and a regular file.]]</td></table>
A symbol ''Binary to Octaldash''"'''-'''" indicates that the permission has '''NOT''' been granted.
# One octal number represents 3 binary numbers, so starting from rightThe permissions of '''newly-side, group binary digits into groups of 3 created''' directories and regular files are automatically assigned<br>via a '''user mask''' (add leading zeros if necessarywe will discuss this shortly).# Write (4)(2)(1) under In order to change permissions for<ubr>each</u> group of 3 binary numbers.# Multiply directories and regular files, you would use the placeholders (i.e. 0's and 1's) by the corresponding (4)(2)(1) for each group to obtain the octal number (refer to diagram of 'chmod'binary to octal'' conversion)command.<br><br>
''Octal to Binary''
# One octal number represents 3 binary numbers'''Changing File Permissions with "chmod" command:'''[[Image:symbolic-chart.png|thumb|right|550px|Examples of adding, so space-out removing and setting permissions using the octal numbers to make space for a binary number.# Write (4)(2)(1) under <u>each</u> octal number.# Write 0's or 1's for each group of binary numbers to add up to 'chmod''' command with the corresponding octal number (refer to diagram of ''octal to binary'Symbolic''' conversion)method.<br><br>]]
==== Method 4: Hexadecimal to Binary / Binary to Hexadecimal ====
'''<table alignspan style="rightfont-style:italic"><tr><td>[[Image:bin-to-hex.png|thumb|right|275px|Performing a '''binary to hexadecimal''' conversion.]]</td><td>[[ImageSymbolic Method:hex-to-bin.png|thumb|right|350px|Performing a '''hexadecimal to binary''' conversion.]]</tdspan></tr></table>''Binary to Hexadecimal''
# One hexadecimal number represents 4 binary numbersThe chmod can use '''symbols''' to ''add'', ''remove'', so starting from rightand ''set'' <span style="font-family:courier;font-sideweight:bold;">rwx</span> permissions for the '''user''', <br>'''same group binary digits into groups of 4 (add leading zeros if necessary)members''', and/or o'''ther group members''' for a directory or reqular file.# Write (8)(4)<br><br><br><br>'''<span style="font-style:italic">Octal (2Absolute)(1) under <u>eachMethod:</uspan> group of 3 binary '''[[Image:octal-permissions.png|thumb|right|150px|Using octal numbersto represent setting file permissions.]]# Multiply the placeholders (i.e. 0You can also use '''octal numbers''s and 1's) by the corresponding (8)(4)(2)(1) for each group to obtain '''set''' permissions. This method is a short-cut and may require less typing than using the octal number''symbolic'' method.# Convert values from 10 to 15 to A You can only use this method to F set file permissions (refer as opposed to diagram of ''binary to hexadecimaladd'' or ''remove'' conversion)<br><br>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 ''Hexadecimal to Binary'rwx''' are be in the form of 3 binary digits (1 represents the permission granted and 0 represents the permission NOT granted).
# One hexadecimal number represents 4 binary numbers, so space'''NOTE:''' You can use the '''-out the hexadecimal numbers R''' option to make space set permissions for a binary number.# Convert letters A to F to 10 to F (refer to diagram of directory, subdirectory and directory contents '''recursively'binary to hexadecimal'' conversion).# Write (8)(4)(2)(1) under <ubr><br>each</ubr> hexadecimal number.# Write 0's or 1's 'Setting Permissions for each group of binary numbers to add up to the corresponding hexadecimal number Newly-Created Directories and Regular Files (refer to diagram of umask):''hexadecimal to binary'' conversion).<br><br>
<table align===File Permissions==="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.
x
Issuing the '''umask''' command without arguments will display the current umask value.
Refer to the diagrams on the right-side to set the umask value for directories and regular files.
Setting the umask value (for example umask 022) only takes effect for the current shell session unless the umask command is contained in a start-up file<br>(e.g. '''.profile''', '''.bash_profile''', or '''.bashrc''').
<br><br>
=INVESTIGATION 1: NUMBERING CONVERSIONS=
<span style="color:red;">'''ATTENTION''': This online tutorial will be required to be completed by '''Friday in week 5 by midnight''' to obtain a grade of '''2%''' towards this course</span><br><br>
For this investigation, we will NOT be logged into our Matrix account, but it is recommended to have sheets of paper ready an '''MS Word document'''<br>open to manually perform numbering conversationsconversions.
<span style="color:blue;">'''NOTE:''' It is essential that you learn how to <u>manually </u> perform numbering conversions since you will NOT be permitted to perform quizzes, midterm, or your final exam with a computer or a calculator. Learning to quickly perform manual numbering conversions will may make IT professional more productive such as setting permissions, designing computer networks, or selecting complex colors when developing webpages.</span>
[[Image:calc-check.png|thumb|right|200px|Only use a calculator to check your numbering conversion '''AFTER''' you have performed the operation '''manually'''. ]]
You will now get practice performing numbering conversions.
 
'''Perform the Following Steps:'''
# Let's convert the following ''8-bit'' binary number '''10111110''' to a '''<u>decimal number</u>'''.<br><br><span style="color:blue;">'''NOTE:''' It is extremely important to learn and '''memorize''' the '''correct technique methods''' to perform the<br>proper numbering conversion method (i.e. view the '''method 1''' above (drawing the L's).</span><br><br># Write the manual conversion on a sheet of papereither in your MS Word document.<br><br># Use a '''calculator ''' to check your work. In MS Windows, you can set the calculator to Programming mode <br>by making the selection to '''binary''', enter the binary number '''10111110''' and view the decimal equivalent.<br><br>Did you get the correct answer? If not, <u>retry </u> the method and check to see what you did wrong.<br><br># Perform a manual conversion of the '''decimal number 55''' to an a '''8-bit <u>binary number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># Perform a manual conversion of the '''octal number 461''''''Bold text''' to an a '''8-bit <u>binary number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># Perform a manual conversion of the '''8-bit binary number 11110001''' to a '''<u>hexadecimal number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># Perform a manual conversion of the '''hexadecimal number ABC''' to an a '''8-bit <u>binary number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># Perform a manual conversion of the '''binary number 10101111''' to an '''<u>octal number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># Perform a manual conversion of the same '''binary number 10101111''' to a '''<u>hexadecimal number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># Perform a manual conversion of the '''octal number 5636''' to a '''<u>hexadecimal number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># Perform a manual conversion of the '''hexadecimal number D68''' to an '''<u>octal number</u>'''.<br>What method (displayed above) will you use? Use a calculator to check your work.<br><br># When you have performed all of the numbering conversions above, then you can proceed to the next INVESTIGATION.<br><br>
=INVESTIGATION 2: FILE PERMISSIONS=
[[Image:file-permission-practice-1.png|right|250px|thumb|]]
In this investigation, 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.
 
 
'''Perform the Following Steps:'''
# '''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;">~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;">~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># Let's limit access to the '''clients''' and '''vendors''' directories to only yourself and same group members.<br>Issue the following Linux command:<br><span style="color:blue;font-weight:bold;font-family:courier;">chmod 750 ~/clients ~/vendors</span><br><br># Issue the '''ls -ld''' and '''ls -lR''' commands (as you did in ''step #8'') to confirm that the permissions for those directories have been changed.<br><br>'''NOTE:''' The '''-R''' option for the '''chmod''' command can change the file permissions <u>recursively</u> within a directory structure.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">chmod 750 -R ~/documents</span><br><br># Issue the '''ls -ld''' command to confirm the permissions for the<br>'''~/documents''', '''~/document/memos''' , '''~/documents/reports''', and '''~/documents/contracts''' directories.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls -lR ~/documents</span><br>What do you noticed happened to the permissions for the regular files contained in those directories.<br>Did those regular file permissions change?<br><br>We will now change permissions for regular text file contained in subdirectories<br>of the '''documents''' directory to: <span style="font-weight:bold;font-family:courier;">r w - r - - - - -</span><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;">~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># Use the <span style="font-weight:bold;font-family:courier;">ls</span> command to verify that those regular file's permissions have changed.<br><br># Using the nano or vi text editor, open the regular file '''~/documents/memos/memo1.txt'''<br>and type in some text and try to save your editing changes.<br>What happened?<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 ~/shared</span><br><br>What are the permissions for this newly-created directory?<br>Can other users access the directory pathname '''<span style="font-family:courier">~youruserid/shared</span>''' ?<br><br># Issue the following Linux command (without an argument): <span style="color:blue;font-weight:bold;font-family:courier;">umask</span><br><br>'''NOTE:''' You should see a '''four-digit octal''' number. Drop the leading zero on the left to obtain the '''default umask value'''.<br><br># Perform a '''mathematical calculation''' by taking the octal number '''777''' and <u>subtracting</u><br>the default umask value you determined in the previous step. What is the result?<br><br># Convert that octal number result to a '''binary''' number. What does that represent as newly created directory permissions?<br>Does that correspond to the permissions for the newly created '''~/shared''' directory?<br><br># Repeat the calculation (like in step #28) but with a umask setting of '''077''' to see how this new umask setting would<br>affect permissions of newly-created directories.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">umask 077</span><br><br># Issue the following Linux command (without arguments): <span style="color:blue;font-weight:bold;font-family:courier;">umask</span><br><br>NOTE: You should notice the value '''0077'''. By dropping the leading zero to the left,<br> that would provide the default '''umask value of 077'''.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">mkdir ~/shared2</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 '''marked work''' 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'''). If students can have access to your directories and project files, they could '''copy''' your work and thus make yourself and other student(s) that copied your work to be charged with '''academic dishonesty'''.</span><br><br>: Complete the Review Questions sections to get additional practice.<br><br>
= LINUX PRACTICE QUESTIONS =
The purpose of this section is to obtain extra practice to help with your assignment #1, quizzes, your midterm, and your final ezamexam.
Here is a link to the MS Word Document of ALL of the questions displayed below but with extra room to answer on the document to
simulate a quiz:
https://ictwiki.cdot.senecacollege.ca/~murray.saululi101/uli101files/uli101_week4_practice.docx
Your instructor may take-up these questions during class. It is up to the student to attend classes in order to obtain the answers to the following questions. Your instructor will NOT provide these answers in any other form (eg. e-mail, etc).
[[Image:number-conversion-chart.png|right|450px|thumb|]]
'''Review Questions:'''
# List the number of digits for the following numbering systems:<ul><li>'''Decimal'''</li><li>'''Binary'''</li><li>'''Octal'''</li><li>'''Hexadecimal'''</li></ul><br># Write a simple chart to show which values are represented for letter '''A - F ''' for a hexadecimal number.# How many '''binary ''' digits does 1 octal digit represent? # How many '''binary ''' digits does 1 hexadecimal digit represent?[[Image:number-conversion-chart.png|right|450px|thumb|]]# Use '''manual numbering conversion ''' to complete the table displayed to the right.  <ol><li value="6">Write the '''chmod''' command (using the ''symbolic'' method) to set “'''pass-through'''” permissions<br>(eg. <span style="font-family:courier;font-weight:bold;">r w x - - x - - x</span>) for your '''home''' directory using an '''absolute pathname'''.<br>Write a Linux command to verify that permissions where set.<br><br><br></li><li>Perform a binary to octal numbering conversion for the permissions: '''r w x - - x - - x'''<br>Write single Linux command to set “'''pass-through'''” permissions for your '''home''' directory,<br>using the '''absolute method''' (i.e. octal numbers).<br><br></li><li>Write a single Linux command to '''add read permissions''' for '''same group members''' for the '''~/tests''' directory.<br><br></li><li>Write a single Linux command to '''remove write permissions''' for '''same group members'''<br>and '''other group members''' for the '''~/projects''' directory. Use the ''symbolic'' method.<br><br></li><li>Write a single Linux command to set the permissions for the '''~/assignments''' directory<br> to the following using the '''absolute''' method (i.e. octal numbers): '''r w x r - x - - x''' <br>Show your work to perform a '''binary''' to '''octal''' conversion.<br>Write the command below using octal numbers and using a relative-to-home pathname.<br><br></li><li>Assume that you just issued the command:<br><span style="font-family:courier;font-weight:bold">chmod u=rwx,go=x ~/linux/content</span><br>What would be the new permissions for the “'''content'''” directory?<br><br></li><li>Assume that you just issued the commands:<br><span style="font-family:courier;font-weight:bold;">umask 077<br>mkdir mydir<br>touch mydir/myfile.txt<br></span><br>What would be the permissions for the newly created '''directory''' and '''regular file'''?<br>(show your work)</li></ol>   _________________________________________________________________________________
Author: Murray Saul
<ol><li value="6">x<License: LGPL version 3Link: https:/li><li>x</li><li>x<www.gnu.org/li><li>x<licenses/li><li>x</li><li>x</li><li>x</li></ol>lgpl.html
_________________________________________________________________________________
[[Category:ULI101]]

Navigation menu