List of all ids,groups, privilege ids

I wish to pull out a list of all user ids on the system, including the privileged ids, the groups to which they belong to. Sometimes after deleting an id also, its home dir does not get deleted or an entry is left behind in /etc/passwd.
Can someone help me with a script to achieve both.

On what exact version of unix or linux are you working on?

Try something with

getent passwd

That works on many OS.