≡ Menu

Ubuntu Linux: Add a User To Group www-data ( Apache Group )

How do I a user to the Apache group called www-data under Ubuntu or Debian Linux server operating systems?

You need to use the useradd command to add a user to the group called www-data.

Add a new user to the www-data group

In this example, add a new user called vivek to the www-data group, enter:

sudo useradd -g www-data vivek
### set the password for vivek user ###
sudo passwd vivek

To verify new settings, enter:

id vivek
groups vivek

The group name www-data is the user’s initial login group i.e. vivek has been added to www-data primary group only.

www-data supplementary groups membership

To add a new user called vivek to supplementary groups called www-data and ftp, enter:

sudo groupadd vivek
sudo useradd -g vivek -G www-data,ftp vivek
sudo passwd vivek

To verify new settings, enter:

id vivek
groups vivek

Add a existing user to www-data group

Type the following command to add an existing user called vgite to the www-data group, enter:

sudo usermod -a -G www-data  vgite
id vgite
groups vgite

Above command will add the user vgite to the supplementary group called www-data. Use -a option only with the -G option.

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 7 comments… add one }
  • msound June 23, 2014, 2:46 pm

    When adding an existing user to www-data group, you might have to logout and login for the new group privileges to take effect.

    • Melroy April 26, 2015, 8:18 pm

      Thats a good tip >< Is there no command for that?

    • samizdam October 2, 2015, 1:28 pm

      Yes… I’m spent some time with chmod / chown manipulation, before understand it =)

  • baljit kumar October 9, 2014, 11:19 am

    it’s working i try

  • Barry Docherty May 24, 2016, 3:44 am

    Rubbish… complete and utter rubbish.
    to add a user to www-data group with Ubuntu at least that is:

    sudo adduser ‘NameOfUserYouWantAdded’ www-data

    and done!

  • fagner July 19, 2016, 7:42 pm

    not exist “ftp” group

    • AndreaEM September 14, 2016, 7:12 am

      Maybe It’s cause you don’t have/don’t need an ftp group (eg. you don’t have an ftp service installed or misconfigured)

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , ,