1

I am trying to create several user accounts with different groups in an imx6 board. Currently, no users are created in the device. Hence, I see 1000:1000 as my default user:group ID.

The scenario I need to implement is as follows:

Create two groups: grp1, grp2

Create three users: A, B, C

User A: primary group-grp1, User B: primary group-grp1, secondary group- grp2 User C: primary group-grp2

Also, these users should be able to communicate via message queues. Users (A & B) and (B & C) should be able to communicate via message queues. Users (A & C) should not be able to communicate. In a Server/Client program, I have already set mq_open file permissions as (S_IRWXU | S_IRWXG ), so that only users in the same group can be communicated.

The steps I followed to create different users are:

adduser  abc 

This creates a user with uid:guid 1000:1000 in /etc/passwd

abc:$1$SqakfDG7$cPlfYQT8YmkcvgzazVKvZ/:1000:1000:Linux User,,,:/home/abc:/bin/sh

addgroup grp1
addgroup grp2

Above step creates two groups in /etc/group as below.

grp1:x:1001:
grp2:x:1002:

Create user A,B with grp1, and C with grp2

adduser -G grp1 A
adduser -G grp1 B
adduser -G grp2 C

This creates user A in /etc/passwd

A:$1$E8MDq2ND$/qU4011IYRaisq7EfJh00/:1001:1001:Linux User,,,:/home/A:/bin/sh
B:$1$l2iSdPAh$ggD5NQAC1nJzbVfNVO/Kk.:1002:1001:Linux User,,,:/home/B:/bin/sh
C:$1$2Y6v67Wz$TYNxHBltTNeCDhAnnAFd3.:1003:1002:Linux User,,,:/home/C:/bin/sh

And in /etc/group

A:x:1003:
B:x:1004:
C:x:1005:

As you can see users A and B has the same group id (grp1) (i.e. 1001), and my server/client program successfully run.

The issue is to add group B into the secondary group "grp2".

Typing "id A" "id B" and "id C" gives me:

uid=1001(A) gid=1001(grp1) groups=1001(grp1)
uid=1002(B) gid=1001(grp1) groups=1001(grp1)
uid=1003(C) gid=1002(grp2) groups=1002(grp2)

Tried adding user "B" to "grp2" using usermod command as explained in Primary and secondary groups

usermod -a -G grp2 B

but "id B" doesn't change

uid=1002(B) gid=1001(grp1) groups=1001(grp1)

I even tried adding user "B" to groups grp1 and grp2 when creating it for the first time

adduser -G grp1,grp2 B

However, I get the following error.

adduser: unknown group grp1,grp2

Any idea what could I have done wrong?

Thanks alot!!

1 Answer 1

0

Adding B to the group grp2 wouldn't change hist ID because his primary groups is still the grp1.

If you do:

cat /etc/group | grep grp1

What do you see? Or try the command: groups B and see what it shows. Sorry, I can't post as a comment yet.

3
  • Hi, Thanks for the reply. I tried the command "groups B" and I get "grp1" as the group. Is it possible to add grp2 as the secondary group? Is it going to affect the message q communication? Thanks a lot!!
    – radar101
    Commented Aug 10, 2017 at 4:43
  • Yes, you can add the B user in the grp2 with the command: usermod -a -G grp2 B that will add the grp2 as a secondary group for user B
    – Adonist
    Commented Aug 10, 2017 at 16:28
  • Hi Thanks for the reply. I tried the command usermod -a -G grp2 B But typing "id B" shows: uid=1002(B) gid=1001(grp1) groups=1001(grp1) Still I cannot communicate between B and C
    – radar101
    Commented Aug 11, 2017 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .