You are not logged in.

#1 2019-03-09 02:16:22

tick1020
Member
Registered: 2017-04-22
Posts: 26

[Solved] Useradd Sets GID's Improperly???

So I've installed arch at least a dozen or more times on many different machines and I've always used the same command or something very similar to create my initial non-root user and the group(s) that go with it and it's always worked as I expected, except for now... For some reason on my most recent install, the useradd command didn't use (what I understand to be) the standard GID's for both groups when I tried to create and add them to my user. I don't know why or how this has always worked for me in the past since I can't seem to find any information on where the "standards" come from in the useradd man page nor from searching here or on the web briefly... Anyway, the command I used was something either very close to or exactly:

useradd -m -g users -G wheel -s /usr/bin/zsh tick

This command worked technically, creating my initial group as "users" but it made that group's GID 985 (instead of 100) and the wheel group's GID 998 (instead of 10)

And of course, I didn't even check these gid's until I started noticing (weeks later) that I couldn't access some network devices that I'd given group rwx permissions to wheel (10).

I know that I can fix this with some effort on my part but I'm just trying to understand why this has worked for me in the past but not now??? In fact, I'm pretty sure I nearly copied the above command from the old "Beginner's Guide" years and years ago... I've just used it ever since and never had any problems till now... Have I just gotten lucky all these years or should I have been using groupadd -g 10 wheel before running this command?

Would it have mattered if I was chrooted into the machine when I created the user? Although I'm pretty sure I've done that before as well without this issue

Last edited by tick1020 (2019-03-09 17:04:25)

Offline

#2 2019-03-09 02:26:52

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Useradd Sets GID's Improperly???

wiki wrote:

If an initial login group is specified by name or number, it must refer to an already existing group. If not specified, the behaviour of useradd will depend on the USERGROUPS_ENAB variable contained in /etc/login.defs. The default behaviour (USERGROUPS_ENAB yes) is to create a group with the same name as the username, with GID equal to UID.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2019-03-09 10:17:52

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: [Solved] Useradd Sets GID's Improperly???

This worked in the past because Arch used to set these groups to specific GIDs. That changed when Arch started using sysusers.d.
See https://git.archlinux.org/svntogit/pack … a0b1706ae8 , https://bugs.archlinux.org/task/45196 & https://www.archlinux.org/todo/switch-t … -sysusers/ .

Offline

#4 2019-03-09 17:03:57

tick1020
Member
Registered: 2017-04-22
Posts: 26

Re: [Solved] Useradd Sets GID's Improperly???

jasonwryan wrote:
wiki wrote:

If an initial login group is specified by name or number, it must refer to an already existing group. If not specified, the behaviour of useradd will depend on the USERGROUPS_ENAB variable contained in /etc/login.defs. The default behaviour (USERGROUPS_ENAB yes) is to create a group with the same name as the username, with GID equal to UID.

Thank you for the response but I've already seen that. That section has to do with whether or not useradd creates a group name identical to your user name. It does mention that I need to use group names that already exist but I'm trying to find out why this wasn't the case before.

nl6720 wrote:

This worked in the past because Arch used to set these groups to specific GIDs. That changed when Arch started using sysusers.d.

Now ^ this is exactly what I was looking for. Thank you so much for your reply nl6720. I didn't know that this was a thing at all. That kind of stinks that that went over my head... Now I have to figure out how to fix this situation... I guess I'll have to create a temporary user... Thanks for the replies though. I'll change this to solved.

Offline

#5 2019-03-09 18:15:50

progandy
Member
Registered: 2012-05-17
Posts: 5,193

Re: [Solved] Useradd Sets GID's Improperly???

There is "groupadd" to create a group with a specific ID. Or you could use a sysusers.d file with the same effect.
Edit: If a group already exists with the wrong ID, then you can use "groupmod" to change it.

If you have files with the wrong gids, then find/chgrp them.

Last edited by progandy (2019-03-09 18:20:09)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

Board footer

Powered by FluxBB