How can I get the unix group name based on the group id?

The libc function for this is getgrgid().

To use it from the shell, try this command:

getent group GID | cut -d: -f1