LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   change ownership of folder & its contents (https://www.linuxquestions.org/questions/linux-newbie-8/change-ownership-of-folder-and-its-contents-568401/)

roadrash 07-11-2007 08:05 AM

change ownership of folder & its contents
 
I have been using linux for about a year now but recently did a new install. I opened a file manager as root and backed up all my important files and things like the hidden .mozilla & .thunderbird and such like folders so as i could keep my mail and news settings and accounts as well.
The only trouble is when i copy any folders into my my installation every folder & file has its ownership changed to root. This I'm sure is what is causing me a lot of permissions problems with these folders & files. It is a massive task to change all the ownerships of the files by selecting all the files in each folder and right clicking them to apply new ownership especially as right clicking the folder and applying new ownership doesn't change it on the files within the folder.

how do I change the ownership of say the entire home directory and the files contained within its folders without having to deal with it one folder at a time.

pplude92 07-11-2007 08:11 AM

login as root, and use the console to navigate to the folder just above the one you want to change ownership for. Then use the following command:

Code:

chown <username> <folder path>
As far as I remember this applies to the files in the folder also.

lord-fu 07-11-2007 08:15 AM

In order to change permissions on all files within the directory it should have the -R switch.

Code:

chown -R user:group folder
Hope it helps some.

[edit] -R means recursive.
man chown

Reveals alot of information.

pplude92 07-11-2007 08:16 AM

thanks, I may need that myself later on!

roadrash 07-11-2007 09:29 AM

So to make things easier if was in the home directory and typed
"chown -R user:group my-homefolder" would that set the permisions for everything in my home-folder and all the subfolders within and their files?

lord-fu 07-11-2007 09:33 AM

Yes, that would change ownership on all files. example

Code:

#cd /home
#chown -R me:wheel me


roadrash 07-11-2007 10:00 AM

Sorry to be stupid but how do i find what group i am in?

custangro 07-11-2007 10:07 AM

you can type the groups command:

Code:

groups
That will tell you what groups you belong to.

If you want to find out your primary group you use the id command

Code:

id


All times are GMT -5. The time now is 07:10 PM.