Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-27-2016, 11:35 AM
|
#1
|
LQ Newbie
Registered: Aug 2014
Posts: 24
Rep: 
|
[SOLVED] file permissions
Let me be user_A who executes:
> sudo -u user_B rm /home/user_B/foo
> sudo -u user_B touch /home/user_B/foo
All seemingly works well; the file is created as evidenced by
> sudo -u user_B ls -l /home/user_B/foo
-rw------- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo
The question is: How can I make it happen (assuming I have root access) that when /home/user_B/foo is created, the user_B group automagically has read and write permissions... i.e., the following would happen
> sudo -u user_B ls -l /home/user_B/foo
-rw-rw---- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo
Last edited by hopeless_n00b; 10-27-2016 at 05:57 PM.
Reason: hoplessly botched my first attempt at describing the issue
|
|
|
10-27-2016, 01:05 PM
|
#2
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep: 
|
Maybe tell us what you are willing to do?
|
|
|
10-27-2016, 01:14 PM
|
#3
|
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,739
|
I wrote up something similar to this in a blog post, https://www.linuxquestions.org/quest...e-users-37043/
How close does that get you to your goal? The changes there apply only to the directories you choose and then only the users in the designated group would get write access, not all of the users.
|
|
1 members found this post helpful.
|
10-27-2016, 02:13 PM
|
#4
|
LQ Newbie
Registered: Aug 2014
Posts: 24
Original Poster
Rep: 
|
write access still denied
I figured out how to edit my question, and so moved the revision (which was here) to the top so that people reading the post would have a more accurate idea of my issue.
Upon following the link in the third post above, I came to appreciate that when user_A executes
> sudo -u user_B touch /home/user_B/foo
it is the umask of user_A that has an influence on the result: if the umask of user_A is 0000 then
> sudo -u user_B ls -l /home/user_B/foo
-rw-r----- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo
I remain mystified as to why write access is denied the user_B group (by the way, I did chmod g+s on directories as advised).
Moreover, User_A does not wish to have umask 0000 . Is there a way around that without Access control lists?
Last edited by hopeless_n00b; 10-27-2016 at 03:26 PM.
Reason: making my posts more coherent
|
|
|
10-27-2016, 02:16 PM
|
#5
|
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,739
|
Quote:
Originally Posted by hopeless_n00b
The question is: How can I make it happen (assuming I have root access) that when /home/user_B/foo is created, the user_B group automagically has read and write permissions... i.e., the following would happen
> sudo -u user_B ls -l /home/user_B/foo
-rw-rw---- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo
|
The gist is that you set the setGID bit for that directory and that the directory is using a group that user_B is a member of. But depending on your umask, you might have to do other tricks. Try the link in #3 above.
|
|
|
10-27-2016, 03:51 PM
|
#6
|
LQ Guru
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342
|
Quote:
Originally Posted by Habitual
Maybe tell us what you are willing to do?
|
what he is willing to do?
what you got in mind. yo?
|
|
|
10-27-2016, 04:21 PM
|
#7
|
LQ Newbie
Registered: Aug 2014
Posts: 24
Original Poster
Rep: 
|
reply to BW-userx
I'm trying to do that which is described in the top post
|
|
|
10-27-2016, 05:00 PM
|
#8
|
LQ Newbie
Registered: Aug 2014
Posts: 24
Original Poster
Rep: 
|
O.K., user_A can have whatever umask wanted, but have it temporarily set to 0000 as follows
> ( umask 0000 ; sudo -u user_B touch /home/user_B/foo )
When the above command finishes the umask for user_A is unchanged, and
> sudo -u user_B ls -l /home/user_B/foo
-rw-r--r-- 1 user_B user_B 0 Oct 27 17:53 /home/user_B/foo
So I almost have a solution... But how can I automagicaly get write permission for the user_B group ?
Last edited by hopeless_n00b; 10-27-2016 at 05:02 PM.
|
|
|
10-27-2016, 05:55 PM
|
#9
|
LQ Newbie
Registered: Aug 2014
Posts: 24
Original Poster
Rep: 
|
need to modify sudo line
FINALLY !!!
The following succeeds:
> ( umask 0000 ; sudo -u ff -- sh -c '( umask 0000 ; touch /home/ff/foo )' )
Thanks to Turbocapitalist who got me thinking in the right direction
|
|
|
10-27-2016, 10:23 PM
|
#10
|
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,739
|
Quote:
Originally Posted by hopeless_n00b
> ( umask 0000 ; sudo -u ff -- sh -c '( umask 0000 ; touch /home/ff/foo )' )
|
That'll give write access to everybody, not just those in your group. Setting the umask is only incidental to using the right group name and using the SetGID bit. If you do set it, it might be 0002 or something. It is the group and SetGID bit that do the work here.
|
|
|
All times are GMT -5. The time now is 11:25 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|