Ubuntu – How is the /etc/passwd file instantiated

passwdUbuntu

This is a weird question, but it strikes me as question a fish might ask about water.

How is the /etc/passwd file created? Initially.

Where I am coming from is this

  • I'm a Linux sysadmin and have been for years
  • I'm using Ubuntu but this could probably be asked of any distro
  • I found that the /etc/passwd file is not actually owned by any packages

So, for example this

# dpkg -S /etc/passwd
dpkg-query: no path found matching pattern /etc/passwd

and this

# dpkg -L passwd | grep '/etc/passwd'

(no results)

That package has all the tools to work with /etc/passwd. Just, not the file itself.

Is there an operation during installation from the installation media that creates this file?

Or is it just a boilerplate file buried in the installation media?

Or something else?

Best Answer

For Ubuntu and Debian the base-passwd package deploys not a packaged file, which is why running dpkg -L doesn't work, but generates the file from the pre-install script /var/lib/dpkg/info/base-passwd.preinst

For my RHEL and CentOS the equivalent rpm -qf /etc/passwd does show a package "owning" that file, the setup RPM package.

Related Question