LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 03-02-2017, 06:03 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
How to make a group owner be a user owner of a file?


How to make a group owner be a user owner of a file?
Is this possible?

One can change group ownership of a
file using chown or chgrp.
Create a group using groupadd.

But is it possible to make a group name to
become a user owner of a file?
Note that this group does not have a user name
it just has a group name (obviously!).


I do not think it is possible since
user owner is for user name ONLY and
NOT for group name, but there may be
a trick to do this that I do not know yet!

Am I correct?

Last edited by fanoflq; 03-02-2017 at 06:05 PM.
 
Old 03-02-2017, 06:36 PM   #2
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Can you explain more, about what you want to -accomplish-, and some examples of what you tried?

I got an 'interesting' result: (can a LQguru explain why sudo refused but su;chown 'worked'?)
Code:
user@darkstar:~$ sudo chown 3210 z #NO sudo in [some OLD thing called ...umm...] slackware! WTH is THAT? malware? :D
-bash: sudo: command not found
user@darkstar:~$ su -c chown 3210 z #or sudo, in M$Ubuntu etc
No passwd entry for user '3210'
user@darkstar:~$ ls -l
-rw-r--r-- 1 user users 0 Feb 27 21:00 z
user@darkstar:~$ grep user /etc/passwd /etc/group
/etc/passwd:user:x:1000:100:,,,:/home/user:/bin/bash
/etc/group:users:x:100:
user@darkstar:~$ su
root@darkstar:/home/user# chown 3210 z
root@darkstar:/home/user# ls -l
-rw-r--r-- 1 3210 users 0 Feb 27 21:00 z
p.s. Yes, I 'web-researched' (a little anyway ):
No results found for intitle:chown "No passwd entry for"

Last edited by Jjanel; 03-02-2017 at 06:58 PM.
 
Old 03-02-2017, 06:56 PM   #3
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872
@Jjanel

The su -c command is treating "chown" as the command and "3210" as the user you want to run the command as.

Try enclosing the whole command in quotes e.g. su -c 'chown 3210 z'
 
1 members found this post helpful.
Old 03-02-2017, 07:08 PM   #4
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
A group and a user are fundamentally different, so no a group can only be the group owner of a file, not the user owner of a file.

Is there a specific issue you have here? It'll probably be something covered under SGID or Filesystem ACLs...
 
Old 03-02-2017, 07:11 PM   #5
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Oh! Thanks! Yup, that fixed it! **MY Noob mistake!** And sudo (of course) worked [in Ubu]:
Code:
user@ubuntu:~/dir$ ls
user@ubuntu:~/dir$ touch z
user@ubuntu:~/dir$ sudo chown 3210 z
[sudo] password for user:
user@ubuntu:~/dir$ ls -l #note: use -n switch in ls, to see NUMeric IDs!
-rw-rw-r-- 1 3210 user 0 Mar  2 15:25 z
Now, any idea what OP is trying to say?

Last edited by Jjanel; 03-02-2017 at 07:44 PM.
 
Old 03-02-2017, 07:15 PM   #6
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Having a group id (GID) being used in place of the users ID (UID) in an ACL is not going to work

Code:
bash-4.3# getfacl -n flg.inod 
# file: flg.inod
# owner: 1001 <--UID must match a UID in /etc/password
# group: 1000 <--GID must match a GID in /etc/group
user::rw-
group::r--
other::r--
So yes, you are correct
NOTE: The names are just for our convenience (or confusion depending on your naming conventions for groups and users) only the UID/GID numbers are referenced by the system

Last edited by dijetlo; 03-02-2017 at 07:23 PM.
 
1 members found this post helpful.
Old 03-02-2017, 07:41 PM   #7
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
A group and a user are fundamentally different, so no a group can only be the group owner of a file, not the user owner of a file.

Is there a specific issue you have here? It'll probably be something covered under SGID or Filesystem ACLs...
No, nothing specific.
It is just something I was wondering.
With ACL, you can only assign permission using u, g, or o.
It is still not possible to assign a group name to a user in ACL using setfacl.

Code:
#Granting a group as user for access would generate error
   setfacl -m u:some_group_name:rwx file3
 
Old 03-02-2017, 08:27 PM   #8
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
No, even when it is acls, because how the system treats a user and a group are different. Also the system doesn't store it by names but by numerical id, the system just does a look-up on /etc/passwd to convert the uid and on /etc/group to convert the uid and the gid into names when you view them but if you looked at it how the system looks at it then it's just a normal integer field. Specifically I believe it is a 2 byte unsigned integer but not looking that up now to confirm... so there is nothing in there that allows for the system to distinguish between a user or a group. AFAIK ACLs use the same format for permissions but rather as being stored as a property of the file, they are stored else where in the meta data.
 
1 members found this post helpful.
Old 03-02-2017, 09:03 PM   #9
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by r3sistance View Post
No, even when it is acls, because how the system treats a user and a group are different. Also the system doesn't store it by names but by numerical id, the system just does a look-up on /etc/passwd to convert the uid and on /etc/group to convert the uid and the gid into names when you view them but if you looked at it how the system looks at it then it's just a normal integer field. Specifically I believe it is a 2 byte unsigned integer but not looking that up now to confirm... so there is nothing in there that allows for the system to distinguish between a user or a group. AFAIK ACLs use the same format for permissions but rather as being stored as a property of the file, they are stored else where in the meta data.

I like the above underlined explanation.
What is "AFAIK ACLs"?
 
Old 03-02-2017, 09:05 PM   #10
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
AFAIK = As Far As I Know
 
Old 03-02-2017, 11:57 PM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,700

Rep: Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494
Just to be extremely clear, UIDs and GIDs are separate lists, so you can have the same UID and GID value, but it has no effect - they are still separate namespaces (although as above, its all stored in /etc/passwd, /etc/group.
If you deleted and entry there, the file/dir prev owned by the deleted user (or group), would still exist, but it would show up with the UID (or GID) number, as those values are stored in each file's metadata (see ctime).

HTH
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change of owner and group owner of a file belongs to diff user ? somorg Linux - Newbie 3 06-14-2015 10:11 AM
change of owner and group owner of a file belongs to diff user ? somorg Linux - Security 2 06-13-2015 03:33 AM
change of owner and group owner of a file belongs to diff user ? somorg Linux - General 2 06-12-2015 11:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration