I got into a lot of trouble when changing the permission of a folder myfolder
residing in /
.
I issued the command
sudo chown -R luca:luca /myfolder/.*
My intention was to change ownership of all the hidden files in /myfolder
.
Unfortunately I realized that also the ownership of /
was changed, which of course left me with a broken system. I think this happened because ..
matches .*
, but still seems weird to me.
Is changing the parent directory the correct behaviour or should I file a bug report?
If it was my mistake in using chown, what are the best practices to use to prevent changing the ownership of system folders and files?
..
matches.*
.*
means any file that ends with.
*.
means any file that starts with.
/
directly (creating folders, removing, etc) unless utterly necessary (open a question for what you wanted to achieve). Also is dangerous using wildcards+root privileges because, more often than not, you are not 100% sure what is been affected by the wildcard.chmod
andchown
are similar commands, both start withch
, contains ano
and have two other similar letters (n
andm
). </literal> Seriously, they are both of the form:[cmd] -R [mode or user] [one or more files]
. Some solutions offered on that question work for your case too, for instance this one from Sean Reifschneider (in the middle). This answer is also applicable to hidden files only by removing the glob pattern for non-hidden files.