Solved Modifying User ID and Group ID

Hello,

This weekend I'll give FreeBSD 10.2-STABLE a first try. But I've one question about user id and group id:
All machines in our LAN have Linux installed and they have user holger with id 1000 and user diane with id 1001, both are in users group with id 5000.

Is it possible to modify user and group id on FreeBSD like in a Linux system per editing /etc/passwd and /etc/group? I want to integrate FreeBSD in our LAN, and user holger also should have id 1000 and user account of my wife diane should have 1001. But it seems, that under FreeBSD the numbering for users starts with 1001.

Kind regards,
Holger
 
Last edited by a moderator:
Remember to chown(8) the user's home directory after you changed their UID or GID or they won't be able to login.
 
Hello,

Under Linux I can handle Groups and Users manually by editing /etc/group and /etc/passwd. Under FreeBSD it seems to be a little different. I want following behaviour:
User "holger" should have ID 1000, that can be set during FreeBSD installation.

a) A new group "users" should be created with Group ID 5000.
b) User "holger" should be member in "users",
c) "users" should be primary group for "holger", with other words: If I add a file under account "holger", then I want, that this file is in group "users".

How can I configure a), b) and c) properly in FreeBSD?

Kind regards,
Holger
 
I have no idea what kind a Linux you are using but /etc/passwd should not be edited unless you are using vipw(). You can add yourself into various groups by directly editing /etc/group. This is true both on RHEL and FreeBSD. Now what is not the same is how you create users and how you modify them. FreeBSD uses adduser() script to create users' accounts. To modify users and groups on FreeBSD you should be using pw(). And this is all well documented.

https://www.freebsd.org/doc/handbook/users-synopsis.html

Just like it is well documented on RHEL for example.
 
User "holger" should have ID 1000, that can be set during FreeBSD installation.

a) A new group "users" should be created with Group ID 5000.
b) User "holger" should be member in "users",
c) "users" should be primary group for "holger", with other words: If I add a file under account "holger", then I want, that this file is in group "users".

Hi Holger,

Have you seen the Handbook? Section 3.3. Users and Basic Account Management might help. In particular, the pw(8) and adduser(8) commands might be useful. Something like this might do what you want (not tested). As the root user:

pw groupadd users -g 5000
then
adduser -g users -uid 1000 and answer the prompts
or
pw useradd holger -u 1000 -g users
 
Hello Oko, hello hanzer,

Thank you for giving me some hints, also to handbook chapter of FreeBSD for managing users and groups. I've searched for this before starting comment above and have found this page:
http://www.cyberciti.biz/faq/freebsd-add-a-user-to-group/

But this page seems not to be so good, because trying some hints kicked my user "holger" out of other groups. The handbook chapter is a better reference, and also your solution, hanzer.

Kind regards,
Holger
 
Last edited by a moderator:
Back
Top