Use chmod command selectively
I want to set 755 permission on all files and sub-directories under a specific directory, but I want to execute chmod 755 only for those components which does not have 755 permission.
find /main_directory/ -exec chmod 755 {} ;
If the find
command returns a long list, this will take a lot of time.
I know that I can use the stat command to check the Octal file level permission of each component and then use if-else to toggle the file permission, but is there any single line approach using find
and xargs
to first check what permission the file/directory has, and then use chmod
to change it to 755 if it is set to something else.
command-line find chmod
add a comment |
I want to set 755 permission on all files and sub-directories under a specific directory, but I want to execute chmod 755 only for those components which does not have 755 permission.
find /main_directory/ -exec chmod 755 {} ;
If the find
command returns a long list, this will take a lot of time.
I know that I can use the stat command to check the Octal file level permission of each component and then use if-else to toggle the file permission, but is there any single line approach using find
and xargs
to first check what permission the file/directory has, and then use chmod
to change it to 755 if it is set to something else.
command-line find chmod
6
This may be premature optimisation, and it may not even make if faster. Doing all of those checks may slow it down. Testing to ensure that it is faster, will only pay off, if you have to do this a lot.
– ctrl-alt-delor
Jan 8 at 9:51
3
You probably don't want to give execute permissions to all files. This will create a security risk. (this is one of the virus vectors on Microsoft's Windows: everything is executable). In symbolic mode you can sayu+rw,go+r,go-w,ugo+X
— note the capital.
– ctrl-alt-delor
Jan 8 at 9:53
I agree with @ctrl-alt-delor but would suggest something closer to what you asked, u=rwX,go=rX which should achieve the same thing.
– penguin359
Jan 9 at 1:13
add a comment |
I want to set 755 permission on all files and sub-directories under a specific directory, but I want to execute chmod 755 only for those components which does not have 755 permission.
find /main_directory/ -exec chmod 755 {} ;
If the find
command returns a long list, this will take a lot of time.
I know that I can use the stat command to check the Octal file level permission of each component and then use if-else to toggle the file permission, but is there any single line approach using find
and xargs
to first check what permission the file/directory has, and then use chmod
to change it to 755 if it is set to something else.
command-line find chmod
I want to set 755 permission on all files and sub-directories under a specific directory, but I want to execute chmod 755 only for those components which does not have 755 permission.
find /main_directory/ -exec chmod 755 {} ;
If the find
command returns a long list, this will take a lot of time.
I know that I can use the stat command to check the Octal file level permission of each component and then use if-else to toggle the file permission, but is there any single line approach using find
and xargs
to first check what permission the file/directory has, and then use chmod
to change it to 755 if it is set to something else.
command-line find chmod
command-line find chmod
edited Jan 8 at 9:28


chaos
35.3k773117
35.3k773117
asked Jan 8 at 9:21
Kumarjit GhoshKumarjit Ghosh
674
674
6
This may be premature optimisation, and it may not even make if faster. Doing all of those checks may slow it down. Testing to ensure that it is faster, will only pay off, if you have to do this a lot.
– ctrl-alt-delor
Jan 8 at 9:51
3
You probably don't want to give execute permissions to all files. This will create a security risk. (this is one of the virus vectors on Microsoft's Windows: everything is executable). In symbolic mode you can sayu+rw,go+r,go-w,ugo+X
— note the capital.
– ctrl-alt-delor
Jan 8 at 9:53
I agree with @ctrl-alt-delor but would suggest something closer to what you asked, u=rwX,go=rX which should achieve the same thing.
– penguin359
Jan 9 at 1:13
add a comment |
6
This may be premature optimisation, and it may not even make if faster. Doing all of those checks may slow it down. Testing to ensure that it is faster, will only pay off, if you have to do this a lot.
– ctrl-alt-delor
Jan 8 at 9:51
3
You probably don't want to give execute permissions to all files. This will create a security risk. (this is one of the virus vectors on Microsoft's Windows: everything is executable). In symbolic mode you can sayu+rw,go+r,go-w,ugo+X
— note the capital.
– ctrl-alt-delor
Jan 8 at 9:53
I agree with @ctrl-alt-delor but would suggest something closer to what you asked, u=rwX,go=rX which should achieve the same thing.
– penguin359
Jan 9 at 1:13
6
6
This may be premature optimisation, and it may not even make if faster. Doing all of those checks may slow it down. Testing to ensure that it is faster, will only pay off, if you have to do this a lot.
– ctrl-alt-delor
Jan 8 at 9:51
This may be premature optimisation, and it may not even make if faster. Doing all of those checks may slow it down. Testing to ensure that it is faster, will only pay off, if you have to do this a lot.
– ctrl-alt-delor
Jan 8 at 9:51
3
3
You probably don't want to give execute permissions to all files. This will create a security risk. (this is one of the virus vectors on Microsoft's Windows: everything is executable). In symbolic mode you can say
u+rw,go+r,go-w,ugo+X
— note the capital.– ctrl-alt-delor
Jan 8 at 9:53
You probably don't want to give execute permissions to all files. This will create a security risk. (this is one of the virus vectors on Microsoft's Windows: everything is executable). In symbolic mode you can say
u+rw,go+r,go-w,ugo+X
— note the capital.– ctrl-alt-delor
Jan 8 at 9:53
I agree with @ctrl-alt-delor but would suggest something closer to what you asked, u=rwX,go=rX which should achieve the same thing.
– penguin359
Jan 9 at 1:13
I agree with @ctrl-alt-delor but would suggest something closer to what you asked, u=rwX,go=rX which should achieve the same thing.
– penguin359
Jan 9 at 1:13
add a comment |
2 Answers
2
active
oldest
votes
If you want to change permissions to 755
on both files and directories, there's no real benefit to using find
(from a performance point of view at least), and you could just do
chmod -R 755 /main_directory
If you really want to use find
to avoid changing permissions on things that already has 755
permissions (to avoid updating their ctime timestamp), then you should also test for the current permissions on each directory and file:
find /main_directory ! -perm 0755 -exec chmod 755 {} +
The -exec ... {} +
will collect as many pathnames as possible and execute chmod
on all of them at once.
Usually, one would want to change permissions on files and directories separately, so that not all files are executable:
find /main_directory -type d ! -perm 0755 -exec chmod 755 {} +
find /main_directory ! -type d ! -perm 0644 -exec chmod 644 {} +
Worked like charm, thank you. Regards, Kumarjit
– Kumarjit Ghosh
Jan 8 at 13:11
1
I suspect using+
instead of;
makes a big difference here.
– Kevin
Jan 8 at 18:25
This is the speedy way -- avoid a check. I would further use find to make a list of only files you have permission to change this will avoid chmod error-ing out on files it cannot change. <pre> <code> # rwx, rw, wx, w only find . -user $(whoami) -perm /002 ! -perm 0755 -exec chmod 0755 {} ; # break into two operations find . -user $(whoami) -perm /002 ! -perm 0755 > /tmp/chfiles.txt for file in $(</tmp/chfiles.txt) do chmod --quiet 0755 "${file}" done </code></pre>
– Chris Reid
Jan 8 at 20:26
@ChrisReid Note that looping over a list of pathnames like that will break if any pathname contains a whitespace character.
– Kusalananda
Jan 8 at 20:30
I guess you need to change the Internal Field Separator (IFS) to 'n' in a script. These are environment settings, the way the shell interprets them is dependent on the values of those settings. I test scripts on dummy files before using them to ferret out blunderous distasters like renaming files or overwriting them. I like the shell printf way of setting IFS. IFS=$(printf "n") # very readable
– Chris Reid
Jan 9 at 22:28
add a comment |
As find
have gotten the -exec ... +
syntax, there's not much point in using xargs
, but as you ask for it:
find /main_directory -not -perm 0755 | xargs chmod 755
1
Also note that xargs without-0
(in combination with-print0
in find; which is GNU extension) can be pretty problematic security-wise if potential attacker can create filenames which include whitespaces or other special characters in them. So better stick to-exec
when you can
– Matija Nalis
Jan 8 at 17:08
No need forxargs
(just use-exec
), and if you do use it you should use-print0
/-0
like Matija says.
– Kevin
Jan 8 at 18:24
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493181%2fuse-chmod-command-selectively%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to change permissions to 755
on both files and directories, there's no real benefit to using find
(from a performance point of view at least), and you could just do
chmod -R 755 /main_directory
If you really want to use find
to avoid changing permissions on things that already has 755
permissions (to avoid updating their ctime timestamp), then you should also test for the current permissions on each directory and file:
find /main_directory ! -perm 0755 -exec chmod 755 {} +
The -exec ... {} +
will collect as many pathnames as possible and execute chmod
on all of them at once.
Usually, one would want to change permissions on files and directories separately, so that not all files are executable:
find /main_directory -type d ! -perm 0755 -exec chmod 755 {} +
find /main_directory ! -type d ! -perm 0644 -exec chmod 644 {} +
Worked like charm, thank you. Regards, Kumarjit
– Kumarjit Ghosh
Jan 8 at 13:11
1
I suspect using+
instead of;
makes a big difference here.
– Kevin
Jan 8 at 18:25
This is the speedy way -- avoid a check. I would further use find to make a list of only files you have permission to change this will avoid chmod error-ing out on files it cannot change. <pre> <code> # rwx, rw, wx, w only find . -user $(whoami) -perm /002 ! -perm 0755 -exec chmod 0755 {} ; # break into two operations find . -user $(whoami) -perm /002 ! -perm 0755 > /tmp/chfiles.txt for file in $(</tmp/chfiles.txt) do chmod --quiet 0755 "${file}" done </code></pre>
– Chris Reid
Jan 8 at 20:26
@ChrisReid Note that looping over a list of pathnames like that will break if any pathname contains a whitespace character.
– Kusalananda
Jan 8 at 20:30
I guess you need to change the Internal Field Separator (IFS) to 'n' in a script. These are environment settings, the way the shell interprets them is dependent on the values of those settings. I test scripts on dummy files before using them to ferret out blunderous distasters like renaming files or overwriting them. I like the shell printf way of setting IFS. IFS=$(printf "n") # very readable
– Chris Reid
Jan 9 at 22:28
add a comment |
If you want to change permissions to 755
on both files and directories, there's no real benefit to using find
(from a performance point of view at least), and you could just do
chmod -R 755 /main_directory
If you really want to use find
to avoid changing permissions on things that already has 755
permissions (to avoid updating their ctime timestamp), then you should also test for the current permissions on each directory and file:
find /main_directory ! -perm 0755 -exec chmod 755 {} +
The -exec ... {} +
will collect as many pathnames as possible and execute chmod
on all of them at once.
Usually, one would want to change permissions on files and directories separately, so that not all files are executable:
find /main_directory -type d ! -perm 0755 -exec chmod 755 {} +
find /main_directory ! -type d ! -perm 0644 -exec chmod 644 {} +
Worked like charm, thank you. Regards, Kumarjit
– Kumarjit Ghosh
Jan 8 at 13:11
1
I suspect using+
instead of;
makes a big difference here.
– Kevin
Jan 8 at 18:25
This is the speedy way -- avoid a check. I would further use find to make a list of only files you have permission to change this will avoid chmod error-ing out on files it cannot change. <pre> <code> # rwx, rw, wx, w only find . -user $(whoami) -perm /002 ! -perm 0755 -exec chmod 0755 {} ; # break into two operations find . -user $(whoami) -perm /002 ! -perm 0755 > /tmp/chfiles.txt for file in $(</tmp/chfiles.txt) do chmod --quiet 0755 "${file}" done </code></pre>
– Chris Reid
Jan 8 at 20:26
@ChrisReid Note that looping over a list of pathnames like that will break if any pathname contains a whitespace character.
– Kusalananda
Jan 8 at 20:30
I guess you need to change the Internal Field Separator (IFS) to 'n' in a script. These are environment settings, the way the shell interprets them is dependent on the values of those settings. I test scripts on dummy files before using them to ferret out blunderous distasters like renaming files or overwriting them. I like the shell printf way of setting IFS. IFS=$(printf "n") # very readable
– Chris Reid
Jan 9 at 22:28
add a comment |
If you want to change permissions to 755
on both files and directories, there's no real benefit to using find
(from a performance point of view at least), and you could just do
chmod -R 755 /main_directory
If you really want to use find
to avoid changing permissions on things that already has 755
permissions (to avoid updating their ctime timestamp), then you should also test for the current permissions on each directory and file:
find /main_directory ! -perm 0755 -exec chmod 755 {} +
The -exec ... {} +
will collect as many pathnames as possible and execute chmod
on all of them at once.
Usually, one would want to change permissions on files and directories separately, so that not all files are executable:
find /main_directory -type d ! -perm 0755 -exec chmod 755 {} +
find /main_directory ! -type d ! -perm 0644 -exec chmod 644 {} +
If you want to change permissions to 755
on both files and directories, there's no real benefit to using find
(from a performance point of view at least), and you could just do
chmod -R 755 /main_directory
If you really want to use find
to avoid changing permissions on things that already has 755
permissions (to avoid updating their ctime timestamp), then you should also test for the current permissions on each directory and file:
find /main_directory ! -perm 0755 -exec chmod 755 {} +
The -exec ... {} +
will collect as many pathnames as possible and execute chmod
on all of them at once.
Usually, one would want to change permissions on files and directories separately, so that not all files are executable:
find /main_directory -type d ! -perm 0755 -exec chmod 755 {} +
find /main_directory ! -type d ! -perm 0644 -exec chmod 644 {} +
edited Jan 8 at 10:01
answered Jan 8 at 9:24


KusalanandaKusalananda
127k16239393
127k16239393
Worked like charm, thank you. Regards, Kumarjit
– Kumarjit Ghosh
Jan 8 at 13:11
1
I suspect using+
instead of;
makes a big difference here.
– Kevin
Jan 8 at 18:25
This is the speedy way -- avoid a check. I would further use find to make a list of only files you have permission to change this will avoid chmod error-ing out on files it cannot change. <pre> <code> # rwx, rw, wx, w only find . -user $(whoami) -perm /002 ! -perm 0755 -exec chmod 0755 {} ; # break into two operations find . -user $(whoami) -perm /002 ! -perm 0755 > /tmp/chfiles.txt for file in $(</tmp/chfiles.txt) do chmod --quiet 0755 "${file}" done </code></pre>
– Chris Reid
Jan 8 at 20:26
@ChrisReid Note that looping over a list of pathnames like that will break if any pathname contains a whitespace character.
– Kusalananda
Jan 8 at 20:30
I guess you need to change the Internal Field Separator (IFS) to 'n' in a script. These are environment settings, the way the shell interprets them is dependent on the values of those settings. I test scripts on dummy files before using them to ferret out blunderous distasters like renaming files or overwriting them. I like the shell printf way of setting IFS. IFS=$(printf "n") # very readable
– Chris Reid
Jan 9 at 22:28
add a comment |
Worked like charm, thank you. Regards, Kumarjit
– Kumarjit Ghosh
Jan 8 at 13:11
1
I suspect using+
instead of;
makes a big difference here.
– Kevin
Jan 8 at 18:25
This is the speedy way -- avoid a check. I would further use find to make a list of only files you have permission to change this will avoid chmod error-ing out on files it cannot change. <pre> <code> # rwx, rw, wx, w only find . -user $(whoami) -perm /002 ! -perm 0755 -exec chmod 0755 {} ; # break into two operations find . -user $(whoami) -perm /002 ! -perm 0755 > /tmp/chfiles.txt for file in $(</tmp/chfiles.txt) do chmod --quiet 0755 "${file}" done </code></pre>
– Chris Reid
Jan 8 at 20:26
@ChrisReid Note that looping over a list of pathnames like that will break if any pathname contains a whitespace character.
– Kusalananda
Jan 8 at 20:30
I guess you need to change the Internal Field Separator (IFS) to 'n' in a script. These are environment settings, the way the shell interprets them is dependent on the values of those settings. I test scripts on dummy files before using them to ferret out blunderous distasters like renaming files or overwriting them. I like the shell printf way of setting IFS. IFS=$(printf "n") # very readable
– Chris Reid
Jan 9 at 22:28
Worked like charm, thank you. Regards, Kumarjit
– Kumarjit Ghosh
Jan 8 at 13:11
Worked like charm, thank you. Regards, Kumarjit
– Kumarjit Ghosh
Jan 8 at 13:11
1
1
I suspect using
+
instead of ;
makes a big difference here.– Kevin
Jan 8 at 18:25
I suspect using
+
instead of ;
makes a big difference here.– Kevin
Jan 8 at 18:25
This is the speedy way -- avoid a check. I would further use find to make a list of only files you have permission to change this will avoid chmod error-ing out on files it cannot change. <pre> <code> # rwx, rw, wx, w only find . -user $(whoami) -perm /002 ! -perm 0755 -exec chmod 0755 {} ; # break into two operations find . -user $(whoami) -perm /002 ! -perm 0755 > /tmp/chfiles.txt for file in $(</tmp/chfiles.txt) do chmod --quiet 0755 "${file}" done </code></pre>
– Chris Reid
Jan 8 at 20:26
This is the speedy way -- avoid a check. I would further use find to make a list of only files you have permission to change this will avoid chmod error-ing out on files it cannot change. <pre> <code> # rwx, rw, wx, w only find . -user $(whoami) -perm /002 ! -perm 0755 -exec chmod 0755 {} ; # break into two operations find . -user $(whoami) -perm /002 ! -perm 0755 > /tmp/chfiles.txt for file in $(</tmp/chfiles.txt) do chmod --quiet 0755 "${file}" done </code></pre>
– Chris Reid
Jan 8 at 20:26
@ChrisReid Note that looping over a list of pathnames like that will break if any pathname contains a whitespace character.
– Kusalananda
Jan 8 at 20:30
@ChrisReid Note that looping over a list of pathnames like that will break if any pathname contains a whitespace character.
– Kusalananda
Jan 8 at 20:30
I guess you need to change the Internal Field Separator (IFS) to 'n' in a script. These are environment settings, the way the shell interprets them is dependent on the values of those settings. I test scripts on dummy files before using them to ferret out blunderous distasters like renaming files or overwriting them. I like the shell printf way of setting IFS. IFS=$(printf "n") # very readable
– Chris Reid
Jan 9 at 22:28
I guess you need to change the Internal Field Separator (IFS) to 'n' in a script. These are environment settings, the way the shell interprets them is dependent on the values of those settings. I test scripts on dummy files before using them to ferret out blunderous distasters like renaming files or overwriting them. I like the shell printf way of setting IFS. IFS=$(printf "n") # very readable
– Chris Reid
Jan 9 at 22:28
add a comment |
As find
have gotten the -exec ... +
syntax, there's not much point in using xargs
, but as you ask for it:
find /main_directory -not -perm 0755 | xargs chmod 755
1
Also note that xargs without-0
(in combination with-print0
in find; which is GNU extension) can be pretty problematic security-wise if potential attacker can create filenames which include whitespaces or other special characters in them. So better stick to-exec
when you can
– Matija Nalis
Jan 8 at 17:08
No need forxargs
(just use-exec
), and if you do use it you should use-print0
/-0
like Matija says.
– Kevin
Jan 8 at 18:24
add a comment |
As find
have gotten the -exec ... +
syntax, there's not much point in using xargs
, but as you ask for it:
find /main_directory -not -perm 0755 | xargs chmod 755
1
Also note that xargs without-0
(in combination with-print0
in find; which is GNU extension) can be pretty problematic security-wise if potential attacker can create filenames which include whitespaces or other special characters in them. So better stick to-exec
when you can
– Matija Nalis
Jan 8 at 17:08
No need forxargs
(just use-exec
), and if you do use it you should use-print0
/-0
like Matija says.
– Kevin
Jan 8 at 18:24
add a comment |
As find
have gotten the -exec ... +
syntax, there's not much point in using xargs
, but as you ask for it:
find /main_directory -not -perm 0755 | xargs chmod 755
As find
have gotten the -exec ... +
syntax, there's not much point in using xargs
, but as you ask for it:
find /main_directory -not -perm 0755 | xargs chmod 755
answered Jan 8 at 9:42


HenrikHenrik
3,6311419
3,6311419
1
Also note that xargs without-0
(in combination with-print0
in find; which is GNU extension) can be pretty problematic security-wise if potential attacker can create filenames which include whitespaces or other special characters in them. So better stick to-exec
when you can
– Matija Nalis
Jan 8 at 17:08
No need forxargs
(just use-exec
), and if you do use it you should use-print0
/-0
like Matija says.
– Kevin
Jan 8 at 18:24
add a comment |
1
Also note that xargs without-0
(in combination with-print0
in find; which is GNU extension) can be pretty problematic security-wise if potential attacker can create filenames which include whitespaces or other special characters in them. So better stick to-exec
when you can
– Matija Nalis
Jan 8 at 17:08
No need forxargs
(just use-exec
), and if you do use it you should use-print0
/-0
like Matija says.
– Kevin
Jan 8 at 18:24
1
1
Also note that xargs without
-0
(in combination with -print0
in find; which is GNU extension) can be pretty problematic security-wise if potential attacker can create filenames which include whitespaces or other special characters in them. So better stick to -exec
when you can– Matija Nalis
Jan 8 at 17:08
Also note that xargs without
-0
(in combination with -print0
in find; which is GNU extension) can be pretty problematic security-wise if potential attacker can create filenames which include whitespaces or other special characters in them. So better stick to -exec
when you can– Matija Nalis
Jan 8 at 17:08
No need for
xargs
(just use -exec
), and if you do use it you should use -print0
/-0
like Matija says.– Kevin
Jan 8 at 18:24
No need for
xargs
(just use -exec
), and if you do use it you should use -print0
/-0
like Matija says.– Kevin
Jan 8 at 18:24
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493181%2fuse-chmod-command-selectively%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
6
This may be premature optimisation, and it may not even make if faster. Doing all of those checks may slow it down. Testing to ensure that it is faster, will only pay off, if you have to do this a lot.
– ctrl-alt-delor
Jan 8 at 9:51
3
You probably don't want to give execute permissions to all files. This will create a security risk. (this is one of the virus vectors on Microsoft's Windows: everything is executable). In symbolic mode you can say
u+rw,go+r,go-w,ugo+X
— note the capital.– ctrl-alt-delor
Jan 8 at 9:53
I agree with @ctrl-alt-delor but would suggest something closer to what you asked, u=rwX,go=rX which should achieve the same thing.
– penguin359
Jan 9 at 1:13