I had email this morning from someone using "chown" to fix
up permissions on a directory. He had discovered "-R" in
the man page but had run into a small problem.
Let's say the directory was /usr/fred. He had done:
chown -R fred:group *
He noted that had done pretty much what he wanted, but had ignored
the "dot" files: .profile, .login etc.
So to fix that, he did:
chown -R fred:group .*
That succesfully changed the ownership of the "dot" files, but had
an unexpected (to him) side effect: /usr was also changed.
Of course that would be true, because ".*" includes ".." and
the ".." of /usr/fred is /usr. A useful command flag seemed to be
difficult or impossible to use as desired.
Well, that's not the case. The "-R" is perfectly happy to do
the job if you invoke it like this:
chown -R fred:group .
See the difference? Just ".", meaning current directory. That
will correctly change all fles, including .login, .profile and
everything else, but it won't touch ".." and therefore leaves
In this case, the misuse was noticed immediately and fixed, but I
have often had panic calls from people where no one can login because
of making this same mistake.
Actually, there's a little more to this. How did /usr/fred get
the wrong ownership to start with? I looked more closely at the
email and saw that "rcp" had been used to copy files from
another system. It had been correctly invoked with "-p" and
"-r", so the permissions and ownership should have been preserved.
However: rcp can't create users. If, for example, "fred" doesn't
yet exist as a user on this new system, rcp can copy Fred's files
from aother system (assuming proper access) but can't magically
create files owned by Fred if "fred" doesn't exist here.
So the solution is to create all necessary users before using
rcp. That would have avoided all of this.
Technorati tags: Mac+OS+X
If this page was useful to you, please help others find it:
More Articles by Anthony Lawrence
- Find me on Google+
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Jump to Comments
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.