05-03-2006
The best way to do this is with PERL. Perl can walk a file system faster than anything else. Do something like this.
#!/opt/perl/bin/perl
use File::Find;
find \&wanted, "/";
sub wanted {
my $dev; # the file system device number
my $ino; # inode number
my $mode; # mode of file
my $nlink; # counts number of links to file
my $uid; # the ID of the file's owner
my $gid; # the group ID of the file's owner
my $rdev; # the device identifier
my $size; # file size in bytes
my $atime; # last access time
my $mtime; # last modification time
my $ctime; # last change of the mode
my $blksize; # block size of file
my $blocks; # number of blocks in a file
#Right below here your telling lstat to retrieve all this info on each and every file/directory. Each and every file/directory is w
ritten to $_.
(($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = lstat($_));
if ($gid <= "99" ) {
$NEWGID=$gid+99;
print "old $gid\n";
print "new $NEWGID\n";
system "chgrp $NEWGID $_;
}
}
I'm not sure if this is perfect but it should be pretty close.
-X
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Here is my situation. On a RedHat 7.3 box, I have a user named jody.
When I log in with jody and type in "id", I get the expected output:
uid=1(jody) gid=1(jody) groups=1(jody), 510(test)
However, I cannot figure which "id" option allows me to change the effective gid. I tried the options... (2 Replies)
Discussion started by: Jody
2 Replies
2. UNIX for Advanced & Expert Users
Hi everyone,
Need help with an issue. The group ownership of files on my Solaris system is getting changed automatically. Could someone tell me the reason why? And how could I correct it? One more info- everytime the ownership changes, it changes to "x".
Thanks :confused: (1 Reply)
Discussion started by: top_gun
1 Replies
3. Shell Programming and Scripting
Hello,
I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job.
linux1
linux2
linux3
linux4
linux5 ......
.
.
.
.
.
1.) How can i enter "password" in script rather asking me?
I was trying this...
ssh... (2 Replies)
Discussion started by: deal732
2 Replies
4. Solaris
Does any one know if changing root's group from “other” to “root” will cause any problems on a running system.
Thanks (4 Replies)
Discussion started by: mjkroner
4 Replies
5. UNIX for Dummies Questions & Answers
i am able to change the mode using chmod and able to change permission.
but i am not able to change group and ownership. getting as invalid
can any one help me regarding this . (4 Replies)
Discussion started by: satheeshkr_cse
4 Replies
6. UNIX for Dummies Questions & Answers
Hello,
I have a small problem and would be happy if someone could help me to find a solution:
A machine ("server") makes backups of different computers ("clients") using rsync. Users and groups are keept, so that it's possible to copy them back to the client if required. The number of groups... (3 Replies)
Discussion started by: tracer
3 Replies
7. Shell Programming and Scripting
/etc/group
tiadm::345:mk789,po312,jo343,ju454,ko453,yx879,iy345,hn453
bin::2:root,daemon
sys::3:root,bin,adm
adm::4:root,daemon
uucp::5:root
/etc/passwd
mk789:x:234:1::/export/home/dummy:/bin/sh
po312:x:234:1::/export/home/dummy:/bin/sh
ju454:x:234:1::/export/home/dummy:/bin/sh... (6 Replies)
Discussion started by: chidori
6 Replies
8. Shell Programming and Scripting
Hi scripting guru's
I found this script on IBM's website and it seems to be really good only thing it gives off more info than i need. I was wondering if someone could help me modify it to only find a group instead of every user. (group is support)
I believe i know how to add the line so it... (2 Replies)
Discussion started by: vpundit
2 Replies
9. Red Hat
I found that I cannot chgrp for some reason with error:
chgrp: changing group of `<file>': Invalid argument
This happens on all NFS mounted disks on client machines.
We use AD (not my call) for authentication and it also provides groups.
We have a NFS server running Scientific Linux 6.3... (1 Reply)
Discussion started by: venmx
1 Replies
LEARN ABOUT LINUX
groupadd
GROUPADD(8) System Management Commands GROUPADD(8)
NAME
groupadd - create a new group
SYNOPSIS
groupadd [options] group
DESCRIPTION
The groupadd command creates a new group account using the values specified on the command line plus the default values from the system.
The new group will be entered into the system files as needed.
OPTIONS
The options which apply to the groupadd command are:
-f, --force
This option causes the command to simply exit with success status if the specified group already exists. When used with -g, and the
specified GID already exists, another (unique) GID is chosen (i.e. -g is turned off).
-g, --gid GID
The numerical value of the group's ID. This value must be unique, unless the -o option is used. The value must be non-negative. The
default is to use the smallest ID value greater than 999 and greater than every other group. Values between 0 and 999 are typically
reserved for system accounts.
-h, --help
Display help message and exit.
-K, --key KEY=VALUE
Overrides /etc/login.defs defaults (GID_MIN, GID_MAX and others). Multiple -K options can be specified.
Example: -K GID_MIN=100 -K GID_MAX=499
Note: -K GID_MIN=10,GID_MAX=499 doesn't work yet.
-o, --non-unique
This option permits to add a group with a non-unique GID.
-p, --password PASSWORD
The encrypted password, as returned by crypt(3). The default is to disable the password.
Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes.
You should make sure the password respects the system's password policy.
-r, --system
Create a system group.
The numeric identifiers of new system groups are chosen in the SYS_GID_MIN-SYS_GID_MAX range, defined in login.defs, instead of
GID_MIN-GID_MAX.
CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool:
GID_MAX (number), GID_MIN (number)
Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.
MAX_MEMBERS_PER_GROUP (number)
Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name,
same password, and same GID).
The default value is 0, meaning that there are no limits in the number of members in a group.
This feature (split group) permits to limit the length of lines in the group file. This is useful to make sure that lines for NIS
groups are not larger than 1024 characters.
If you need to enforce such limit, you can use 25.
Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use this variable unless you really
need it.
SYS_GID_MAX (number), SYS_GID_MIN (number)
Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers.
FILES
/etc/group
Group account information.
/etc/gshadow
Secure group account information.
/etc/login.defs
Shadow password suite configuration.
CAVEATS
It is usually recommended to only use groupnames that begin with a lower case letter or an underscore, followed by lower case letters,
digits, underscores, or dashes. They can end with a dollar sign. In regular expression terms: [a-z_][a-z0-9_-]*[$]?
On Debian, the only constraints are that groupnames must neither start with a dash ('-') nor contain a colon (':') or a whitespace (space:'
', end of line: '
', tabulation: ' ', etc.).
Groupnames may only be up to 32 characters long.
You may not add a NIS or LDAP group. This must be performed on the corresponding server.
If the groupname already exists in an external group database such as NIS or LDAP, groupadd will deny the group creation request.
EXIT VALUES
The groupadd command exits with the following values:
0
success
2
invalid command syntax
3
invalid argument to option
4
GID not unique (when -o not used)
9
group name not unique
10
can't update group file
SEE ALSO
chfn(1), chsh(1), passwd(1), gpasswd(8), groupdel(8), groupmod(8), login.defs(5), useradd(8), userdel(8), usermod(8).
System Management Commands 06/24/2011 GROUPADD(8)