In most cases, a better solution is to not use absolute permissions.
It is both easier and safer to use symbolic permissions.
https://www.mvps.net/docs/linux-permissions-the-symbolic-assignment-of-permissions/
Yah that’s pretty cool.
I had no idea it existed.
I’ll try to learn howto assign permission in this way also.
There must be some basic rules to know.
Thanks Dalto.
The best way (really, believe me!) is to memorize…
- the important 3x3 bits (octal, old farts remember…)
- for user, group, other (left to right).
They’re all the same scheme:
rwx: read, write, execute (values: 4, 2, 1 left-to-right).
So rwxr-xr-x (think in 3-bit groups: rwx r-x r-x) is:
4+2+1 = 7,4+1 = 5,4+1 = 5→755.user hasread,write, execute permission,group hasread and execute,others (everyone) haveread and execute.
Now try 600 for yourself!
Only look here AFTER finding out yourself!
- user:
6 = 4+2→rw-→read,write,e,xecute - group:
0→---→,read,writee,xecute - other:
0→---→,read,writee.xecute - so
600looks likerw- --- ---. - You could use
600for a file with sensitive data that nobody should be able to read/write but yourself.
Easy, right?
If you throw some of these numbers and rwx combos around your head a few times a day, you’ll have that memorized very quickly—and never forget again. No need for “online calculators”, really.
Here are some exercises at random, for self-training:
- What dos
644mean? - Who can write to a
200file? - A file that only the user can read & write, the group can read only, and all others have no access to? (Do both the letters and the number)
- Why would it be a bad idea to
chmod 777a file? - Bonus question: When would it be good or bad to set the
xbit on a text file?
Remember the sequences:
- User, Group, Other (3 bits each = 1 octal digit)
- Read, Write, eXecute (4, 2, 1)
And on another day, we’ll also learn…
- what the
xbit means for directories, - how we can change single bits using complicated commands like
chmod go-x,g+r,o-rw filename.ext, - and the secrets of the fourth set of 3 bits (SUID, SGID, Sticky).
And then, one day, at 3:30 a.m., after a drinking night, I’ll stand beside your bed and shout questions at you like the above… and you’ll be able to answer them without thinking!
EDIT: This is actually proven truth. Once did that after a party at my best buddy, who had complained for weeks he’d never get his head around “that crazy permissions stuff”. He did come up with the right answers, and man, had we been drinking before! Although he couldn’t remember next morning…
![]()
Wow I wasn’t ready for that. Must let that sink in… ![]()
Are these the symbolic once, for example:
chmod g+rwx example.txt
Yes, exactly. Those are symbolic permissions. It is far safer to use those in commands than absolute permissions. Especially when making recursive changes.
It is also easier to understand.
Weeell… I kinda grew up with octal and prefer juggling a few bits in my head anytime, while having to stop and think about symbolic syntax every time, since they invented that.
But I give you that it’s easier to just chmod +x script.sh, or do bitwise setting/removal on recursive jobs—that’s indeed much safer, since you only set/remove exactly what you want, without touching the rest of permissions.
It’s still very helpful to understand the underlying principle, so you do the right things using either method. Like not setting x on a text file. ![]()
It isn’t just about being easier, it is safer.
We see people breaking their systems because they tried to apply an absolute permission recursively. It is much less likely to do that with symbolic permissions.
I agree. Still understanding is the basis for doing it right.
I’ve also had more than one case where people messed up their whole system by believing “advice” like “Bah, just set everything 777 and you won’t have permission problems again…” Didn’t work, used sudo… bye bye working OS…
So, fellows: Don’t believe everything you get told, read on the Internet, or ask off an Artificial Idiot™. Always be critical and try to understand the commands you are typing in!
Even if you understand the octal notation, there are a lot of gotchas with using octal notation during recursive operations.
Absolutely. Use symbolic for recursive. Totally agree.
You might also want to handle directories separately from files (or really know what you’re doing). But using find for that is subject for another day. ![]()
Some nasty
utilities actually enforce their configuration files being “600”, as in “refusing to work if not”.
On the other hand, (basic) Linux permissions pale in comparison to NTFS permissions or to Linux ACLs ![]()
And never mix others with owner - there is no owner. How many time did I mess chmod o+x just because some guide was using the words file owner and I learned it incorrectly.
Yeah, fun times “securing” the system by removing “execution” permission of all directories. Fun time indead. ![]()
