LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why is chmod a+r -R /usr/ a bad idea? (https://www.linuxquestions.org/questions/linux-newbie-8/why-is-chmod-a-r-r-usr-a-bad-idea-117427/)

BroX 11-18-2003 11:56 AM

Why is chmod a+r -R /usr/ a bad idea?
 
After installing Wine I only had normal fonts in the programs I ran with Wine when I logged in as root. Logged in as myself I got those horrible squares.

Thinking that this could be because the fonts couldn't be reached when logged in as user, I decided to give everyone permission to read from /usr/ (I am the only person using the laptop anyway so I figured 'nothing to lose'). So,

chmod a+r -R /usr/

NOT a good idea :-( Everything on my desktop disappeared!!

Why was this so bad?? Reading doesn't hurt? Or....?

Please o gurus, enlighten me :-)

xode 11-18-2003 12:56 PM

Quote:

Why is chmod a+r -R /usr/ a bad idea?
(1) "a+r" as a chmod argument? I personally don't like that style. I use exclusively octal when specifying the permissions that I give to chmod. There is no misunderstanding with octal. I encourage you to learn and use it.

(2) -R means recursive, which means that you altered the permissions of not only /usr itself but every file and every directory in /usr. Personally, I like to chmod only what I have in my sights, so to speek, the only exception being a collection of user data (e.g. a bunch of text files that I just copied over from a CDROM to a working directory on the hard drive) that I just acquired, that is currently in one specific harmless and out of the way spot and that needs to be altered as a unit. Especially, if I am root and I am working on the system, I will only change one item at a time and check things out after each change. It could be that, when you gave everything in /usr read permission to everyone, it was your system's security mechanisms that caused your problem, but that is a guess on my part. Obviously, you did create a problem.

vasudevadas 11-18-2003 01:06 PM

chmod a+r <filename> is the relative form of the command. It means "grant read permission to all users on this file in addition to whatever other permissions are set". Similarly, chmod g-w <filename> would mean "remove write permission to all users in the same group on this file in addition to whatever other permissions are set".

The absolute octal form of the command is good, but I find this easier than working out the octal representations of the binary.

Dunno why this made everything on your [ljsbrokken] desktop disappear though.

xode 11-18-2003 01:23 PM

Binary to octal is a lead pipe cinch. Each group of 3 bits of the 9 bit permission that you want to give, beginning with the left 3 bits, gets replaced by whatever single octal digit that those 3 bits correspond to. Binary to octal mapping is as follows:

0 = 000
1 = 001
2 = 010
3 = 011
4 = 100
5 = 101
6 = 110
7 = 111

Incidentally, binary to hex is just as easy. The exact same mapping rules apply, except that it is 4 bits at a time that map to a hex digit.

vasudevadas 11-18-2003 01:47 PM

Thanks (genuinely). I used to hack in machine code on my old Archimedes, so I'm quite familiar with binary and hex (and therefore octal too). My understanding is not the problem. My problem is laziness - I just can't be bothered to remember whether read permission is bit 0 or 2, and whether the user's permissions is the most significant nibble or whether that's all users, and I also can't be bothered to remember eight conversions from binary to octal (or decimal or hex - 'tis after all the same from 0 to 7!).

I can't stress enough - this is all my fault, pure laziness and no other reason. If I had to execute chmod commands frequently, I'm sure I'd remember, but I don't so I don't.


All times are GMT -5. The time now is 07:07 AM.