> When doing a chown -R user:user .* --- (dot star)
> the chown recurses up the tree as well as down.
Yes.
> Is this the intended action or is this a problem on
> RedHat 6.1
This is the intended action because '*' matches '.' in filenames. If
you want to avoid matching '.' (you do) then you need to use a
different match patern.
chown -R user:user .[!.]*
That command uses a modern extension to shell file name globbing in
which [!.] means anything not a dot. This matches all dot files. If
there are not .files then '.[!.]*' fails to expand.
[The time honored traditional method which you might see which
predates this is to use '?' which does not match '.' in file names.
You might see '.??*' in older scripts. This matches all two letter or
longer filenames that start with a dot. It misses all single letter
file names which start with a dot. But this is the original best way
to do this and is seen in many old scripts so I will include it for
edification purposes.]
To understand why -R is recursing down the directories you need to
understand that .* matched . and .. in the directory. Therefore you
pattern expanded to include . and .. in addition to any .files there.
Therefore the -R traversed down it.
To see this directly check your pattern using the echo command.
mkdir /tmp/foo
cd /tmp/foo
touch foo .foo
echo chown -R user:user .*
chown -R user:user . .. .foo
echo chown -R user:user .[!.]*
chown -R user:user .foo
Remember too that if there are no dot files at all in the directory
that the globbing will fail to expand. In that case the shell leaves
it in just as listed. In that case you would probably get an error
message "chown: .[!.]*: No such file or directory" from the command.
rm .foo
echo chown -R user:user .[!.]*
chown -R user:user .[!.]*
Bob