- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Anyone already have a script to do this?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2006 04:52 AM
11-15-2006 04:52 AM
Does anyone have a script that go through each user and check whether their GID is valid (per /etc/groups) and if it not, put that output into a list?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2006 05:19 AM
11-15-2006 05:19 AM
SolutionThis will help:
# cat ./badgid
#!/usr/bin/perl
use strict;
use warnings;
my %gids;
my ( $name, $uid, $gid );
while ( ( undef, undef, $gid ) = getgrent ) {
$gids{$gid}++;
}
while ( ( $name, undef, $uid, $gid ) = getpwent ) {
print "uid $uid for user '$name' with gid $gid is bogus\n"
unless defined $gids{$gid};
}
1;
...This script caches the 'gid' of the group database and then proceeds to sequentially examine every user record's 'gid'.
Silenece is golden. That is, the last of output means that all 'gid's are valid. Unmatched records are produce:
uid 1002 for user 'dummy' with gid 220 is bogus
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2006 05:27 AM
11-15-2006 05:27 AM
Re: Anyone already have a script to do this?
#!/usr/bin/sh
USERLIST=/var/tmp/users_with_invalid_gid.txt
USERS=$(awk -F: '{print $1}' /etc/passwd)
for USER in ${USERS}
do
GID=$(grep ^${USER}: /etc/passwd | awk -F: '{print $4}')
if [ $(grep -c :${GID}: /etc/group) -eq 0 ]
then
echo ${USER} >> ${USERLIST}
fi
done
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2006 09:23 AM
11-15-2006 09:23 AM
Re: Anyone already have a script to do this?
the command 'pwck' - part of the OS - will be a help for you as well. Just check the man page!
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2006 09:29 AM
11-15-2006 09:29 AM
Re: Anyone already have a script to do this?
The 'pwck' and/or 'grpck' may not discern inter user-group file inconsistencies.
Hence, my simple Perl script.
Regards!
...JRF...