Change file permissions with chmod

michelsaey
  6 years ago
  0

  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 info.sh to have these permissions

      - rwx r-x r-- info.sh
    
  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-- info.sh
        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 info.sh
Comments
sujitnag 6 years ago

you should add alternative way as @Hammer459 said.

and user decide which one is easier for them.


Hammer459 6 years ago

Actually....
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-- info.sh -> - rwx rwx r-- info.sh
run this command:
chmod g+w info.sh
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 6 years ago

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