2009/3/3 satrun77 <[email protected]>:
> You can use the following command to list the uid/username, gid/
> groupname, and the groups each user belongs to…
>
> for user in `cat /etc/passwd | cut -d: -f1`; do id $user; done
>
> You will get an output in the following format…
>
> uid=1(user) gid=2(group) groups=2(group), 3(users), 4(system)

That is fine for handling local users. If you want something that also
handles remote users (eg from winbind or ldap etc), you'll probably
want to use getent.

eg:

for user in `getent passwd | cut -d: -f1`; do id $user; done

You can also do getent group for a list of local and remote groups.

-- 
Cheers
Anton

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to