Results 1 to 6 of 6

Thread: Chmod Explained

  1. #1
    Join Date
    Mar 2009
    Beans
    927
    Distro
    Ubuntu 12.04 Precise Pangolin

    Post Chmod Explained

    chmod is an abbreviation of change mode. There are two ways to chmod:

    Symbolic (e.g. chmod +x)
    Code:
    chmod <people><+/-><permissions>
    Example: chmod o-w (deny others from editing the file)
    Example: chmod u+rwx (give the owner full control)
    Exmaple: chmod +rwx (give everyone full control)
    Example: chmod +x (allow anyone to execute the file)
    Code:
    Key:
    r - Read
    w - Write
    x - Execute
    
    u - The owner of the file
    g - The group that the file belongs to
    o - Anybody who is not one of the above
    a - All users
    
    + - Add permissions
    - - Remove permissions

    Numerical (e.g. chmod 700):
    Code:
                                    : The first octet represents permissions for the owner.
            r w x  T                : The second octet represents permissions for the group.
    Owner:  4 2 1  7                : The third octet represents permissions for everyone else.
    Group:  0 0 0  0                : For each octet, start at 0 and:
    Other:  0 0 0  0                : +4 for read permission.
                                    : +2 for write permission.
    Command: chmod 700              : +1 for execute permission.
    What is an octet? What Happened to +3?
    Read more: Wikipedia. Man page.
    Last edited by Penguin Guy; June 12th, 2011 at 07:15 PM.

  2. #2
    Join Date
    Mar 2009
    Beans
    927
    Distro
    Ubuntu 12.04 Precise Pangolin

    Lightbulb What is an Octet?

    When I refer to 'octets' in my chmod guide, I am referring to these:
    chmod 644 file

    While digits go from 0-9, octets go from 0-7 (skipping 8 and 9). A number written using digits is called a decimal, a number written using octets is called an octal.
    Code:
    Counting to 20 in Decimal: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 
    Counting to 20 in Octal: 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24
    Last edited by Penguin Guy; June 5th, 2010 at 02:02 PM.

  3. #3
    credobyte is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Jun 2009
    Beans
    1,559
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Chmod Explained

    Might be a little bit offtopic, but .. does anyone have an answer to the following question ?

    Why there's no +3 ( +1, +2 ... +4 ) ?

  4. #4
    Join Date
    Apr 2007
    Location
    Washington state
    Beans
    350
    Distro
    Ubuntu Development Release

    Re: Chmod Explained

    Quote Originally Posted by credobyte View Post
    Might be a little bit offtopic, but .. does anyone have an answer to the following question ?
    Look at the place values. The first (rightmost) digit is the ones, the next is the 2's and the next is the 4's. To make 3 you would use the ones and the 2's place. so:
    1 is 001
    2 is 010
    3 is 011
    4 is 100
    5 is 101
    6 is 110
    7 is 111.

    There is no one place for the 3's

    This is analogous to the base 10 system with the first place being the ones, the next the 10's etc.

  5. #5
    Join Date
    Mar 2009
    Beans
    927
    Distro
    Ubuntu 12.04 Precise Pangolin

    Lightbulb What Happened to +3?

    Quote Originally Posted by credobyte View Post
    Might be a little bit offtopic, but .. does anyone have an answer to the following question ?

    Why there's no +3 ( +1, +2 ... +4 ) ?
    Good question! The answer is simple; +3 is switched with +4 to avoid a duplicate number 3 in the sum octet:
    Code:
    +4 System      +3 System
    r w x  Σ       r w x  Σ
    4 2 1  7       3 2 1  6
    4 2 0  6       3 2 0  5
    4 0 1  5       3 0 1  4
    4 0 0  4       3 0 0  3
    0 2 1  3       0 2 1  3
    0 2 0  2       0 2 0  2
    0 0 1  1       0 0 1  1
    0 0 0  0       0 0 0  0
    Although this may seem confusing, it makes sense mathematically. This kind of code is based off binary.
    Last edited by Penguin Guy; June 12th, 2011 at 06:36 PM.

  6. #6
    Join Date
    Jan 2006
    Beans
    63

    Re: Chmod Explained

    This is a subject of it's own, but here's a quick primer on counting in other number systems.

    Counting in any base system is exactly the same as counting in decimal - representing, or writing down the count is what is different.

    Code:
    Base10 (Decimal) 1,110 has the following meaning:
    
    10^3 10^2 10^1 10^0
    ------------------- = (1*10^3)+(1*10^2)+(1*10^1)+(0*10^0)
    1    1    1    0
    
    
    Base8 (Octal) 5477 has the following meaning:
    
    8^3 8^2 8^1 8^0
    --------------- = (5*8^3)+(4*8^2)+(7*8^1)+(7*8^0)
    5   4   7   7
    
    
    Base30 (Trigesimal) 11T has the following meaning:
    
    30^2 30^1 30^0 
    ------------------- = (1*30^2)+(1*30^1)+(30*30^0)
    1    1    T  (T represents 30)
    How do we write these numbers? Each position has a representitive character or symbol whose count is equal to N(max)-1.

    In Base8 (Octal), each position is counted from 0 (meaning none) to 7 (the maximum count in that position). When we want to say that we've counted past 7, we add an octet position and start counting again in the base^0 position again.

    In Base10, we count from 0 to 9. When we want to say that we've counted past 9, we add a deimal position and start counting again in the base^0 position again.

    In Base30, we count from 0 to T. When we want to say that we've counted past 30, we add a trigesimal position and start counting again in the base^0 position again.

    Counting in a base 3 system would look like this:

    Code:
    3^3 3^2 3^1 3^0
    ---------------
    1   1   1   1   = 40
        3   3   3   = 39
        3   3   2   = 38
        3   3   1   = 37
        3   2   3   = 36
        3   2   2   = 35
        3   2   1   = 34
        3   1   3   = 33
        3   1   2   = 32
        3   1   1   = 31
        2   3   3   = 30
    
    ....
    
    ....
    
        0   0   0   = 0

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •