Maybe i'm getting old but should . and .. not be ignored by any command ? AFAIK these are there because of the filesystem and serve no other purpose.
That would make no sense, simply because you specifically fed the names .
and ..
to chown by your chown <...> .*
. In such an instance, why should chown
think that you didn't do what you wanted to do?
The names were fed to chown because the shell expanded them based on the shell glob expansion criteria you gave it, which matched both .
and ..
along with every other dot-directory in the current directory. Since you told chown
to work recursively, it descended into those directories and anything below them. This means it "descended into" ..
and then kept working from there.
You can try this out yourself by doing echo .*
to see the names that were fed into chown's command line. Compare that to the output of echo *
with shopt dotglob
on and off respectively (shopt -s dotglob
to turn on, shopt -u dotglob
to turn off). Use ls
rather than echo
to see the first level of recursion.
There are perfectly valid reasons for running even a chown -R
on either .
or ..
. The most obvious seems to be to extract an archive that has incorrect ownership information on files and all files within a single directory; in such a case, chown -R abc:xyz .
from within the uncompressed directory is a perfectly reasonable thing to do, to reset ownership to something reasonable on your system.
If you want your shell to not expand .*
into .
and ..
then you need to make sure that it is set up correctly for your particular shell. For example, quoting from the GNU bash 4.2.37(1)-release (current on Debian Wheezy at the time of this writing, Debian bash
package version 4.2+dfsg-0.1+deb7u3
on amd64 architecture) man page:
GLOBIGNORE
A colon-separated list of patterns defining the set of file names to be ignored by pathname expansion. If a filename matched by a pathname expansion pattern also matches one of the patterns in GLOBIGNORE, it is removed from the list of matches.
Remember that part of the Unix philosophy is "trust that the user knows what they are doing".