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:
cd /usr/fred
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:
cd /usr/fred
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:
cd /usr/fred
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 /usr alone.
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 usewr 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.
Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)
| Views for this page | ||||
|---|---|---|---|---|
| Today | This Week | This Month | This Year | Overall |
| 19 | 40 | 19 | 9,205 | 17,338 |
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
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.
Add your comments