- 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
- 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
- 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
111 101 100
translates to the number754
. - Now use that number in a
chmod
command to set your desired permissions on the file:
chmod 754 info.sh
Sunday, October 24, 2010
Linux chmod by the numbers
Up to this point, we’ve been setting the mode with letters. It turns out that you can also set the mode numerically. Here’s how it works:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment