Mukul Mehra
Mukul Mehra

Reputation: 99

How can I add a group inside /etc/group of a target root file system?

I am cross-compiling target RFS from a makefile which is executing on a host machine? Is there any specific usage of groupadd command that i should know? Also do I need to use groupadd from host linux machine or the target's embedded version of groupadd? How to specify within groupadd command to add group in the target RFS and not in the host machine. I am new to this. example : /usr/sbin/groupadd -g 1111 test_gp
I need to create 1111 inside a specific path where rfs is getting compiled,say /home/arm_build/rfs/ and then add a user under it

/usr/sbin/useradd -g test_gp -m -d /home/test_gp -p l.cjpassword -s /bin/bash -c "A test group" test_gp

what will be the equivalent command as I see there is no option to provide path in groupadd it just takes a number as gid

Upvotes: 1

Views: 974

Answers (1)

Luca Ceresoli
Luca Ceresoli

Reputation: 1661

You have many options:

  • /etc/group is nothing but a text file, so you can create it manually or from your own scripts
  • according to the manpage, groupadd --root <DIR> will modify files under <DIR>, so you can point it to the directory where you are building your root filesystem
  • don't reinvent the wheel and use an existing buildsystem: Buildroot and Yocto are the mostly used ones and of course they handle group creation

Upvotes: 1

Related Questions