Changes

Jump to: navigation, search
INVESTIGATION 2: FILE PERMISSIONS
:* Identify '''which numbering system conversion method to use''' when required to perform a numbering conversion
:* Explain the purpose of '''file permissions'''
:* Explain how permissions work differently for '''directories ''' as opposed to for '''regular files.'''
:* Change file '''permissions''' with the '''chmod''' command (both ''symbolic'' and ''absolute'' methods)
:* Use the '''umask''' command to automatically assign permissions for directory '''newly created directories''' and '''regular files to be created.'''<br><br>
===Tutorial Reference Material===
* [https://www.booleanworld.com/introduction-linux-file-permissions/ Introduction to File Permissions]<br><br>
File Permission Commands<br>
* [httphttps://man7ss64.orgcom/linux/man-pages/man1bash/chmod.1.html chmod]<br>* [httphttps://man7ss64.org/linuxcom/man-pages/man1bash/umask.1p.html umask]<br><br>
|colspan="1" style="padding-left:15px;" width="30%"|Instructional Videos:
===Why Study Data Representation?===
<table align="right"><tr valign="top"><td>[[Image:binary-number1.png|thumb|right|220px|A series of '''binary numbers''' form a '''byte''' to represent '''numbers'''.<br>(Image licensed under [https://creativecommons.org/licenses/by-sa/3.0/ cc])]]</td><td>[[Image:binary-number-2.png|thumb|right|200px|'''Bytes''' can be used to also represent '''characters'''. It is job of a program to know if 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><i>''Data ... 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)...''</i><br>
Reference: https://en.wikipedia.org/wiki/Data_(computing)<br><br>
Binary numbers are combined in a sequence to form a '''byte'''. Bytes are used to represent '''numbers''' or '''characters'''. How does the computer know which bytes represent a number or a letter? That is the job of '''computer programs ''' that are created (including operating systems and application software) to perform that task.
''Examples of Understanding IT Professionals that Use Data Representation:''
* ''Network Specialists'': Building Large Networks via Sub-netting
* ''C ProgrammingProgrammers:'' Sending information over networks, files* ''Web DevelopmentDevelopers:'' Setting color codes for webpage background or text * ''Allowing or Limiting Unix / Linux File AccessSystem Administrators:'' Setting ''permissions'' for files and directories
<br><br>
''Decimal Numbers''
The '''decimal''' numbering system consists of digits consisting of numbers ranging from '''0''' to '''9'''. The numbering system is based on '''sums of the power of 10''' which provides a framework for mathematic calculations.
The fact that '''humans''' started counting on their fingers and thumbs most likely lead to the development of this numbering system.
''Binary Numbers''
The '''binary''' numbering system consists of digits containing the numbers ranging from '''0''' or to '''1'''. The numbering system is based on '''sums of the power of 2'''.
Digital computers have circuits which representing data in terms of voltage levels. Multiple circuits are used to represent data (in the form of ''binary'' numbers).
''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 '''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 consist of digits containing numbers ranging from '''0 to 7''' and ranging from '''0 to F''' respectively. For ''hexadecimal'' numbers, values for '''10 to 15''' are represented by the characters '''A to F''' respectively. The '''octal''' and '''hexadecimal''' numbering system are based on sums of the power of '''8''' and '''16''' respectively.
Since '''1 octal digit represents 3 binary digits''' and '''1 hexadecimal digit represents 4 binary digits''', octal and hexadecimal numbers are used as '''short-cuts''' to represent binary number.
# Write down the '''decimal number''' to be converted.
# On the ''right-side'', write the number '''1''' and moving '''leftwards''', keep <u>doubling</u> the numbers until that number is '''greater than''' the decimal number to be converted (refer to the diagram on the right).<br>
# Starting on the rightleft-side 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''' below.<br><br># Repeat '''step #3''' (moving leftwards 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''' if necessary.<br><br>
==== Method 3: Octal to Binary / Binary to Octal ====
Since the Unix / Linux operating file systems allow for '''multiple user accounts''' it is essential<br>to have a system to '''share''' or '''limit''' access to directories and files contained in those different user accountswithin the file system.
[[Image:listing-file-directory.png|thumb|right|400px|Detailed directory listing showing permissions for a '''directory'''<br>and a '''regular file'''.]]
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 are 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 will learn how to those tasks when or if you take a Unix/Linux administration accountcourse.<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:directory-permissions.png|thumb|right|350px|Permissions of a '''directory''' that contain subdirectories and regular files.]]
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 a that directory.
Permissions for Directory files directories have a different meaning than permissions for '''regular files'''. Refer to the diagrams to the right to see the explanation of permissions and how they differ between a directory and a regular file.
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 directories and regular files, >you would use the '''chmod''' command.
'''<span style="font-style:italic">Octal (Absolute) Method:</span>'''
[[Image:octal-permissions.png|thumb|right|150px|using Using octal numbers to represent setting file permissions.]]You can also use '''octal numbers''' to represent '''set''' permissions. This method is a short-cut and may require less typing than using the ''symbolic'' method. You can only use this method to '''set''' file permissions (as opposed to ''add'' or ''remove'' 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).
For this investigation, we will NOT be logged into our Matrix account, but it is recommended to have sheets of paper ready to manually perform numbering conversions.
<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'''. ]]
'''Perform the Following Steps:'''
# Let's convert the following ''8-bit'' binary number '''10111110''' to a '''decimal ''' number.<br><br><span style="color:blue;">'''NOTE:''' It is important to learn and '''memorize''' the '''correct techniques''' 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 paper.<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, retry the method and check to see what you did wrong.<br><br>
'''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>
# Make certain that your current directory is '''your home directory'''.<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/week4-check-1</span><br><br>
# If you encounter errors and '''re-run ''' the checking script until you receive a congratulations message, then you can proceed.<br><br>[[Image:file-permission-practice-2.png|right|450px|thumb|]]
# Issue Linux commands to create empty files for each of those newly created directories as show 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/week4-check-2</span><br><br>
# If you encounter errors and '''re-run ''' the checking script until you receive a congratulations message, then continue the remaining steps.<br><br>Let's get practice understanding permissions, changing permissions, and setting your Linux account to automatically set permissions for newly created directories and regular 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. 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. 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''' command 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>
# Again, use the '''ls ''' command to confirm the permissions for the '''~/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 want to now change those regular file permissions to the following settings: <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 740 640 ~/documents/memos/memo*.txt<br>chmod 740 640 ~/documents/reports/report*.txt<br>chmod 740 640 ~/dcouments/contracts/contract*.txt</span><br><br>
# Issue the '''ls -lR''' command for the '''~/documents''' directory to confirm that those regular file permission have changed.<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>
# 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 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 -l ~/shared</span><br><br>What are the permissions for this newly-created directory? <br>Can other users access the directory pathname '''~youruserid/shared''' ?<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 subtracting the default umask value you determined in the previous step.<br>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 '''steps #27''' and '''#28''' to see how a umask setting of '''077''' would 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, 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>
13,420
edits

Navigation menu