Operating System - HP-UX
1820553 Members
2830 Online
109626 Solutions
New Discussion юеВ

Re: user name not updated in /etc/group file

 
chandregowda
Advisor

user name not updated in /etc/group file

Hi

I have created user abc123 with primary group "users" and secondary group "work".but user abc123 is not showing in group "user" in the in /etc/group file.

i have given commands like below

$more /etc/passwd|grep abc123
abc123:*:21344:20:testuser:/home/test:/usr/bin/ksh

$more /etc/group |grep users
users::20:root,arcade

but if i check with id commannd its displaying the groupname for abc123
$id -ng abc123
users

$id -nG abc123
work


Thanks
chandra
9 REPLIES 9
Robert-Jan Goossens
Honored Contributor

Re: user name not updated in /etc/group file

Hi Chandra,

abc123 is part of the primary group users, have a look at your output from the password file.

abc123:*:21344:20:testuser:/home/test:/usr/bin/ksh

His id is 21344 and his primary group is 20. The primary group 20 correspond to the group users.

Regards,
Robert-Jan

Ivan Krastev
Honored Contributor

Re: user name not updated in /etc/group file

For all groups, when user belong to check with grep:

grep user /etc/group

regards,
ivan
TTr
Honored Contributor

Re: user name not updated in /etc/group file

> but user abc123 is not showing in group "user" in the in /etc/group file

I think Chandra is expecting to see user abc123 automtically appear appended at the end of "users::20:root,arcade" in /etc/group. As pointed out above the abc123 membership to "users" is via the ":20:" in the passwd file. No need to do anything with /etc/group.
For the secondary group "work", the user abc123 must be manually appended to the "work" line in /etc/group.
SKR_1
Trusted Contributor

Re: user name not updated in /etc/group file

Do

grep username /etc/group

Thanks

SKR
chandregowda
Advisor

Re: user name not updated in /etc/group file

Hi TTr

Thx for ur reply.

But i cant add abc123 to group work in/etc/group manually,because /etc/group is read only file.
Dennis Handly
Acclaimed Contributor

Re: user name not updated in /etc/group file

>but if I check with id command it's displaying the groupname for abc123

It would be better to just use "id" so we can see all of the groups.'

>But I can't add abc123 to group work in /etc/group manually because /etc/group is read only file.

By definition you are root so you can change anything. Just use vi. If it complains, use w!.
(If you want to be pedantic, you can use chmod to add then remove write permission. :-)

You can also use usermod(1M) to add secondary groups:
# usermod -u abc123 -G work

>Ivan: For all groups, when user belong to check with grep:

Wouldn't "id abc123" be easier?
chandregowda
Advisor

Re: user name not updated in /etc/group file

Hi Dennis

/etc/group file is belongs to owner and group "bin".

I am not sure wether we can change the file having the ownership bin by root user.
Dennis Handly
Acclaimed Contributor

Re: user name not updated in /etc/group file

>I am not sure whether we can change the file having the ownership bin by root user.

Unless you have /etc/ as an NFS mount, root can edit it without problems.

(If you want to be pedantic, you can use chown root:root, chmod, edit, then chmod, chown. ;-)

Using usermod(1m) looks even easier now?
Deepak Kr
Respected Contributor

Re: user name not updated in /etc/group file

Chandra,

Can you please tell us why exactly you want to update /etc/group file.

As long as id is showing all desired details you should not modify /etc/group.

provide us:

#id
# grep -i abc123 /etc/group

"There is always some scope for improvement"