Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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?
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!
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.