Other Real-World Issues
There are some other issues that are likely to come up in the Real World. For the sake of brevity we wimp out, and instead of writing code, we simply discuss them here.
First, and most obvious, is that the /etc/group
file is also likely to need
merging. With this file, it's necessary to:
Make sure that all the groups from each individual system exist in the merged
/etc/group
file, and with the same unique GID. This is completely analogous to the username/UID issue we just solved, only the format of the file is different.Do a logical merge of users in the same group on the different systems. For example:
floppy:x:5:tolstoy,camus In u1 /etc/group floppy:x:5:george,betsy In u2 /etc/group
When the files are merged, the entry for group
floppy
needs to be:
floppy:x:5:tolstoy,camus,george,betsy Order of users doesn't matter
The GID of all files must be brought into sync with the new, merged
/etc/group
file, just as was done with the UID. If you're clever, it's possible to generate thefind
...| xargs chown
... command to include the UID and GID so that they need to be run only once. This saves machine processing time at the expense of additional programming time.
Second, any large system that has been in use for some time will
have files with UID or GID values that no longer (or never did) exist in
/etc/passwd
and /etc/group
. It is possible to find such files
with:
find / '(' -nouser -o -nogroup ')' -ls
This produces a list of files in an output format similar to that of ...
Get Classic Shell Scripting now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.