Unleash your inner root

chmod: Capital (X) Gunna Give it to you

Pardon the terrible title of this tutorial, but you know…I decided when I started this blog that I would have cheesy terrible titles, and this was the best one for the subject matter.
Anyway, this is one of those “I feel dumb” moments that it’s entirely possible the entire Linux world knew about before I did, but it just changed my perception of reality, so I thought I’d share the glory with the rest of you. So one frustration I have run into frequently, but just sort of learned to live with is this: You have an application, java for example, that you’ve compiled or installed in some way and its permissions are confined to user only. So you want to extend those permissions to allow group and other permissions as well. What do you do?

The simplest way of extending permissions is to do something like

chmod -R 777 /java
# OR
chmod -R ugo+rwx /java

The problem with this of course is that you make every random text file or other non-executable file, executable. While that isn’t necessarily an issue, it’s somewhat aggravating. So what can you do instead? CAPITAL X!
X in chmod (and setfacl as well, but that’s another matter entirely), provides execute permissions ONLY to files/directories that ALREADY have it set from the user permission.
So simply issuing:

chmod -R ugo+rwX /java

Will apply the execute permission properly to all of the things that are supposed to have it, without effecting the random other files that aren’t supposed to have it. Simple, but amazing.

chmodlinuxposix permissions

Brandon.Graves • May 10, 2016


Previous Post

Next Post

Leave a Reply

Your email address will not be published / Required fields are marked *

%d bloggers like this: