Open main menu

CDOT Wiki β

Changes

LINUX PRACTICE QUESTIONS
'''<span style="font-style:italic">Octal (Absolute) Method:</span>'''[[Image:octal-permissions.png|thumb|right|150px|using octal numbers to represent setting file permissions.]]You can use '''octal numbers'''to represent permissions.
You Since 1 octal digit represents 3 binary digits, one octal digit can use '''octal numbers''' to represent the rwx permission granted or NOT granted. The permissionsrwz would be in the form of 3 binary digits (1 represents the permission granted and 0 represents the permission NOT granted.
'''NOTE:''' You can only use this method to '''set''' file permissions (as opposed to ''add'' or ''remove'' permissions).
<table cellpadding="5" width="70%"><tr><th style="border-bottom: 1px solid black;text-align:left;">Command</th><th style="border-bottom: 1px solid black;text-align:left;">Description</th></tr><tr valign="top"><td width="40%"><span style="font-family:courier;font-weight:bold;">chmod 500 script.bash</span></td><td>Set read and execute permissions for only the '''user''' for the file '''script.bash''' so it can be run.</tr><tr valign="top"><td><span style="font-family:courier;font-weight:bold">chmod 711 ~</span></td><td>Set "'''pass-thru'''" permissions of your '''home''' directory for same group members and other group members to navigate to other subdirectories (that may have access / view permissions).</tr><tr valign="top"><td><span style="font-family:courier;font-weight:bold;">chmod 750 ~/shared</span></td><td>Set full permissions for user, read and access permissions for some group members and no permissions for other group members for the directory '''~/shared'''</td></tr><tr valign="top"><td><span style="font-family:courier;font-weight:bold;">chmod 555 myfile.txt</span></td><td>Set read and execute permissions for the directory '''myfile.txt'''</td></tr></table>
'''NOTE:''' You can use the '''-R''' option to set permissions for directory, subdirectory and directory contents '''recursively'''.
<table align="right"><tr><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></table>'''Setting File Permissions upon Directory / for Newly-Created Directories and Regular File Creation with Files (umask command):''' The '''umask''' command is used to set the permissions of newly-created directories and regular files. 
xIssuing 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=
# Perform a manual conversion of the '''octal number 5636''' to a '''hexadecimal number'''.<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 '''octal number'''.<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=
=INVESTIGATION 2: FILE PERMISSIONS=In this section, you will get experience using the '''chmod''' and '''umask''' commands to set permissions for directories and files.
'''Perform the Following Steps:'''
x# '''Login''' your matrix account and issue a command to '''confirm''' you are located in your home directory.<br><br>
= LINUX PRACTICE QUESTIONS =
<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>Perform a binary to octal numbering conversion for the permissions: '''r w x - - x - - x'''<br><br></li><li>xWrite single Linux command to set “pass-through” permissions for your home directory,<br>but use the '''absolute method''' (i.e. octal numbers) and use a relative-to-home pathname.<br><br></li><li>xWrite a single Linux command to add read permissions for '''same group members''' for the “'''tests'''” directory.<br>Use a '''relative''' pathname. Use the ''symbolic'' method.<br><br></li><li>x3. Write a single Linux command to '''remove''' read 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>(using a '''relative-to-home''' pathname) to the following using the '''absolute''' method (i.e. octal numbers): '''r w xr - 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>xAssume that you just issued the command:<br><span style="font-family:courier;font-weight:bold;">chmod 640 ./linux/content/tests/answers.txt</span><br>What would be the new permissions for the “'''answers.txt'''” file?<br>(show work for numbering conversion)</li></ol>   
[[Category:ULI101]]
13,420
edits