Give specific user permission to write to a folder using +w notation











up vote
119
down vote

favorite
49












I know I can assign the permission to write to an owner/group/others like this:



chmod u+w myfolder


Can I specify the specific user here? Some like this:



chmod username u+w myfolder









share|improve this question
























  • I don't think it's possible. Why don't you just add the user to the group?
    – Emil
    Jun 24 '14 at 10:50















up vote
119
down vote

favorite
49












I know I can assign the permission to write to an owner/group/others like this:



chmod u+w myfolder


Can I specify the specific user here? Some like this:



chmod username u+w myfolder









share|improve this question
























  • I don't think it's possible. Why don't you just add the user to the group?
    – Emil
    Jun 24 '14 at 10:50













up vote
119
down vote

favorite
49









up vote
119
down vote

favorite
49






49





I know I can assign the permission to write to an owner/group/others like this:



chmod u+w myfolder


Can I specify the specific user here? Some like this:



chmod username u+w myfolder









share|improve this question















I know I can assign the permission to write to an owner/group/others like this:



chmod u+w myfolder


Can I specify the specific user here? Some like this:



chmod username u+w myfolder






permissions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 10 at 23:09









Charo

2,04821226




2,04821226










asked Jun 24 '14 at 10:33









Max Koretskyi aka Wizard

80421015




80421015












  • I don't think it's possible. Why don't you just add the user to the group?
    – Emil
    Jun 24 '14 at 10:50


















  • I don't think it's possible. Why don't you just add the user to the group?
    – Emil
    Jun 24 '14 at 10:50
















I don't think it's possible. Why don't you just add the user to the group?
– Emil
Jun 24 '14 at 10:50




I don't think it's possible. Why don't you just add the user to the group?
– Emil
Jun 24 '14 at 10:50










3 Answers
3






active

oldest

votes

















up vote
122
down vote



accepted










If you want to change the user owning this file or directory (folder), you will have to use the command chown. For instance, if you run



sudo chown username: myfolder


the user owning myfolder will be username. Then you can execute



sudo chmod u+w myfolder


to add the write permission to the username user.



But if you want to add this user to the group associated with "myfolder", you can run



sudo usermod -a -G groupname username


and then execute



sudo chmod g+w myfolder


to add the write permission to the group.






share|improve this answer























  • There is a way in which both users will have access to the folder, and a group is not needed; it was suggested in an answer for the same question here: superuser.com/a/235398/191720.
    – Luan Nico
    Feb 3 '16 at 17:17










  • Can I do this without sudo?
    – becko
    Jun 2 '16 at 13:36






  • 1




    @becko: You can if you drop to a root shell.
    – Charo
    Jun 2 '16 at 14:07










  • @Charo I meant without root
    – becko
    Jun 2 '16 at 14:28






  • 1




    @AER: In the first command, if a colon follows username the owning group is also changed to username (if you omit such a colon, the owning group will not change).
    – Charo
    Apr 18 at 8:46


















up vote
152
down vote













You could use setfacl:



setfacl -m u:username:rwx myfolder


This sets permissions for specific users, without changing the ownership of the directory.



Check out the man page for further details and examples.






share|improve this answer



















  • 8




    Perfect answer! Also setfacl is available on CentOS (yum -y install acl) & FreeBSD as well.
    – Viet
    Apr 20 '17 at 12:21






  • 4




    just a note: setfacl = set File ACL, ACL = Access Control List hence for short "setFacl" - easier way to remember i think.
    – Yawar Murtaza
    Aug 22 '17 at 10:29






  • 5




    If you want to apply it recursively to all the subdirectories: add the -R flag like this: setfacl -R -m u:username:rwx myfolder
    – Jose A
    Mar 14 at 21:01












  • easiest way to give permission for a new user
    – Rajesh Mbm
    Mar 17 at 17:03






  • 1




    Is there a way to grant a user rw without changing any existing x permission, if operating on multiple files or recursively?
    – Qi Fan
    Apr 23 at 21:58




















up vote
7
down vote













No this is not possible. You can either change the owner of the file with



[sudo] chown username: foldername


or you can add the user to the group that owns the file with



usermod -a -G {group-name} username





share|improve this answer























  • useradd -G {group-name} username tells me that username already exists
    – Erdal G.
    Sep 20 '16 at 11:51










  • i tried this but my user still can't write to that folder
    – Sonic Soul
    Sep 9 at 16:32











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f487527%2fgive-specific-user-permission-to-write-to-a-folder-using-w-notation%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
122
down vote



accepted










If you want to change the user owning this file or directory (folder), you will have to use the command chown. For instance, if you run



sudo chown username: myfolder


the user owning myfolder will be username. Then you can execute



sudo chmod u+w myfolder


to add the write permission to the username user.



But if you want to add this user to the group associated with "myfolder", you can run



sudo usermod -a -G groupname username


and then execute



sudo chmod g+w myfolder


to add the write permission to the group.






share|improve this answer























  • There is a way in which both users will have access to the folder, and a group is not needed; it was suggested in an answer for the same question here: superuser.com/a/235398/191720.
    – Luan Nico
    Feb 3 '16 at 17:17










  • Can I do this without sudo?
    – becko
    Jun 2 '16 at 13:36






  • 1




    @becko: You can if you drop to a root shell.
    – Charo
    Jun 2 '16 at 14:07










  • @Charo I meant without root
    – becko
    Jun 2 '16 at 14:28






  • 1




    @AER: In the first command, if a colon follows username the owning group is also changed to username (if you omit such a colon, the owning group will not change).
    – Charo
    Apr 18 at 8:46















up vote
122
down vote



accepted










If you want to change the user owning this file or directory (folder), you will have to use the command chown. For instance, if you run



sudo chown username: myfolder


the user owning myfolder will be username. Then you can execute



sudo chmod u+w myfolder


to add the write permission to the username user.



But if you want to add this user to the group associated with "myfolder", you can run



sudo usermod -a -G groupname username


and then execute



sudo chmod g+w myfolder


to add the write permission to the group.






share|improve this answer























  • There is a way in which both users will have access to the folder, and a group is not needed; it was suggested in an answer for the same question here: superuser.com/a/235398/191720.
    – Luan Nico
    Feb 3 '16 at 17:17










  • Can I do this without sudo?
    – becko
    Jun 2 '16 at 13:36






  • 1




    @becko: You can if you drop to a root shell.
    – Charo
    Jun 2 '16 at 14:07










  • @Charo I meant without root
    – becko
    Jun 2 '16 at 14:28






  • 1




    @AER: In the first command, if a colon follows username the owning group is also changed to username (if you omit such a colon, the owning group will not change).
    – Charo
    Apr 18 at 8:46













up vote
122
down vote



accepted







up vote
122
down vote



accepted






If you want to change the user owning this file or directory (folder), you will have to use the command chown. For instance, if you run



sudo chown username: myfolder


the user owning myfolder will be username. Then you can execute



sudo chmod u+w myfolder


to add the write permission to the username user.



But if you want to add this user to the group associated with "myfolder", you can run



sudo usermod -a -G groupname username


and then execute



sudo chmod g+w myfolder


to add the write permission to the group.






share|improve this answer














If you want to change the user owning this file or directory (folder), you will have to use the command chown. For instance, if you run



sudo chown username: myfolder


the user owning myfolder will be username. Then you can execute



sudo chmod u+w myfolder


to add the write permission to the username user.



But if you want to add this user to the group associated with "myfolder", you can run



sudo usermod -a -G groupname username


and then execute



sudo chmod g+w myfolder


to add the write permission to the group.







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 8 '16 at 10:40









jokerdino

32.4k21118186




32.4k21118186










answered Jun 24 '14 at 10:55









Charo

2,04821226




2,04821226












  • There is a way in which both users will have access to the folder, and a group is not needed; it was suggested in an answer for the same question here: superuser.com/a/235398/191720.
    – Luan Nico
    Feb 3 '16 at 17:17










  • Can I do this without sudo?
    – becko
    Jun 2 '16 at 13:36






  • 1




    @becko: You can if you drop to a root shell.
    – Charo
    Jun 2 '16 at 14:07










  • @Charo I meant without root
    – becko
    Jun 2 '16 at 14:28






  • 1




    @AER: In the first command, if a colon follows username the owning group is also changed to username (if you omit such a colon, the owning group will not change).
    – Charo
    Apr 18 at 8:46


















  • There is a way in which both users will have access to the folder, and a group is not needed; it was suggested in an answer for the same question here: superuser.com/a/235398/191720.
    – Luan Nico
    Feb 3 '16 at 17:17










  • Can I do this without sudo?
    – becko
    Jun 2 '16 at 13:36






  • 1




    @becko: You can if you drop to a root shell.
    – Charo
    Jun 2 '16 at 14:07










  • @Charo I meant without root
    – becko
    Jun 2 '16 at 14:28






  • 1




    @AER: In the first command, if a colon follows username the owning group is also changed to username (if you omit such a colon, the owning group will not change).
    – Charo
    Apr 18 at 8:46
















There is a way in which both users will have access to the folder, and a group is not needed; it was suggested in an answer for the same question here: superuser.com/a/235398/191720.
– Luan Nico
Feb 3 '16 at 17:17




There is a way in which both users will have access to the folder, and a group is not needed; it was suggested in an answer for the same question here: superuser.com/a/235398/191720.
– Luan Nico
Feb 3 '16 at 17:17












Can I do this without sudo?
– becko
Jun 2 '16 at 13:36




Can I do this without sudo?
– becko
Jun 2 '16 at 13:36




1




1




@becko: You can if you drop to a root shell.
– Charo
Jun 2 '16 at 14:07




@becko: You can if you drop to a root shell.
– Charo
Jun 2 '16 at 14:07












@Charo I meant without root
– becko
Jun 2 '16 at 14:28




@Charo I meant without root
– becko
Jun 2 '16 at 14:28




1




1




@AER: In the first command, if a colon follows username the owning group is also changed to username (if you omit such a colon, the owning group will not change).
– Charo
Apr 18 at 8:46




@AER: In the first command, if a colon follows username the owning group is also changed to username (if you omit such a colon, the owning group will not change).
– Charo
Apr 18 at 8:46












up vote
152
down vote













You could use setfacl:



setfacl -m u:username:rwx myfolder


This sets permissions for specific users, without changing the ownership of the directory.



Check out the man page for further details and examples.






share|improve this answer



















  • 8




    Perfect answer! Also setfacl is available on CentOS (yum -y install acl) & FreeBSD as well.
    – Viet
    Apr 20 '17 at 12:21






  • 4




    just a note: setfacl = set File ACL, ACL = Access Control List hence for short "setFacl" - easier way to remember i think.
    – Yawar Murtaza
    Aug 22 '17 at 10:29






  • 5




    If you want to apply it recursively to all the subdirectories: add the -R flag like this: setfacl -R -m u:username:rwx myfolder
    – Jose A
    Mar 14 at 21:01












  • easiest way to give permission for a new user
    – Rajesh Mbm
    Mar 17 at 17:03






  • 1




    Is there a way to grant a user rw without changing any existing x permission, if operating on multiple files or recursively?
    – Qi Fan
    Apr 23 at 21:58

















up vote
152
down vote













You could use setfacl:



setfacl -m u:username:rwx myfolder


This sets permissions for specific users, without changing the ownership of the directory.



Check out the man page for further details and examples.






share|improve this answer



















  • 8




    Perfect answer! Also setfacl is available on CentOS (yum -y install acl) & FreeBSD as well.
    – Viet
    Apr 20 '17 at 12:21






  • 4




    just a note: setfacl = set File ACL, ACL = Access Control List hence for short "setFacl" - easier way to remember i think.
    – Yawar Murtaza
    Aug 22 '17 at 10:29






  • 5




    If you want to apply it recursively to all the subdirectories: add the -R flag like this: setfacl -R -m u:username:rwx myfolder
    – Jose A
    Mar 14 at 21:01












  • easiest way to give permission for a new user
    – Rajesh Mbm
    Mar 17 at 17:03






  • 1




    Is there a way to grant a user rw without changing any existing x permission, if operating on multiple files or recursively?
    – Qi Fan
    Apr 23 at 21:58















up vote
152
down vote










up vote
152
down vote









You could use setfacl:



setfacl -m u:username:rwx myfolder


This sets permissions for specific users, without changing the ownership of the directory.



Check out the man page for further details and examples.






share|improve this answer














You could use setfacl:



setfacl -m u:username:rwx myfolder


This sets permissions for specific users, without changing the ownership of the directory.



Check out the man page for further details and examples.







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 27 '16 at 16:19









muru

135k20289492




135k20289492










answered Aug 8 '16 at 9:59









user3689208

1,620144




1,620144








  • 8




    Perfect answer! Also setfacl is available on CentOS (yum -y install acl) & FreeBSD as well.
    – Viet
    Apr 20 '17 at 12:21






  • 4




    just a note: setfacl = set File ACL, ACL = Access Control List hence for short "setFacl" - easier way to remember i think.
    – Yawar Murtaza
    Aug 22 '17 at 10:29






  • 5




    If you want to apply it recursively to all the subdirectories: add the -R flag like this: setfacl -R -m u:username:rwx myfolder
    – Jose A
    Mar 14 at 21:01












  • easiest way to give permission for a new user
    – Rajesh Mbm
    Mar 17 at 17:03






  • 1




    Is there a way to grant a user rw without changing any existing x permission, if operating on multiple files or recursively?
    – Qi Fan
    Apr 23 at 21:58
















  • 8




    Perfect answer! Also setfacl is available on CentOS (yum -y install acl) & FreeBSD as well.
    – Viet
    Apr 20 '17 at 12:21






  • 4




    just a note: setfacl = set File ACL, ACL = Access Control List hence for short "setFacl" - easier way to remember i think.
    – Yawar Murtaza
    Aug 22 '17 at 10:29






  • 5




    If you want to apply it recursively to all the subdirectories: add the -R flag like this: setfacl -R -m u:username:rwx myfolder
    – Jose A
    Mar 14 at 21:01












  • easiest way to give permission for a new user
    – Rajesh Mbm
    Mar 17 at 17:03






  • 1




    Is there a way to grant a user rw without changing any existing x permission, if operating on multiple files or recursively?
    – Qi Fan
    Apr 23 at 21:58










8




8




Perfect answer! Also setfacl is available on CentOS (yum -y install acl) & FreeBSD as well.
– Viet
Apr 20 '17 at 12:21




Perfect answer! Also setfacl is available on CentOS (yum -y install acl) & FreeBSD as well.
– Viet
Apr 20 '17 at 12:21




4




4




just a note: setfacl = set File ACL, ACL = Access Control List hence for short "setFacl" - easier way to remember i think.
– Yawar Murtaza
Aug 22 '17 at 10:29




just a note: setfacl = set File ACL, ACL = Access Control List hence for short "setFacl" - easier way to remember i think.
– Yawar Murtaza
Aug 22 '17 at 10:29




5




5




If you want to apply it recursively to all the subdirectories: add the -R flag like this: setfacl -R -m u:username:rwx myfolder
– Jose A
Mar 14 at 21:01






If you want to apply it recursively to all the subdirectories: add the -R flag like this: setfacl -R -m u:username:rwx myfolder
– Jose A
Mar 14 at 21:01














easiest way to give permission for a new user
– Rajesh Mbm
Mar 17 at 17:03




easiest way to give permission for a new user
– Rajesh Mbm
Mar 17 at 17:03




1




1




Is there a way to grant a user rw without changing any existing x permission, if operating on multiple files or recursively?
– Qi Fan
Apr 23 at 21:58






Is there a way to grant a user rw without changing any existing x permission, if operating on multiple files or recursively?
– Qi Fan
Apr 23 at 21:58












up vote
7
down vote













No this is not possible. You can either change the owner of the file with



[sudo] chown username: foldername


or you can add the user to the group that owns the file with



usermod -a -G {group-name} username





share|improve this answer























  • useradd -G {group-name} username tells me that username already exists
    – Erdal G.
    Sep 20 '16 at 11:51










  • i tried this but my user still can't write to that folder
    – Sonic Soul
    Sep 9 at 16:32















up vote
7
down vote













No this is not possible. You can either change the owner of the file with



[sudo] chown username: foldername


or you can add the user to the group that owns the file with



usermod -a -G {group-name} username





share|improve this answer























  • useradd -G {group-name} username tells me that username already exists
    – Erdal G.
    Sep 20 '16 at 11:51










  • i tried this but my user still can't write to that folder
    – Sonic Soul
    Sep 9 at 16:32













up vote
7
down vote










up vote
7
down vote









No this is not possible. You can either change the owner of the file with



[sudo] chown username: foldername


or you can add the user to the group that owns the file with



usermod -a -G {group-name} username





share|improve this answer














No this is not possible. You can either change the owner of the file with



[sudo] chown username: foldername


or you can add the user to the group that owns the file with



usermod -a -G {group-name} username






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 5 at 8:58









David Foerster

27.6k1364109




27.6k1364109










answered Jun 24 '14 at 11:03









Pabi

5,59933042




5,59933042












  • useradd -G {group-name} username tells me that username already exists
    – Erdal G.
    Sep 20 '16 at 11:51










  • i tried this but my user still can't write to that folder
    – Sonic Soul
    Sep 9 at 16:32


















  • useradd -G {group-name} username tells me that username already exists
    – Erdal G.
    Sep 20 '16 at 11:51










  • i tried this but my user still can't write to that folder
    – Sonic Soul
    Sep 9 at 16:32
















useradd -G {group-name} username tells me that username already exists
– Erdal G.
Sep 20 '16 at 11:51




useradd -G {group-name} username tells me that username already exists
– Erdal G.
Sep 20 '16 at 11:51












i tried this but my user still can't write to that folder
– Sonic Soul
Sep 9 at 16:32




i tried this but my user still can't write to that folder
– Sonic Soul
Sep 9 at 16:32


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f487527%2fgive-specific-user-permission-to-write-to-a-folder-using-w-notation%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

數位音樂下載

格利澤436b

When can things happen in Etherscan, such as the picture below?