Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

How to change permissions for a group of directories and ...

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
20 posts • Page 1 of 1
Author
Message
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

How to change permissions for a group of directories and ...

  • Quote

Post by Trisha » Tue Sep 14, 2004 8:42 pm

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
Top
papal_authority
Veteran
Veteran
User avatar
Posts: 1823
Joined: Wed Mar 31, 2004 4:07 am
Location: Canada

  • Quote

Post by papal_authority » Tue Sep 14, 2004 8:50 pm

Something like

Code: Select all

chown -R trisha /home/trisha
should work :D
The free market gave me gonorrhea.
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 9:36 pm

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?
Top
fleed
l33t
l33t
User avatar
Posts: 756
Joined: Wed Aug 28, 2002 8:32 am
Location: London

  • Quote

Post by fleed » Tue Sep 14, 2004 9:51 pm

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?
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 9:58 pm

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.
Top
kashani
Advocate
Advocate
User avatar
Posts: 2030
Joined: Mon Sep 02, 2002 6:38 am
Location: San Francisco
Contact:
Contact kashani
Website

  • Quote

Post by kashani » Tue Sep 14, 2004 10:17 pm

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.
Top
groovin
Guru
Guru
User avatar
Posts: 429
Joined: Sat Feb 07, 2004 8:16 pm
Location: California, USA

  • Quote

Post by groovin » Tue Sep 14, 2004 10:27 pm

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 =)
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 10:38 pm

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?
Top
papal_authority
Veteran
Veteran
User avatar
Posts: 1823
Joined: Wed Mar 31, 2004 4:07 am
Location: Canada

  • Quote

Post by papal_authority » Tue Sep 14, 2004 10:45 pm

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.
Top
kashani
Advocate
Advocate
User avatar
Posts: 2030
Joined: Mon Sep 02, 2002 6:38 am
Location: San Francisco
Contact:
Contact kashani
Website

  • Quote

Post by kashani » Tue Sep 14, 2004 10:57 pm

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.
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 10:59 pm

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!! :)
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 11:04 pm

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.
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 11:07 pm

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?
Top
kashani
Advocate
Advocate
User avatar
Posts: 2030
Joined: Mon Sep 02, 2002 6:38 am
Location: San Francisco
Contact:
Contact kashani
Website

  • Quote

Post by kashani » Tue Sep 14, 2004 11:12 pm

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.
Top
Monkeywrench
Apprentice
Apprentice
User avatar
Posts: 205
Joined: Tue Jun 22, 2004 3:50 am
Location: Florida

  • Quote

Post by Monkeywrench » Tue Sep 14, 2004 11:20 pm

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:
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)!
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 11:34 pm

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! ;)
Top
Trisha
Tux's lil' helper
Tux's lil' helper
Posts: 97
Joined: Wed Mar 31, 2004 11:51 pm

  • Quote

Post by Trisha » Tue Sep 14, 2004 11:39 pm

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?
Top
kashani
Advocate
Advocate
User avatar
Posts: 2030
Joined: Mon Sep 02, 2002 6:38 am
Location: San Francisco
Contact:
Contact kashani
Website

  • Quote

Post by kashani » Wed Sep 15, 2004 12:25 am

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.
Top
Monkeywrench
Apprentice
Apprentice
User avatar
Posts: 205
Joined: Tue Jun 22, 2004 3:50 am
Location: Florida

  • Quote

Post by Monkeywrench » Wed Sep 15, 2004 5:18 am

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)!
Top
groovin
Guru
Guru
User avatar
Posts: 429
Joined: Sat Feb 07, 2004 8:16 pm
Location: California, USA

  • Quote

Post by groovin » Wed Sep 15, 2004 3:49 pm

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!
Top
Post Reply

20 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic