LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-23-2004, 06:45 AM   #1
k2merlinsix
Member
 
Registered: Dec 2004
Location: West Virginia
Distribution: Fedora
Posts: 35

Rep: Reputation: 15
How can I find and change UIDs


Background:
2 NIS systems
2 seperate /etc/passwd files
Same users
Different UID's

I want to sync the two systems up together but in doing so I must go through and change every file so that it has the UID for each person that that file belongs too. Any clues other then manually of how I can do this? And how do I get it to recursively go through and do the same thing for the dot files.

Thanks,
 
Old 12-23-2004, 07:09 AM   #2
SlackerLX
Senior Member
 
Registered: Dec 2004
Location: Herzliyya, Israel
Distribution: SuSE 10.1; Testing Distros
Posts: 1,832

Rep: Reputation: 47
Keep in mind that root is always 1000
So, your next newly created user is 1001
and so on, next user you create will be 1002
 
Old 12-27-2004, 07:13 AM   #3
k2merlinsix
Member
 
Registered: Dec 2004
Location: West Virginia
Distribution: Fedora
Posts: 35

Original Poster
Rep: Reputation: 15
Maybe I should re-phrase this.

I have 2 different NIS domains that have two different /etc/passwd files and have the same user names but different UID's
Example

/etc/passwd for NIS 1
aweikle:x:502:100:Aaron Weikle:/home/aweikle:/bin/bash

/etc/passwd for NIS 2
aweikle:x:12345:100:Aaron Weikle:/home/aweikle:/bin/bash

I want both NIS systems to have the same /etc/passwd file. If I make both of them look like /etc/passwd for NIS 1 then the aweikle will lose permissions for his home directory and all the contents on the NIS 2 because It would be looking for UID 12345 but instead would be returning 502. Also all files on any system with in the NIS 2 domain aweikle will lose permissions to those as well. Once I change the /etc/passwd file the owner no longer becomes aweikle the owner will be 12345.

My question is how can you recursively find all files with owner 12345 and replace the owner with aweikle or 502 through out any single system on NIS 2 domain so that the permissions are restored to the true owner of that file or files?
 
Old 12-28-2004, 07:22 AM   #4
k2merlinsix
Member
 
Registered: Dec 2004
Location: West Virginia
Distribution: Fedora
Posts: 35

Original Poster
Rep: Reputation: 15
?
 
Old 12-28-2004, 11:36 AM   #5
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
OK, so what you want to do is "recursively find all files with owner 12345 and replace the owner with aweikle or 502 through out any single system on NIS 2 domain".

Linux has the tools to help you do this, and although I do not know the answer exactly, I can point you in the right direction:

There are many threads in LQ answering things like "how do I delete all the .html files in all my directories? The solution is a command featuring find and rm and (as I recall) exec and curly brackets. No doubt if I read ALL about bash, I'd be able to give you a one-liner. But if you do a search on these forums, you'll get the idea.

Note that find . -uid 12345 will find all files from the current directory downwards, whose User ID is 12345.
chown acting on the results of your find . -iud 12345 will let you reset the ownerships to what you want.

You'll probably have to run this command as root - so test it out carefully before you execute it!

Hope this helps.
 
Old 12-28-2004, 03:15 PM   #6
mmoser63
LQ Newbie
 
Registered: Dec 2004
Distribution: slackware
Posts: 3

Rep: Reputation: 0
tredegar is on the right track.

find . -uid 12345 -exec chown 54321 {} \;

will do what you want throught the entire filesystem

Beware of
1) the order of the changes (if you change uid 11to 22 and then uid 22 to 45, you'll accidentally give uid 45 ownership of both sets of files)
2) external filesystems (mounted NFS or SAMBA shares on other servers)
3) group ids
 
  


Reply



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
SIDs and UIDs and RIDs! Oh My! (SAMBA) calabash Linux - Networking 0 08-10-2005 07:18 PM
two users with uids of 0 shanenin Linux - Security 2 03-04-2005 09:57 AM
Multiple UIDS at the same time ? SiLiCoN Linux - General 3 12-17-2004 04:20 AM
samba - map winbind users to nis uids and gids bkurnik Linux - Networking 0 09-20-2004 06:47 AM
Help with UIDs please :) gponto18 Linux - Newbie 5 10-22-2002 02:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:14 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration