Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to add the Apache user (www-data) to the audio group. I've read the man page for useradd, but I'm not having any luck. I'm running xubuntu 11.10. Here's what I'm doing:

$ sudo useradd -G audio www-data
useradd: user 'www-data' already exists

If I leave out the -G option, bash, prints the help info for useradd:

$ sudo useradd  audio www-data
Usage: useradd [options] LOGIN
Options: -b, --base-dir BASE_DIR       base directory for the home directory...

It's not clear to me from the man page what options I should select to make this work.

share|improve this question
add comment

4 Answers

up vote 63 down vote accepted

The useradd command will not surprisingly try to add a new user. To modify an existing user, like adding that user to a new group, use the usermod command.

Try this:

sudo usermod -a -G audio www-data

The user will need to logout and log back in to see their new group added.

share|improve this answer
12  
sudo usermod -a -G [group-name] [user-name] : Just a quickie for those who only glance at the answer after reading the headline –  Programster Nov 11 '13 at 14:50
add comment

Adding a user to a group:

sudo adduser user group

Removing a user from a group:

sudo deluser user group
share|improve this answer
add comment

I normally use

sudo gpasswd -a myuser mygroup
share|improve this answer
add comment

After adding to a existing user:

usermod -a -G group user  

You may need to logout and login to get the groups permissions from /etc/group.

share|improve this answer
1  
Please make it the part "need to logout and login" bold. –  Jin Kwon Dec 17 '13 at 6:36
    
FYI: I think the id command should indicate you were added to the group without needing to exit. id myuser –  ficuscr Jan 3 at 16:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.