How to add +x just for user with chmod?

10

2

chmod +x file changes a file from rw-r--r-- to rwxr-x-r-x but really I only wanted rwx-r--r-- is this possible?

Steven R.

Posted 2014-03-11T00:55:57.890

Reputation: 203

You'd be much more likely to get a good answer on Unix/Linux SE

– evamvid – 2014-03-11T00:58:08.427

4chmod u+x file. u=user, g=group, o=others. – jweyrich – 2014-03-11T01:15:04.677

1@jweyrich put that as an answer -- that's more elegant and better than my way... – evamvid – 2014-03-11T01:17:48.167

1The question probably has dozens of duplicates, but I posted it as an answer anyway. Glad it helped. – jweyrich – 2014-03-11T01:38:26.643

2@evamvid this question is perfectly on topic here, no reason to suggest the OP take it to [unix.se]. And I say that as a regular of both sites. – terdon – 2014-03-11T05:52:59.623

nicely put @terdon :) – GMasucci – 2014-03-11T11:34:51.073

@terdon also speaking as a regular of both sites, I didn't mean that this question was off-topic on this site; I was just trying to point out that, in general, Linux-specific questions will get better and/or more complete answers on U+L SE

– evamvid – 2014-03-11T20:19:44.797

@evamvid not true, U&L is great for the more obscure, in-depth answers, this is an elementary question about the basic options of a standard command. U&L would not find it very interesting and would likely ignore it. This is a better home for this type of question. – terdon – 2014-03-12T00:35:00.557

Answers

28

To change only the permission for the current user, you can use:

chmod u+x <file>

Where u=user, g=group, o=others.

If you want to enforce the permissions you mentioned, this would be the ideal:

chmod u=rwx,go=r file

Optionally, you can do the same using the octal notation, as follows:

chmod 744 <file>

This will set rwx (the 7) for user, and r (the 4's) for group and others.

jweyrich

Posted 2014-03-11T00:55:57.890

Reputation: 1 106

3

Try running chmod u=rwx,go=r file.

In my case, that gives the permissions as rwx-r--r--, which I think is what you meant.

evamvid

Posted 2014-03-11T00:55:57.890

Reputation: 393