chown: invalid user: ‘www–data:www-data’
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
Related videos on Youtube
Orlo
Updated on September 18, 2022Comments
-
Orlo over 1 year
I'm experiencing strage problem. I simple need to give permissions
www-data
to a folderchown -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 over 10 years
-
VL-80 over 10 yearsWhat happens if you try to issue command without group?
chown -R www–data /somefolder
-
Nullpointer42 over 10 yearsdoes the user exist in /etc/shadow as well?
-
davidgo over 10 yearsWeird, should work. What happens if you use chown www-data.www-data /somefolder ? (ie . rather then :)
-
Orlo over 10 years@Nikolay chown: invalid user: ‘www–data’
-
Orlo over 10 years@ernie yes, it's there as well.
-
VL-80 over 10 yearsI see. Very interesting... What if you try to use UID instead of username?
chown -R 33:33 /somefolder
?
-
-
PsychoData over 10 yearsThis is what I was going to point out. try using
-
instead of the–
and it might fix your problem altogether -
VL-80 over 10 years+1. Brilliant. Difference can be seen even visually. You are very observant.
-
code-8 over 8 yearsKeep getting
chown: invalid user: ‘www-data:www-data’
still -
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 tonobody
, it must be accessible to everybody. -
Saeed Salam almost 3 yearsthis worked for me on Fedora 34. thanks!
-
Sami over 2 yearswaoo... so the problem is
-
only. rewrite it.