Change file permissions with chmod

  8 years ago

  1. Write the permissions you want the file to have. To make your life easier, write the permissions grouped into sets of three letters. For example, let’s say you want file to have these permissions

      - rwx r-x r--
  2. Under each letter, write a digit 1; under each dash write a digit zero. Ignore the dash at the very beginning that tells you whether it’s a file or directory. This gives you three binary numbers.

      - rwx r-x r--
        111 101 100
  3. Now convert each set of three digits to a single digit using this table:

    Binary Becomes
    000 0
    001 1
    010 2
    011 3
    Binary Becomes
    100 4
    101 5
    110 6
    111 7

    From our example, the 111 101 100 translates to the number 754.

  4. Now use that number in a chmod command to set your desired permissions on the file:

      chmod 754
sujitnag 8 years ago

you should add alternative way as @Hammer459 said.

and user decide which one is easier for them.

Hammer459 8 years ago

You should NOT use the octal number representation as that could cause problems.
The proper way is something like this...
To do this change:
- rwx r-x r-- -> - rwx rwx r--
run this command:
chmod g+w
This way you are explicitly adding (+) write permission (w) to all in your group (g)
Possible operations; add(+) set to(=) or remove(-)
Usual permissions; write(w) read(r) or execute(x)
Possible groupings; user(u) group(g) other(o) or all(a)( )

Abderraouf 8 years ago

i really really like it!
it is really cool tutorials...thank you :D
شكرا لك