chown: invalid user: ‘www–data:www-data’

51,224

Solution 1

Looking at what I assume is a copy paste:

chown -R www–data:www-data /somefolder

It should be noted that the hyphen in the user name is not a hyphen, but ASCII 150, or an en dash. This can be verified if you copy paste the string into a tool such as http://www.asciivalue.com/. You'll see the first dash is ASCII 150, while the second is ASCII 45. ASCII 45 is the standard hyphen that is expected.

Fix that, and you should be fine.

Solution 2

If you are used to using a Debian/Ubuntu distribution and you change to a CentOS/Red Hat distribution, you may be experiencing problems because the correct user is "apache" on CentOS/Red Hat. The string becomes:

chown -R apache:apache /somefolder

Solution 3

what you can also check, is the ID of the user and then run it like

chown -R 999:999 /somefolder

this works almost each time

Share:
51,224

Related videos on Youtube

Orlo
Author by

Orlo

Updated on September 18, 2022

Comments

  • Orlo
    Orlo over 1 year

    I'm experiencing strage problem. I simple need to give permissions www-data to a folder

    chown -R www–data:www-data /somefolder
    chown: invalid user: ‘www–data:www-data’
    
    grep www-data /etc/passwd
    www-data:x:33:33:www-data:/var/www:/bin/sh
    

    other folders generated by apache:

    drwxr-xr-x 2 www-data www-data 16384 Jan 12 00:30 11
    drwxr-xr-x 2 www-data www-data  8192 Jan 13 01:01 12
    drwxr-xr-x 2 www-data www-data  8192 Jan 14 00:30 13
    
    • VL-80
      VL-80 over 10 years
      Check if this and this will help.
    • VL-80
      VL-80 over 10 years
      What happens if you try to issue command without group? chown -R www–data /somefolder
    • Nullpointer42
      Nullpointer42 over 10 years
      does the user exist in /etc/shadow as well?
    • davidgo
      davidgo over 10 years
      Weird, should work. What happens if you use chown www-data.www-data /somefolder ? (ie . rather then :)
    • Orlo
      Orlo over 10 years
      @Nikolay chown: invalid user: ‘www–data’
    • Orlo
      Orlo over 10 years
      @ernie yes, it's there as well.
    • VL-80
      VL-80 over 10 years
      I see. Very interesting... What if you try to use UID instead of username? chown -R 33:33 /somefolder ?
  • PsychoData
    PsychoData over 10 years
    This is what I was going to point out. try using - instead of the and it might fix your problem altogether
  • VL-80
    VL-80 over 10 years
    +1. Brilliant. Difference can be seen even visually. You are very observant.
  • code-8
    code-8 over 8 years
    Keep getting chown: invalid user: ‘www-data:www-data’ still
  • G-Man Says 'Reinstate Monica'
    G-Man Says 'Reinstate Monica' almost 4 years
    “I need to pound a nail into the wall, and I can’t find my hammer.”  /  “Well, just use a glass bottle instead — or maybe an old shoe.”  You seem to be suggesting an answer that is superficially similar to what the question is asking for, but that won’t really do the job.  If your directory is accessible to the www-data user after you chown it to nobody, it must be accessible to everybody.
  • Saeed Salam
    Saeed Salam almost 3 years
    this worked for me on Fedora 34. thanks!
  • Sami
    Sami over 2 years
    waoo... so the problem is - only. rewrite it.