How to change the installation user's group name

Asked by Gautam

Hi...

I just did a fresh Ubuntu 10.10 installation on a system that will be used by a family of about 6-7 users. Now they want to have the family surname as the name of the primary group to which they all belong. I am however unable to change this first created group name, it always defaults to, without asking, to the name of the first user created.

Foe example, let the name of the first user be James Bond. The moment I create an user james, the group name by default becomes james. He wants it as username james groupname bond. How do I do this ? Can I somehow rename the group after the installation completed? Migrating all users to a new group does not help, as the first user, who is also an administrator, still sees the groupname by default equal to his first name.

Before I get some inane questions on why would this be ever required - here are a bunch of people, say called as James, Samantha, Super, etc., who then will see their ls -l command outputs as
-rwxr-xr-x james bond file_no_1 while his wife will see
-rwxr-xr-x samantha bond file_belonging_to_the_lady

Please help ...

Thanks in anticipation ...

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-system-tools Edit question
Assignee:
No assignee Edit question
Solved by:
Eliah Kagan
Solved:
Last query:
Last reply:
Revision history for this message
Best Eliah Kagan (degeneracypressure) said :
#1

"Migrating all users to a new group does not help, as the first user, who is also an administrator, still sees the groupname by default equal to his first name."

The migrate that user too. There's nothing special about the first user created in installation, nor is there anything special about administrators, with respect to primary group membership.

The only think I can think of that might make it seem otherwise is if you're neglecting to log that user out and back in, before using the account to create a file and see if the file's group owner is the new group.

You can perform the migration however you like. I'd probably use users-admin (System > Administration > Users and Groups), because it's graphical and easy and fast. To do it in that utility, click on the username, and then click the Advanced Settings button near the lower-right corner of the window. When the Change Advanced User Settings window comes up, click the Advanced tab and change the "Main Group" to whatever you want.

To answer the other part of your question, though it might not be relevant to the solution you implement: You can remove groups and change the ID number of groups. (The group owner of a file is stored as the group ID number of the file. If you change what group has that ID number, you change the group owner of the file. Therefore, changing groups' group ID numbers enables you to accomplish most of what you could accomplish by changing the names of groups.) To edit groups in users-admin, click the Manage Groups button. To delete a group, select it and click Delete. To change a group's ID number, select the group and click Properties.

After you change a group's group ID, if you want the files that formerly had that group as their owner to still have that group as their owner, you'll have to chgrp them again (see below).

If you really, really wanted to change a group's name, you could make all the necessary substitutions in /etc/groups and /etc/passwd. But there is really no need to do this.

On the other hand, if the issue you're experiencing (or an additional issue you're experiencing) is that the files formerly created by users (this would happen for all users, not just the first one) still have their old group ownerships, then the solution is simply to change their group ownerships. One way to do this is by running:

sudo chgrp -R bond ~james
sudo chgrp -R bond ~samantha
# and so forth

"Before I get some inane questions on why would this be ever required..."

There are plenty of reasons why someone might want all or most human users on a system to have the same primary group, and many other Unix-like operating systems default to this behavior (naming that group "staff"). However, the specific reason why your clients want this seems quite silly. But there shouldn't be any harm in it...and as the saying goes, whatever floats their boat...

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#2

Correction: "The migrate that user too." --> "Then migrate that user too."

Revision history for this message
Gautam (quasar66) said :
#3

Thanks Eliah Kagan, that solved my question.