The following is often used to set file permissions, a good example being setting a key file to an appropriate permission level to be used by ssh (this being the "octal" form):
chmod 600 filename.xyz
Would it be a correct equivalent and acceptable practice to use the following instead (this is the "symbolic" form)?
chmod a=,u=r filename.xyz
The reason I ask is that it seems a bit clearer for code readability. Still not exactly human readable, but no bit mapping needed.
If maximum readibility (and not terseness) were the primary driver, would there be a better option?
Best Answer
With
a=,u=r
, the order is important. If you accidentally swap the order ofa=
andu=r
(or the order ofa=
andu=
), the result would be very different. (Yes,a
andu
are pretty far from each other on a QWERTY keyboard, but someone looking at a reference doc and manually typing things in might mess up between the two very similar looking parts.) For maximum readability and safety, I'd be more explicit:The permission components are very different here, and way more explicit, making mistakes less likely to happen. And it doesn't matter if you have
go-rwx
first oru=r
first.