Open main menu

CDOT Wiki β

Changes

ULI101 Week 4

144 bytes added, 21:30, 4 September 2019
no edit summary
+ 1 x 8^0 = 1 x 1 = 1
---------------------
Sum of 1024+448+32+1 = 1505
</pre>
Remember, start from the right-hand-side and move to the left. Therefore, <code>2741</code> in octal is <code>1505</code> in decimal.
<pre class="example">F x 16^2 = 15 x 16^2 = 15 x 256 = 3840
2 x 16^1 = 2 x 16^1 = 2 x 16 = 32A x 16^0 = 10 x 16^0 = 10 x 1 = 10---------------------------------- Sum of 3840+32+10 = 3882
</pre>
Therefore, <code>F2A</code> in Hexadecimal is <code>3882</code> in decimal. I can understand now how decimal numbers can be stored in the computers as binary numbers, but why are we learning Octal and Hexadecimal numbers? As computers and computer programming languages evolved, octal and hexadecimal numbers were considered “short-hand” a short-cut to represent binary numbers.
* Convert the binary number <code>111110000</code> to an octal number:
<pre class="example">= 1 1 1 1 1 0 0 0 0x 2^2 2^1 2^0 2^2 2^1 2^0 2^2 2^1 2^0i.e. (4) (2) (1) (4) (2) (1) (4) (2) (1)1x4+ 1x2+ 1x1 1X4+ 1x2+ 0x1 0X4+ 0x2+ 0x1= (4+2+1) = 7 (4+2+0) = 6 (0+0+0) = 0
</pre>
Therefore, the binary number 111110000 represents 760 as an octal number. This code can be used to represent directory and file permissions (you will learn how to set permissions soon)
* Convert the binary number <code>111110000</code> to a hexadecimal number:
<pre class="example">= 0 0 0 1 1 1 1 1 0 0 0 0(8) (4) (2) (1) (8) (4) (2) (1) (8) (4) (2) (1)1 15 01 F 0
</pre>
Therefore, the binary number <code>111110000</code> represents <code>1F0</code> as a hexadecimal number.
<blockquote>1 hexadecimal digit is equal to 4 binary digits. Group binary digits into groups of 4 starting from the right. Add leading zeros if last group of digits is less than 4 digits. Convert each group of 4 digits to a hexadecimal digit.
</blockquote>
 
=== Converting Hex to Binary ===
<pre class="example"> 1 F 0
= 1 15 0= (8)(4)(2)(1) (8)(4)(2)(1) (8)(4)(2)(1)= 0 0 0 1 1 1 1 1 0 0 0 0
= 000111110000 = 111110000
</pre>
-rw-rw---- 1 joe.professor users 0 2006-02-02 10:47 ~/work_together
# This indicates the user “joe.professor” owns the file “work_together”.
# The owner “joe.professor” can read and write to that file.“work_together”# By the way, you joe.professor can change the ownership of files work_together (using the chown command, assuming you own them).
# Let’s look at the detailed listing for a regular file owned by someone else:
-rw-rw---- 1 joe.professor users 0 2006-02-02 10:47 ~/work_together
# This indicates a group name (called “users”) that is assigned to that file “work_together”.# In this case the user “joe.professor” has given permission to other users that belong to theanyone in “users” group# “users” group to read from and write to (incl. delete) the file “work_together”.
[joe.professor] ls -l ~/work_together
# Answer: all “other” users - users that DO NOT belong to the “users” group.!
</pre>
 
= Directory Permissions =
* For ordinary files any execute permissions are no applied
* For example: umask 310 would result in permissions 466 (r--rw-rw-)
 
[[Category:ULI101]]
[[Category:ULI101-2018]]