Recently on Twitter, David Coronel pointed out that the script for Linux didn't work properly on older versions of Red Hat Enterprise Linux (RHEL) because the groupmod command doesn't update users primary group in /etc/passwd. This isn't an issue on Debian/Ubuntu distributions, and I don't believe it is an issue on RHEL 6; just RHEL 5 and older.

Below is an updated version of the Linux script. It adds an optional "--gusermod" command line flag that will display usermod commands to update the primary group. You would want to use this optional flag on RHEL 5 or older systems when using the script.

For more information on how the script works and more information on standardizing UID/GID numbers, check out the AIX developerWorks article which goes in to detail on how the AIX version of the script works, and the Linux version works basically the same way. Note that this script doesn't make any changes on your system - it just generates the commands lines that can be used to make the changes (read the AIX article for more info.)

Here is the updated Linux script:

#!/usr/bin/perl
# This is unsupported code. This script is provided "as is" without warranty of
# any kind, expressed or implied, including, but not limited to, the implied
# warranty of merchantability or fitness for a particular purpose.
# Use at your own risk.
#
use Getopt::Long;
use User::pwent;
use User::grent;