Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this command:

chown root:www-data /var/www/example.com -R 

but I get an error message that the directory is not listed.

What is wrong?

share|improve this question
What exact error message do you get? – Stéphane Chazelas May 5 '13 at 13:15

You have to put the -R option in front.

chown -R root:www-data /var/www/example.com 

(I always use a dot instead of a colon between user and group, but the man pages says the colon should be used).

share|improve this answer
Er, I don't know why you think you can't use a colon: sprunge.us/aDJW – Chris Down May 5 '13 at 8:55
Dot was the old way and colon the new. Guess someone thought it'd be nice to be able to use dots in user-names/groups. – Runium May 5 '13 at 9:05
@Sukminder I guess that 'old way' identifies me. I am glad that dot is still allowed as it is difficult to change typing habits after using the command this way for close to 30 years – Anthon May 5 '13 at 9:09
@Sukminder At one point Anthon said in his answer that colons were not allowed, which is not true. I wasn't trying to suggest that using a dot is "wrong" in some way, just that a colon is perfectly valid. – Chris Down May 5 '13 at 9:24
GNU tools allow options after arguments (which IMO is a bug) unless the POSIXLY_CORRECT environment variable is set (or -- is used to mark the end of options). AFAIK, Ubuntu does not set that option in the default environment, so I doubt this be the issue. Anyway I agree one should put the options in front. – Stéphane Chazelas May 5 '13 at 13:18

The GNU coreutils version of chown, which is standard under Ubuntu, accept options placed anywhere, (as long as -- is not used). That is:

chown foo:bar some/location -R
chown -R foo:bar some/location

both work. This is because of how getopt_long() works. In my book this is a bug – as it should either result in error, or be documented, which from what I can find it is not.

chown foo:bar some/location -- -R

would look for directory named -R.

However if one set environment variable POSIXLY_CORRECT the first example would fail if there is no directory named -R, and would never recurse.

$ chown -v :foo a/ -R
ownership of `a/' retained as foo:foo
chown: cannot access `-R': No such file or directory

IMHO: always try to conform to the POSIX way as one day you enter that command on another system where a POSIX is enforced, thus breaking.

Also note that the value of POSIXLY_CORRECT has no effect. This would not disable it:

export POSIXLY_CORRECT=false

One would need to unset it.

It could be your system is set up with either another chown tool or POSIXLY_CORRECT is set.

Check by:

export | grep POSIX
chown --version
# etc.

As a side note, the use of dot, ., to separate group and user was obsoleted as of POSIX 2001 (info coreutils 'chown invocation'), but still supported for backwards compatibility, though it is not recommended.

share|improve this answer

Your Answer


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.