<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.2//EN">
<book id="users-and-groups">
  <bookinfo>
    <title>Users and Groups in the Debian System</title>
    <edition>0.2</edition>

    <authorgroup>
      <author>
	<firstname>Joey</firstname>
	<surname>Hess</surname>
	<email>joeyh@debian.org</email>
      </author>
      <author>
	<firstname>Colin</firstname>
	<surname>Watson</surname>
	<email>cjwatson@debian.org</email>
      </author>
      <author>
	<firstname>David</firstname>
	<surname>Mandelberg</surname>
	<email>mandelbergd@eth0.is-a-geek.org</email>
      </author>
    </authorgroup>

    <copyright>
      <year>2001</year>
      <year>2002</year>
      <holder>Joey Hess</holder>
    </copyright>

    <copyright>
      <year>2005</year>
      <holder>David Mandelberg</holder>
    </copyright>

    <copyright>
      <year>2001-2022</year>
      <holder>Colin Watson</holder>
    </copyright>

    <legalnotice>
      <para>
	This document is free; you can redistribute it and/or modify it
	under the terms of version 2 of the GNU General Public License as
	published by the Free Software Foundation.
      </para>

      <para>
	This document is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
	General Public License for more details.
      </para>

      <para>
	You should have received a copy of the GNU General Public License
	along with this document; if not, write to the Free Software
	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
	02110-1301, USA.
      </para>
    </legalnotice>
  </bookinfo>

  <chapter id="introduction">
    <title>Introduction</title>

    <para>
      The Debian base-passwd package contains the master versions of
      <filename>/etc/passwd</filename> and <filename>/etc/group</filename>.
      The <command>update-passwd</command> tool keeps the entries in these
      master files in sync on all Debian systems. They comprise only "global
      static" ids: that is, those which are reserved globally for the
      benefit of packages which need to include files owned by those users
      or groups, or need the ids compiled into binaries. Since this
      reservation is a serious restriction, these ids must be allocated by
      the base-passwd maintainer on request. In general, packages should
      avoid requesting such ids where possible and instead allocate system
      users or groups dynamically. See Debian Policy for further details.
    </para>

    <para>
      The Debian Policy Manual reserves ranges for these global static users
      and groups, but it makes no attempt to allocate individual numbers or
      define their purposes. This document fills that gap by describing the
      purposes of the individual entries in these master files.
    </para>

    <para>
      This is a work in progress. Items in need of feedback are marked with
      the "HELP" tag. Please send mail to
      <email>base-passwd@packages.debian.org</email> or file a bug with the
      Debian bug tracking system if you have more information.
    </para>
  </chapter>

  <chapter id="entries">
    <title>Users and Groups</title>

    <para>
      Many users have a corresponding group, and these pairs will be treated
      together.
    </para>

    <variablelist>
      <varlistentry>
	<term>root</term>
	<listitem>
	  <para>
	    Root is (typically) the superuser.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>daemon</term>
	<listitem>
	  <para>
	    Some unprivileged daemons that need to be able to write to some
	    files on disk run as daemon.daemon (<command>portmap</command>,
	    <command>atd</command>, <command>lambdamoo</command>,
	    <command>mon</command>, and others). Daemons that don't need to
	    own any files sometimes run as nobody.nogroup instead; it is
	    generally better practice to use a dedicated user, and more
	    complex or security-conscious daemons certainly do this. The
	    daemon user is also handy for locally installed daemons,
	    probably.
	  </para>
	  <para>
	    LSB 1.3 lists daemon as legacy, and says: "The 'daemon' UID/GID
	    was used as an unprivileged UID/GID for daemons to execute under
	    in order to limit their access to the system. Generally daemons
	    should now run under individual UID/GIDs in order to further
	    partition daemons from one another."
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>bin</term>
	<listitem>
	  <para>
	    HELP: No files on my system are owned by user or group bin. What
	    good are they? Historically they were probably the owners of
	    binaries in <filename>/bin</filename>? It is not mentioned in
	    the FHS, Debian Policy, or the changelogs of base-passwd or
	    base-files.
	  </para>
	  <para>
	    LSB 1.3 lists bin as legacy, and says: "The 'bin' UID/GID is
	    included for compatibility with legacy applications. New
	    applications should no longer use the 'bin' UID/GID."
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>sys</term>
	<listitem>
	  <para>
	    Historically, the sys user and group
	    <ulink url="http://article.olduse.net/109@Autzoo.UUCP">owned the
	    kernel sources and some related items like the include
	    files</ulink>, but this was obsoleted long ago in favour of bin
	    (now itself legacy; see above).
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>sync</term>
	<listitem>
	  <para>
	    The shell of user sync is <filename>/bin/sync</filename>. Thus,
	    if its password is set to something easy to guess (such as ""),
	    anyone can sync the system at the console even if they have no
	    account on the system.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>games</term>
	<listitem>
	  <para>
	    Many games are sgid to games so they can write their high score
	    files. This is explained in Debian Policy.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>man</term>
	<listitem>
	  <para>
	    The <command>man</command> program (sometimes) runs as user man,
	    so it can write cat pages to <filename>/var/cache/man</filename>
	    and update its databases there.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>lp</term>
	<listitem>
	  <para>
	    The <filename>lp*</filename> devices are writable by this group
	    so that users in it can access the parallel ports directly.
	    Traditionally this job is taken by a printer daemon instead
	    which will only need to run in this group.
	  </para>
	  <para>
	    The <command>lpr</command> system keeps its spool directories
	    owned by lp/lp. Its daemon and frontend tools (through setuid)
	    run as user root.
	  </para>
	  <para>
	    HELP: what do other print systems (<command>rlpr</command>,
	    <command>lprng</command>, ...) do?
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>mail</term>
	<listitem>
	  <para>
	    Mailboxes in <filename>/var/mail</filename> are owned and
	    writable by group mail, as is explained in Debian Policy. The
	    user and group is used for other purposes as well by various
	    MTAs and MUAs.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>news</term>
	<listitem>
	  <para>
	    Various news servers and other associated programs (such as
	    <command>suck</command>) use user and group news in various
	    ways. Files in the news spool are often owned by user and group
	    news. Programs such as <command>inews</command> that can be used
	    to post news are typically sgid news.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>uucp</term>
	<listitem>
	  <para>
	    The uucp user and group is used by the UUCP subsystem. It owns
	    spool and configuration files. Users in the uucp group may run
	    <command>uucico</command>.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>proxy</term>
	<listitem>
	  <para>
	    Like daemon, this user and group is used by some daemons
	    (specifically, proxy daemons) that don't have dedicated user ids
	    and that need to own files. For example, group proxy is used by
	    <command>pdnsd</command>, and <command>squid</command> runs as
	    user proxy.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>majordom</term>
	<listitem>
	  <para>
	    Majordomo has a statically allocated uid on Debian systems for
	    historical reasons. It is not installed on new systems.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>postgres</term>
	<listitem>
	  <para>
	    Postgresql databases are owned by this user and group.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>www-data</term>
	<listitem>
	  <para>
	    Some web servers run as www-data. Web content should
	    <emphasis>not</emphasis> be owned by this user, or a compromised
	    web server would be able to rewrite a web site. Data written out
	    by web servers will be owned by www-data.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>backup</term>
	<listitem>
	  <para>
	    Presumably so backup/restore responsibilities can be locally
	    delegated to someone without full root permissions?
	  </para>
	  <para>
	    HELP: Is that right? Amanda reportedly uses this, details?
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>operator</term>
	<listitem>
	  <para>
	    Historically, the operator user account was used by system
	    operators with low privilege to dump filesystem backups to tape,
	    and was in the root group so that it could do this. In Debian,
	    the use of a utility such as <command>sudo</command> to gain
	    privilege is preferred over such highly-special-purpose
	    accounts, and the operator user is no longer created by default.
	    It had uid 37.
	  </para>
	  <para>
	    The operator group is used by <command>dump -n</command> to
	    notify logged-in operators via <command>wall</command> when it
	    requires operator attention. This is a historical use, and new
	    applications should not behave this way. (If nothing else, the
	    group should be configurable.)
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>list</term>
	<listitem>
	  <para>
	    Mailing list archives and data are owned by this user and group.
	    Some mailing list programs may run as this user as well.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>irc</term>
	<listitem>
	  <para>
	    Used by IRC daemons. A statically allocated user is needed only
	    because of a bug in <command>ircd</command>: it
	    <function>setuid()</function>s itself to a compiled-in user id
	    on startup.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>gnats</term>
	<listitem>
	  <para>
	    Used by <command>gnats</command>.  This had a statically
	    allocated user and group for purely historical reasons (it could
	    equally well use a dynamic system user and group).  Since
	    <command>gnats</command> has been removed from Debian, this user
	    and group are no longer created by default; they had uid/gid 41.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>nobody, nogroup</term>
	<listitem>
	  <para>
	    Daemons that need not own any files sometimes run as user nobody
	    and group nogroup, although using a dedicated user is far
	    preferable. Thus, no files on a system should be owned by this
	    user or group.
	  </para>
	  <para>
	    (Technically speaking, it does no harm for a file to be owned by
	    group nogroup as long as the ownership confers no additional
	    privileges, that is if the group and other permission bits are
	    equal. However, this is sloppy practice and should be avoided.)
	  </para>
	  <para>
	    If root-squashing is in use over NFS, root access from the
	    client is performed as user nobody on the server.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>messagebus</term>
	<listitem>
	  <para>
	    The dbus daemon (<command>dbus-daemon-1</command>) runs as this
	    user and group.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>postfix</term>
	<listitem>
	  <para>
	    Used by the <command>postfix</command> MTA.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>gdm</term>
	<listitem>
	  <para>
	    GDM (GNOME Display Manager) runs as this user/group.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>saned</term>
	<listitem>
	  <para>
	    Added by sane-utils, but appear to be unused.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>klog</term>
	<listitem>
	  <para>
	    Used by <command>klogd</command>, the kernel logger.
	  <para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>syslog</term>
	<listitem>
	  <para>
	    Used by syslog, the general purpose logger.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>

    <para>
      Other groups have no associated user.
    </para>

    <variablelist>
      <varlistentry>
	<term>adm</term>
	<listitem>
	  <para>
	    Group adm is used for system monitoring tasks. Members of this
	    group can read many log files in <filename>/var/log</filename>,
	    and can use <command>xconsole</command>.
	  </para>
	  <para>
	    Historically, <filename>/var/log</filename> was
	    <filename>/usr/adm</filename> (and later
	    <filename>/var/adm</filename>), thus the name of the group.
	  </para>
	  <para>
	    HELP: Perhaps policy should state the purpose of this group so
	    users may be safely added to it, in certainty that all they'll
	    be able to do is read logs. Wouldn't hurt to rename it 'log'
	    either ...
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>tty</term>
	<listitem>
	  <para>
	    Tty devices and <filename>/dev/vcs*</filename> are owned by this
	    group. This is used by <command>write</command> and
	    <command>wall</command> to enable them to write to other
	    people's ttys.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>disk</term>
	<listitem>
	  <para>
	    Raw access to disks. Mostly equivalent to root access.
	  </para>
	  <para>
	    HELP: Well, I have some disk devices in
	    <filename>/dev</filename> owned by the group, but I can't see
	    the point. On another system, I noticed that some of the files
	    <command>lilo</command> puts in <filename>/boot</filename> are
	    also owned by disk. I can imagine local uses for such a group,
	    like if you want to give some users in the group direct access
	    to some hard disk. But these uses I've found on my systems seem
	    to preclude doing that easily; if I put a user in group disk
	    here, they'd have write access to the root filesystem.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>kmem</term>
	<listitem>
	  <para>
	    <filename>/dev/kmem</filename> and similar files are readable by
	    this group. This is mostly a BSD relic, but any programs that
	    need direct read access to the system's memory can thus be made
	    setgid kmem.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>dialout</term>
	<listitem>
	  <para>
	    Full and direct access to serial ports. Members of this group
	    can reconfigure the modem, dial anywhere, etc.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>dip</term>
	<listitem>
	  <para>
	    The group's name stands for "Dialup IP". Being in group dip
	    allows you to use tools such as <command>pppd</command>,
	    <command>pon</command>, and <command>poff</command> to make
	    dialup connections to other systems using predefined
	    configuration file(s) in the <filename>/etc/ppp/peers</filename>
	    directory.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>fax</term>
	<listitem>
	  <para>
	    Allows members to use fax software to send or receive faxes.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>voice</term>
	<listitem>
	  <para>
	    Voicemail, useful for systems that use modems as answering
	    machines.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>cdrom</term>
	<listitem>
	  <para>
	    This group can be used locally to give a set of users access to
	    a CD-ROM drive.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>floppy</term>
	<listitem>
	  <para>
	    This group can be used locally to give a set of users access to
	    a floppy drive.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>tape</term>
	<listitem>
	  <para>
	    This group can be used locally to give a set of users access to
	    a tape drive.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>sudo</term>
	<listitem>
	  <para>
	    Members of this group may run any command as any user when using
	    <command>sudo</command> or <command>pkexec</command> (from the
	    policykit-1 package, independently of whether the sudo package
	    is installed).
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>audio</term>
	<listitem>
	  <para>
	    This group can be used locally to give a set of users access to
	    an audio device.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>src</term>
	<listitem>
	  <para>
	    This group owns source code, including files in
	    <filename>/usr/src</filename>. It can be used locally to give a
	    user the ability to manage system source code.
	  </para>
	  <para>
	    HELP: <filename>/usr/src</filename> is owned by group src and is
	    setgid. This doesn't make files put there by foo-src packages
	    necessarily be owned by group src though. If the intent is to
	    make group src be able to manage source code, perhaps policy
	    should say that foo-src packages make files in
	    <filename>/usr/src</filename> owned and writable by the group
	    (and files in tarballs dropped there likewise)?
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>shadow</term>
	<listitem>
	  <para>
	    <filename>/etc/shadow</filename> is readable by this group. Some
	    programs that need to be able to access the file are setgid
	    shadow.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>utmp</term>
	<listitem>
	  <para>
	    This group can write to <filename>/run/utmp</filename>,
	    <filename>/var/log/wtmp</filename>,
	    <filename>/var/log/lastlog</filename>, and similar files.
	    Programs that need to be able to write to them (such as X
	    terminal emulators) are setgid utmp.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>video</term>
	<listitem>
	  <para>
	    This group can be used locally to give a set of users access to
	    a video device.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>plugdev</term>
	<listitem>
	  <para>
	    Members of this group can access removable devices in limited
	    ways without explicit configuration in
	    <filename>/etc/fstab</filename>. This is useful for local users
	    who expect to be able to insert and use CDs, USB drives, and so
	    on.
	  </para>
	  <para>
	    Since <command>pmount</command> (the original implementor of
	    group plugdev) always mounts with the nodev and nosuid options
	    and applies other checks, this group is not intended to be
	    root-equivalent in the ways that the ability to mount
	    filesystems might ordinarily allow. Implementors of semantics
	    involving this group should be careful not to allow
	    root-equivalence.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>staff</term>
	<listitem>
	  <para>
	    Allows users to add local modifications to the system
	    (<filename>/usr/local</filename>, <filename>/home</filename>)
	    without needing root privileges. Compare with group 'adm', which
	    is more related to monitoring/security.
	  </para>
	  <para>
	    Note that the ability to modify <filename>/usr/local</filename>
	    is effectively equivalent to root access (since
	    <filename>/usr/local</filename> is intentionally on search paths
	    ahead of <filename>/usr</filename>), and so you should only add
	    trusted users to this group. Be careful in environments using
	    NFS since acquiring another non-root user's privileges is often
	    easier in such environments.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>users</term>
	<listitem>
	  <para>
	    While Debian systems use the user-group system by default (each
	    user has their own group), some prefer to use a more traditional
	    group system. In that system, each user is a member of the
	    'users' group.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>lpadmin</term>
	<listitem>
	  <para>
	    Allows a user to add, modify, and remove printers from foomatic,
	    cups, and possibly other printer databases.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>sasl</term>
	<listitem>
	  <para>
	    Users in this group have read/write access to
	    <filename>/etc/sasldb</filename> and/or
	    <filename>/etc/sasldb2</filename>, wich are used to
	    authentication with sasl. This is commonly used by IMAP, POP,
	    and SMTP servers for authentication.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>scanner</term>
	<listitem>
	  <para>
	    Users in this group can use scanner(s).
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>_ssh</term>
	<listitem>
	  <para>
	    <command>ssh-agent</command> is setgid to _ssh in order to
	    prevent ptrace attacks.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
        <term>libvirt</term>
        <listitem>
          <para>
            Access to the system libvirt daemon is controlled by this
            group.  Membership in this group gives full daemon access
            including (but not restricted to) managing virtual machines.
          </para>
        </listitem>
      </varlistentry>
    </variablelist>

    <para>
      Some users have no corresponding group.
    </para>
    
    <variablelist>
      <varlistentry>
	<term>sshd</term>
	<listitem>
	  <para>
	    Unprivileged user used by the privilege-separated
	    <command>sshd</command> when communicating with the network
	    before successful authentication.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>fetchmail</term>
	<listitem>
	  <para>
	    Used by the <command>fetchmail</command> program.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>cupsys</term>
	<listitem>
	  <para>
	    <acronym>CUPS</acronym> (Common Un*x Printing System) runs as
	    this user. It is in group lp, so it can access printer devices. 
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </chapter>
</book>

<!-- vi: sts=2 sw=2 tw=76
-->
