- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: chown -r me:group .* misunderstanding effects
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2005 04:57 AM
11-01-2005 04:57 AM
In order to correct this as root I executed
$ cd /usr/users
$ chown me:mygroup mydir
$ cd /usr/users/mydir
$ chown -R me:mygroup *
The result was all files in and below $HOME received me:mygroup ownership. Excellent!
This left the ownership of the hidden files/dirs in $HOME unchanged. In $HOME I then executed
chown -R me:mygroup .*
Lo and behold, the command traveled up a level to /usr/users and then down through ALL /usr/users, making me:mygroup the owner. My career passed in front of my eyes.
Please help me understand the chown syntax or file specification wildcard mis-understanding/ignorance I am operating under.
I have searched ITRC with no relevant references found. If there is a relevant article please provide a pointer. Thanks for your help.
Joe S.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2005 05:55 AM
11-01-2005 05:55 AM
Re: chown -r me:group .* misunderstanding effects
There is a way using the ? symbol but have not researched enough. the manual method may take longer but I do feel safer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2005 06:02 AM
11-01-2005 06:02 AM
Solutionthis .* is not chown syntax but shell special pattern.
look at results of command:
1. echo .*
. ..
this means your command was interpreted by shell as:
chown -R me:mygroup . ..
when you want to change permisions or owner to .* files and directores you should use syntax:
chown -R me:mygroup .??*
where ? - Matches any single character.
Don't use single ? because:
echo .? -> means ..
But in your example the best/easiest solution to change owner of all files and dirs was:
cd /usr/users
chown -R me:mygroup mydir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2005 06:05 AM
11-01-2005 06:05 AM
Re: chown -r me:group .* misunderstanding effects
if you use ".*" you also select the directory ".." which is the parent directory. The option -r will now change all right in all selected directory, even in the parent directory and all subfolders of the parent directory.
To avoid this i always use ".??*" and handle all dot-files matching ".?" manually.
HeL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2005 06:22 AM
11-01-2005 06:22 AM
Re: chown -r me:group .* misunderstanding effects
I had better know how the shell special characters are interpreted. The suggestions of .??* and correct directory spec are very useful. Thnx again.
Joe S.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2005 08:43 PM
11-01-2005 08:43 PM
Re: chown -r me:group .* misunderstanding effects
Other pattern matching that will work:
chown -R me:mygroup .[A-z]*
will catch any file or directory beginning with . followed by any letter.
You could extend this to include numbers and other characters.
Or:
chown -R me:mygroup .[!.]*
which will match any file or directory beginning with a . and followed by any character, but *NOT* a second . (i.e. "dot-not-dot-but-anything-else")
Regards,
Andy Bruce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2005 08:47 PM
11-01-2005 08:47 PM
Re: chown -r me:group .* misunderstanding effects
for more information, have a look in the man page for the shell you are using (e.g. man bash) and look for the explanation of pattern matching.
Indeed, if you do a "man bash" and search for:
Pattern Matching
The second occurrence is the section you want to read up on!
Regards,
Andy Bruce
ps if you're dishing out points, don't give me double as I meant to put this bit in with my first respone! ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 02:46 AM
11-03-2005 02:46 AM
Re: chown -r me:group .* misunderstanding effects
you could have done it with
chown -R me:mygroup /usr/users/mydir
This would have included all . files as well.
chown -R .* is very dangerous as said.
I wrecked a production system twice. :-(
I was new into Unix and I tried to set the owner of the .* files.
Luckily the sysadmin did have a few open windows at all times so he could repair it.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 03:23 AM
11-03-2005 03:23 AM
Re: chown -r me:group .* misunderstanding effects
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 03:24 AM
11-03-2005 03:24 AM
Re: chown -r me:group .* misunderstanding effects
Joe S.