Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add user to a group without usermod?

Tags:

Is it possible to add a user to a group without usermod? I'm working on embedded Linux 3.14.52 and I don't have the usermod command line. If it is not possible, how add this command to kernel with Buildroot?

like image 679
M.Ferru Avatar asked Jun 13 '16 14:06

M.Ferru


People also ask

How do I add a user to a group?

To add a user to a group, specify the -a -G flags. These should be followed by the name of the group to which you want to add a user and the user's username.

How do I add a user to a supplementary group?

To add a member to a supplementary group, use the usermod command to list the supplementary groups that the user is currently a member of, and the supplementary groups that the user is to become a member of. where user-name is the user name. To display who is a member of a group, use the getent command.


2 Answers

In Buildroot, users and groups are created with the BR2_ROOTFS_USERS_TABLES configuration option. Set it to a file or list of files or users you want to create. See section 9.6 of the Buildroot manual. Note that this only allows you to specify users; groups are created automatically when a user is assigned to a group.

Alternatively, you can take control of the entire /etc/groups file by adding a filesystem overlay.

To update the group configuration at runtime, you can use the addgroup and delgroup utilities in busybox.

like image 147
Arnout Avatar answered Nov 15 '22 02:11

Arnout


The user<->group association is saved in the /etc/group file. Each line of the file is in the format:

group_name:password:GID:user_list

You can add users in the comma-separated user_list part. If you prefer to use some existing tool, you can consider gpasswd (if available).

I don't know how to help you for the kernel/buildroot question.

like image 29
Andrea Carron Avatar answered Nov 15 '22 04:11

Andrea Carron