1

I personally usually use Debian based systems but I ask the following question on the entire *nix family of operating systems.

Is the www-data user usually using as the Apache/Nginx already comes with some *nix systems or is it usually created by a given software, i.e Apache/Nginx?

If it already comes with some systems (Debian in my case) it will prevent me for creating it for software different than Apache/Nginx before I install Apache/Nginx that might create it themselves, thus saving myself from some possible conflict.

BTW, I was thinking using it for Ansible with become: yes.

2 Answers 2

7

Since you’re using Ansible, you should specify that you want a www-data user to be present, using the user module with state=present and whatever other attributes are appropriate (e.g. system=yes). That will create the user if necessary, and won’t if one is already present. That’s a general principle of configuration management — describe the situation you want the system to be in, not the steps to get there.

On Debian, and presumably most derivatives, the www-data user is always present, it’s not created by a specific package for its own purposes (it’s “created” by base-passwd, along with all the other entries in the default /etc/passwd). I don’t know off-hand about other systems.

1
  • Nice list of users that some I should get to know more personally and nice tips. Thanks. Commented Dec 9, 2018 at 22:31
2

On Red Hat distributions and derivatives, typically the package installer has a "create user" command inside the pre-install script. So, on CentOS 7, via the rpm -q --scripts httpd we can see

preinstall scriptlet (using /bin/sh): # Add the "apache" group and user /usr/sbin/groupadd -g 48 -r apache 2> /dev/null || : /usr/sbin/useradd -c "Apache" -u 48 -g apache \ -s /sbin/nologin -r -d /usr/share/httpd apache 2> /dev/null || : 

This tells us a number of things:

  • On Red Hat and derivatives the user is called apache
  • It also tries to create a group called apache
  • It wants the userid and groupid to be 48
  • But if the user or group already exist then it continues with the install.

You must log in to answer this question.