changing group ID


 
Thread Tools Search this Thread
Special Forums Hardware Filesystems, Disks and Memory changing group ID
# 1  
Old 05-03-2006
changing group ID

My current GID are all < 100, however I am having issues now with this. Does anyone know of a way to change all GID's to perhaps add 100, IE so GID now = 23 will = 123. I am running an NIS network so changing the table is easy , however finding all the files on all my filesystems and modifying them is what i need to find if there is an easy way to do this.....

Frank
# 2  
Old 05-03-2006
Check the man page for the find command - there should be an option for finding files that belong to a certain group:

Example: find /some-starting-directory -group 23 -exec chgrp 123 {} \;
# 3  
Old 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
# 4  
Old 05-03-2006
Bug assumptions

I am assuming that this 'walks' the directory from that point forward or does something else have to be done.

Frank

P.S. Thanks very much BTW
# 5  
Old 05-19-2006
Thanks for the help

Except for a missing " everything worked just fine. I am running the scripts (i modified the / to . so as to walk from the curent directory forward. But it works beautifully, thanks again.

Frank
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Can't chgrp. Error - chgrp: changing group of `<file>': Invalid argument

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

2. Shell Programming and Scripting

perl :Changing script to only find the group

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

3. Shell Programming and Scripting

need a one liner to grep a group info from /etc/group and use that result to search passwd file

/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

4. UNIX for Dummies Questions & Answers

Changing rights without touching user and group?

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

5. UNIX for Dummies Questions & Answers

regarding changing ownership and group

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. Solaris

Changing root group to group from other

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

7. Shell Programming and Scripting

Changing userID and Changing group and GID

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

8. UNIX for Advanced & Expert Users

File group ownership changing automatically

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

9. UNIX for Dummies Questions & Answers

Changing the Effective Group ID

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
Login or Register to Ask a Question