View previous topic :: View next topic |
Author |
Message |
xiaweitang Apprentice
Joined: 26 Feb 2010 Posts: 152
|
Posted: Sat Apr 10, 2010 6:52 pm Post subject: [SOLVED]chown -R behavior is strange |
|
|
Suppose I have three dirs in /home: user1, user2 and user3, and I want to change the ownership of user1 and all its contents to user1:users.
Code: | cd /home
chown user1:users user1
cd user1
chown -R user1:users ./*
chown -R user1:users ./*.*
chown -R user1:users ./.* |
After those steps, I found not only the contents of user1 have the ownership user1:users, but the directories user2 and user3 ant all of their contents also have the ownership of user1:users. It seems chown -R operates outside the present working directory. Also, is there a way to combine the last three lines of my commands?
Last edited by xiaweitang on Sat Apr 10, 2010 8:15 pm; edited 1 time in total |
|
Back to top |
|
|
mikegpitt Advocate
Joined: 22 May 2004 Posts: 3224
|
Posted: Sat Apr 10, 2010 7:01 pm Post subject: Re: chown -R behavior is strange |
|
|
xiaweitang wrote: | Suppose I have three dirs in /home: user1, user2 and user3, and I want to change the ownership of user1 and all its contents to user1:users.
Code: | cd /home
chown user1:users user1
cd user1
chown -R user1:users ./*
chown -R user1:users ./*.*
chown -R user1:users ./.* |
After those steps, I found not only the contents of user1 have the ownership user1:users, but the directories user2 and user3 ant all of their contents also have the ownership of user1:users. It seems chown -R operates outside the present working directory. Also, is there a way to combine the last three lines of my commands? | The problem is that you are including the directory under the current working directory in your commands with the .* and the *.* chown calls. This will include .. and start traveling outside user1/.
Instead try this:
Code: | cd user1
chown -R user1:users . |
...or just this in your parent dir:
Code: | chown -R user1:users user1/ |
|
|
Back to top |
|
|
xiaweitang Apprentice
Joined: 26 Feb 2010 Posts: 152
|
Posted: Sat Apr 10, 2010 8:15 pm Post subject: |
|
|
Thanks. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|