LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 03-18-2007, 10:13 AM   #1
sdefor
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Rep: Reputation: 0
Question Chang GID numbers


Im looking to change GID numbers for certian groups.
My initial thought is to open /etc/group and change the number to what it needs to be. My concern might be for files that were created under the old group ID. Similar to changing a UID. Any thoughts on this?

The reason I am doing this, is because I am trying to make several servers that have the same UID's and GID's (same group names and user names).

But something tells me just editing /etc/group will do fine. The UID's however would be a little more involved (finding all files and modifiying them).

Thanks
SAm
 
Old 03-18-2007, 10:27 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You could use the -gid argument of the find command to locate files owned by a group. You can also use -exec to run the chgrp command on that file.
 
Old 03-18-2007, 10:52 AM   #3
sdefor
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for the reply!

So I could in effect do the following...
login as 'root'

For UID change use the command....

$usermod -u <newUID> <username> ## or modify /etc/passwd

Then to find files to modify to new UID use the command...

$find / -user <oldUID> -print -exec chown <newUID> {}\;

And for GID
modify /etc/group

Then to find files to modify to NEW GID if any use...

$find / -gid <oldGID> -print -exec chgrp <newGID> {}\;

Would the above look appropriate?

Thanks,
Sam
 
Old 03-18-2007, 05:20 PM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I wouldn't recommend starting at the root directory. You will waste a lot of time doing it that way. Searching for group owned files in /proc, /sys, /mnt or /dev isn't what you want to do. Excluding certain directories can make the command too complicated.

You could use a form like:
find /home /tmp /var /usr ...
instead to apply it on directories that you know have the group's files.

Also, use su or sudo instead, and log in as a normal user. It is a good habit to get into. (And enforced if you have Ubuntu)

Last edited by jschiwal; 03-18-2007 at 05:23 PM.
 
Old 03-18-2007, 07:07 PM   #5
sdefor
LQ Newbie
 
Registered: Mar 2007
Posts: 3

Original Poster
Rep: Reputation: 0
That's an excellent point, and some great advice. I will give it a shot on a few bogus users as well as groups and files. I forget sometimes that being logged in as root is not always the "wise" thing to do.

Thanks Again
sam
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sequence of numbers, how to extract which numbers are missing jonlake Programming 13 06-26-2006 03:28 AM
how to chang IceWM desktop background color? BRAHmS Linux - Software 1 02-14-2005 04:37 AM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 09:18 AM
Changing GID in X dxdad Linux - Software 2 03-22-2004 08:45 AM
chang ip zaraza Linux - Networking 4 10-23-2003 03:42 AM


All times are GMT -5. The time now is 10:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration