6

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?

3 Answers 3

9

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.

1
  • 1
    Voted up for describing different distributions. It gets even more complicated when we start to look at different OS's (Solaris, *BSD, etc etc). It is very much platform specific. Commented Sep 20, 2018 at 2:03
0

Linux from scratch has you create this file your self. I would assume that distros start with a base file and then add users and services you choose at install time on the fly. It appears the only rule they want you to follow is root has uid and gid 0, and bin has 1. It appears as everything else is arbitrary.

1
0

In the case of embedded systems its created in buildroot/mkimage etc.

In custom/small distros the admin creates it.

On some desktop/server distributions its created with a package like 'filesystem' on Arch Linux or 'setup' on Fedora.

On Ubuntu or Debian its part of a pre-install script. The base-passwd package provides a update-passwd utility.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .