9

When installing a new system, depending on selected packages, some uids for some packages aren't always the same.

eg: 'sshd' may be UID 102, sometimes another value. On the other hand, 'www-data' is always '33'

How can I figure out all packages with reserved UIDs (ie www-data) and all the packages that generate a pseudo-random administration UID (<1000, ie: sshd)? This goes for GIDs too.

Is there a list of all those packages? Or is there an aptitude command that let's me find out all those packages, even the ones not installed?

Thanks

BlakBat
  • 193
  • 1
  • 6

1 Answers1

9

The UIDs and GIDs 0-99 are fixed and always the same. They are created by the package base-passwd.

The 100-999 are dynamically allocated, usually in the order the users/groups are created on your system.

See the section "UID and GID classes" in the Debian/Ubuntu Policy Manual for some more classes.

As far as I know there is no list of packages that create users or groups.

Packages create the additional users and groups in their *.preinst and *.postinst scripts. So to find the installed packages that have created users

grep 'adduser ' /var/lib/dpkg/info/*inst

may be a starting point (replace adduser with addgroup for groups).

Adam Katz
  • 714
  • 8
  • 16
Florian Diesch
  • 86,013
  • 17
  • 224
  • 214
  • The Ubuntu Policy Manual is apparently no longer a thing; it was [out of date](https://askubuntu.com/q/57259/260416 "Is the Ubuntu policy manual out of date?") for a long while, then it was removed in mid-2019 ([here is the last archive](https://web.archive.org/web/20190414232944/https://people.canonical.com/~cjwatson/ubuntu-policy/policy.html/ch-opersys.html)). I believe this fully inherits from its [Debian Policy Manual](https://www.debian.org/doc/debian-policy) – see [§ 9.2.2: UID and GID classes](https://www.debian.org/doc/debian-policy/ch-opersys.html#uid-and-gid-classes). – Adam Katz Apr 23 '22 at 16:43