chmod
by the NumbersUp 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:
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:
|
|
From our example, the 111 101 100
translates to the
number 754
.
Now use that number in a chmod
command to set your
desired permissions on the file:
chmod 754 info.sh
<< chmod Quick Reference Summary
|
Index | Numeric Mode in Action >> |