Such a problem, I have on VDS CMS Joomla and when I put something through it, then the owner becomes apache , in the end, when I try to change something via ftp I fail to do it. I have to go through the ISP panel and change the rights there.

I read that I need to add my user to the www-data group, but I don’t know how to do this, but I haven’t yet found any information in Google about this. Help me to understand.

My username is testuser

But the path to the folder with my site /var/www/testuser/data/www/mysite.ru

I have a Centos operating system, ssh access too.

By ssh, I wanted to do this:

Add my user to the group with this command - sudo adduser testuser www-data

After chown testuser:www-data -R /var/www/testuser/data/www/mysite.ru

And lastly - chmod -R 775 /var/www/testuser/data/www/mysite.ru

But all this I could not do, because of the wrong commands.

Friends, tell me what am I doing wrong? Help me to understand.

    2 answers 2

    Add my user to the group with this command

     sudo adduser testuser www-data 

    In the redhat-main distribution, this syntax does not "pass". because /usr/sbin/adduser is just a symbolic link to /usr/sbin/useradd , and the useradd program is not intended to add a user to a group.

    this syntax “will pass” in debian-main distributions, where /usr/sbin/adduser is a perl-script , about which it is written in man adduser :

    adduser and addgroup are groupedd and usermod programs.

    my free translation:

    adduser and addgroup are wrappers around useradd , groupadd and usermod low-level tools.


    i.e., to add a user to a group, you will have to use the low-level usermod tool, which it can do:

     $ sudo usermod -a -G группа пользователь 

    Where:

    • -a - add the user to the additional group (s). only used with the -G option
    • -G группы - a list of additional groups (if more than one group is specified, the separator is a comma)

    for details, see using man usermod on your system.


    You can view current group membership, for example, using the groups program:

     $ groups root root : root bin daemon sys adm disk wheel 

      To add a user to a group, it seems that not useradd (this command adds a new user), but usermod :

       sudo usermod -aG www-data testuser 
      • And -aG is that? - Anatoly
      • man usermod is an option to add a user to the specified groups, without deleting others. - Flowneee
      • Will it be the right teams? sudo usermod -aG www-data testuser chown testuser:www-data -R /var/www/testuser/data/www/mysite.ru chmod -R 775 /var/www/testuser/data/www/mysite.ru - Anatoly
      • @Anatoly Well it looks like it, but it's better to explain what you meant by Но все это мне не удалось сделать, из за неправильных команд. That is, the console swore at something or what? - Flowneee
      • When sudo adduser did testuser www-data, a table appeared with hints. - Anatoly