Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]chown -R behavior is strange
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
xiaweitang
Apprentice
Apprentice


Joined: 26 Feb 2010
Posts: 152

PostPosted: Sat Apr 10, 2010 6:52 pm    Post subject: [SOLVED]chown -R behavior is strange Reply with quote

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
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3224

PostPosted: Sat Apr 10, 2010 7:01 pm    Post subject: Re: chown -R behavior is strange Reply with quote

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
View user's profile Send private message
xiaweitang
Apprentice
Apprentice


Joined: 26 Feb 2010
Posts: 152

PostPosted: Sat Apr 10, 2010 8:15 pm    Post subject: Reply with quote

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
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