Validating ownership against /etc/passwd and /etc/group
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Validating ownership against /etc/passwd and /etc/group
Looking for ideas for how to validate ownerships against /etc/passwd and /etc/group.
I had to rebuild a server and then restore selected files from backups. All went well.
Except I noticed the /etc/passwd and /etc/group files no longer match the other similar servers or the same files from backups. Makes some sense because the rebuild was performed with a more recent ISO of the system.
For example:
Old /etc/passwd:
sshd:x:105:65534::/var/run/sshd:/usr/sbin/nologin
New /etc/passwd:
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
Because of the selective backups, I want to validate that the ownerships of all restored files match the newer /etc/passwd|group files. I could restore those same files from backups, but I don't know what will break.
I am not noticing anything in the logs, but I would be more comfortable with some kind of validation.
Hmm. I'm feeling a bit dense and am not followwing you.
You set up new server, user sshd is UID 106, was UID 105 in backup data.
Change UID to 105 in /etc/passwd on the new server to match the backup data.
Repeat for all non-matching UIDs on new server.
My focus though is discovering whether there are any files/directories created from within the new install that are using the new UIDs/GIDs. I suppose I could run 'find / -user $NewUID', 'find / -group $NewGID', etc. That way I would know what files/directories are affected before restoring the old UIDs/GIDs.
Perhaps also the reverse -- using the old UIDs/GIDs. Then there is discovering any files/directories that are not using the installed or backed up UIDs/GIDs. I was hoping for some kind of automated method, but I can manually run one command at a time. Time consuming but doable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.