Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to change permissions for a group of directories and ...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 8:42 pm    Post subject: How to change permissions for a group of directories and ... Reply with quote

I moved all the files from my old computer on to my new one running Gentoo but I'm not recognized as the owner of my files. So far I have been right clicking, choosing Properties and giving myself Write permission so I can use them. That's getting to be a lot of work though - way too many directories and subdirectories of files to change like that.

Is there a way using chmod, or something else from the command line to give myself read, write and execute permission on all files in my user directory? For example how can I do this with myself as user trisha so that I can do whatever I need to with all files in /home/trisha/?

Thanks
Back to top
View user's profile Send private message
papal_authority
Veteran
Veteran


Joined: 31 Mar 2004
Posts: 1823
Location: Canada

PostPosted: Tue Sep 14, 2004 8:50 pm    Post subject: Reply with quote

Something like
Code:
chown -R trisha /home/trisha
should work :D
_________________
The free market gave me gonorrhea.
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 9:36 pm    Post subject: Reply with quote

Thanks - can I su to root to do it or do I have to be actually logged in as root?

Also, someone else had told me to do:

chown -R trisha:users /home/trisha

But it didn't work. I did that with su.

And what is the difference between the two? What did the 'users' part try to do that didn't work, or was it that I wasn't really logged in as root?
Back to top
View user's profile Send private message
fleed
l33t
l33t


Joined: 28 Aug 2002
Posts: 756
Location: London

PostPosted: Tue Sep 14, 2004 9:51 pm    Post subject: Reply with quote

You don't need to be logged in as root, su is fine. The part after the : is telling chown what group to use, and users should be fine. What error message did you get?
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 9:58 pm    Post subject: Reply with quote

I don't get an error - it just doesn't work. Both with

chown -R trisha:users /home/trisha
and
chown -R trisha /home/trisha

I do it, then go and check some files and directories, and I still don't have write access.
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Tue Sep 14, 2004 10:17 pm    Post subject: Reply with quote

I'd do both chown and chmod just in case.

chown -R trisha: /home/trisha
# that : after trisha pulls the proper group and saves you some typing.

chmod -R 755 /home/trisha
# this might be much more than you want. For instance your .ssh/ dir shouldn't be 755 so you may just want to do the dirs separately.

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
groovin
Guru
Guru


Joined: 07 Feb 2004
Posts: 429
Location: California, USA

PostPosted: Tue Sep 14, 2004 10:27 pm    Post subject: Reply with quote

owning a file doesnt always mean you have write access to it. chmod like kashani suggested.

you should do

man chmod

and read up on permissions. man pages are boring, but usually educational =)
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 10:38 pm    Post subject: Reply with quote

Quote:
owning a file doesnt always mean you have write access to it. chmod like kashani suggested.


Write permission was one of the main things I wanted, since I am not able to edit existing files without it.

Also, I was just even trying to move entire directories (with many subdirectories) to a different location and I get a message saying I don't have permission to do that.

I've done chmod before, but just on servers to change permissions on certain files for web sites. I can't imagine having to go through and do each directory and subdirectory separate though - I have way too many.

Is there any danger in just doing chmod -R 755 /home/trisha, so I would have write permission on all files?
Back to top
View user's profile Send private message
papal_authority
Veteran
Veteran


Joined: 31 Mar 2004
Posts: 1823
Location: Canada

PostPosted: Tue Sep 14, 2004 10:45 pm    Post subject: Reply with quote

Trisha wrote:
Is there any danger in just doing chmod -R 755 /home/trisha, so I would have write permission on all files?

Not really any danger with a user's home directory, but I'd still do each directory seperately as kashani suggested. Looks like you may owe him a spinach pizza :P
_________________
The free market gave me gonorrhea.
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Tue Sep 14, 2004 10:57 pm    Post subject: Reply with quote

It's good to know papal authority really is infallible. :)

Seriously you probably won't break anything, but if you use ssh keys those will break since 755 permissions are a bit much. You might try

chmod -R +w /home/trisha
That should add write access for you the owner to each file without affecting anything else. That should be less intrusive.

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 10:59 pm    Post subject: Reply with quote

If I tried to do every directory separately it might take hours, which was what I was trying to avoid to begin with.

What would be the purpose of doing it that way?

I don't get the pizza thing - but I have had spinach on pizza although I don't normally like vegetables on pizza, but I've had spinach and mushroom pizza before and I liked it. Damn it! Now you've make me hungry!! :)
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 11:04 pm    Post subject: Reply with quote

I don't know what ssh keys are, so I doubt that I use them. What are they for anyway in case I might be using them?

The only thing I know about ssh is that my hosting company doesn't allow telnet access anymore, so for certain things, if I want to use them I would need to install putty for ssh access.
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 11:07 pm    Post subject: Reply with quote

Ok, I saw kashani's sig line now, so I get the pizza thing - and I'm still hungry!

So chmod -R +w /home/trisha will only add write access, but not change the read or execute permissions from what they are now?
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Tue Sep 14, 2004 11:12 pm    Post subject: Reply with quote

Starting over here, first you need to make sure you're the owner of all the files.

chown -R trisha: /home/trisha

This can be run without causing any problems. The -R is for recursive so all files, sub folders etc get owned to you. Obviously you'll need to do that as root since you're changing ownership.

chmod -R +w /home/trisha

This should be fine as well as I just did some simple tests to make sure. Again the -R is recursive and does all the files and sub folders.

Lots of people will say read the man pages, but I would recommend "Unix for the Impatient" as a better place to start depending on how much you wnat to get into Linux. It's probably $40-50, but really covers the basics well of getting around your *nix box from the command line.

The pizza thing was a bit of a joke. I was living in California and really missed stuffed spinach pizzas and I was also getting a number of AIM and privates messages for help from the Gentoo forums. Since I normally fix friends computers for "pizza and beer" I figured it was only fair that the rest of the people should have to play along. One nice fellow who I spent a few hours with working on his mail server did actually send me two pizzas which was pretty darn nice.

Since I moved back to Chicago in June I'll have to think of something else for people to send me. Maybe sushi. :)

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
Monkeywrench
Apprentice
Apprentice


Joined: 22 Jun 2004
Posts: 205
Location: Florida

PostPosted: Tue Sep 14, 2004 11:20 pm    Post subject: Reply with quote

755? What an ugly hack. I would feel horribly icky if everything in my home dir was 755...

Kashani: your command would set write permissions for all users.

try this instead:

Quote:
chmod -R u+rw /home/trisha


The command adds read and write permissions only for the owner for every file in /home/trisha... which is way more secure than blindly applying 755 to every single file.

Be paranoid! 8)
_________________
Folding@home -Join the Linux team (163)!
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 11:34 pm    Post subject: Reply with quote

kashani - I did the chown part already, so I should be ok with that. I'll try the chmod part in a little while here.

I asked a while back in another forum here for book suggestions on Gentoo or linux. As far as I can tell, there are no Gentoo books yet. So you recommend "Unix for the Impatient"? I might try it. Man pages are generally written way over my head. I don't expect to be an expert on linux/unix, I just need to learn what I need. Not that I don't like learning - I have my hands full right now with learning. I'm just a web developer/designer who got tired of Windows and was determined to switch to linux to avoid it. So I have to learn what I can along the way and still get my regular work done.

Chicago huh? I'm originally from Southern Illinois, in St. Louis now. I bet when you're not drinking beer with your pizza, you drink 'pop' with it! ;)
Back to top
View user's profile Send private message
Trisha
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2004
Posts: 97

PostPosted: Tue Sep 14, 2004 11:39 pm    Post subject: Reply with quote

Monkeywrench - right now I'm the only user on this computer, and most likely always will be so that may not be an issue.

Would chmod -R u+rw /home/trisha take away execute permission from files that already have it?
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Wed Sep 15, 2004 12:25 am    Post subject: Reply with quote

Nope and you can test to make sure.

touch test.txt
chmod 777 test.txt
ls -la test.txt
chmod -w test.txt
ls -la test.txt

at this point you should see that the user can not write to the file any more. The u specificies user permissions which is also the default. So u+w is the same as +w.

chmod +w test.txt
now things are back to normal.

chmod +w test.txt
no change so you're good.

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
Monkeywrench
Apprentice
Apprentice


Joined: 22 Jun 2004
Posts: 205
Location: Florida

PostPosted: Wed Sep 15, 2004 5:18 am    Post subject: Reply with quote

Trisha wrote:
Monkeywrench - right now I'm the only user on this computer, and most likely always will be so that may not be an issue.

Would chmod -R u+rw /home/trisha take away execute permission from files that already have it?

Well, it's just good practice in general. I don't plan on crashing into a tree with a car soon, but I still wear seat belts.

And no, the command I supplied doesn't take any permissions away. Here's a quick breakdown of what I gave you:
chmod ----the command
R ----this just makes it so the command applies to all files in a directory and subdirectories, and the files in the subdirectories (and so on)
u ----this means only for the owner of the file, which is you. if this was 'g', then the command would apply to the group that owns the file, which is the 'users' group. if it was 'o', it would apply to all other users.
+ ----this means only add permissions. if it was a '-', it would have taken away read and write permissiosn.
rw ----this means read and write. adding 'x' would have added execute permission. execute permission is required for programs and scripts and such. execute permission is also required for directories so you can access them.

Does that make sense?
_________________
Folding@home -Join the Linux team (163)!
Back to top
View user's profile Send private message
groovin
Guru
Guru


Joined: 07 Feb 2004
Posts: 429
Location: California, USA

PostPosted: Wed Sep 15, 2004 3:49 pm    Post subject: Reply with quote

fixing comps for beer and pizza? thats a great idea!! if i had beer and pizza for every computer ive fixed, damn, i would weigh 400lbs and never have to buy myself dinner!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security 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