Skip to Content
Classic Shell Scripting
book

Classic Shell Scripting

by Arnold Robbins, Nelson H. F. Beebe
May 2005
Intermediate to advanced
560 pages
15h 18m
English
O'Reilly Media, Inc.
Content preview from Classic Shell Scripting

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 the find ... | 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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Complete Bash Shell Scripting

Complete Bash Shell Scripting

Narendra Kumar Reddy Polu

Publisher Resources

ISBN: 0596005954Errata Page