The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Special Forums > Hardware > Filesystems, Disks and Memory
.
google unix.com



Filesystems, Disks and Memory Discuss NAS, SAN, RAID, Robotic Libraries, backup devices, RAM, DRAM, SCSI, IDE, EIDE topics here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Monkcast #12: IBM HW group OEMs Solaris to chagrin of SW group & a ... - ZDNet.com bl iBot UNIX and Linux RSS News 0 08-17-2007 05:30 PM
Changing userID and Changing group and GID deal732 Shell Programming and Scripting 2 04-18-2007 11:09 AM
File group ownership changing automatically top_gun UNIX for Advanced & Expert Users 1 12-09-2005 03:37 PM
entry in /etc/group too long - problem using sudo with %group poli SUN Solaris 4 12-21-2004 09:50 AM
Changing the Effective Group ID Jody UNIX for Dummies Questions & Answers 2 12-05-2002 03:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-03-2006
frankkahle frankkahle is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 88
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 (permalink)  
Old 05-03-2006
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
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 (permalink)  
Old 05-03-2006
x96riley3 x96riley3 is offline
Registered User
  
 

Join Date: Mar 2006
Location: Nashville
Posts: 79
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 (permalink)  
Old 05-03-2006
frankkahle frankkahle is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 88
Smile 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 (permalink)  
Old 05-19-2006
frankkahle frankkahle is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 88
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0