Find the answer to your Linux question:
Results 1 to 6 of 6
I would like to change the ownership of some all folders and files within them folders by making changes to parentfolder. But I mess it up. The folder path is ...
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    93

    How to CHOWN all folders within a folder?

    I would like to change the ownership of some all folders and files within them folders by making changes to parentfolder. But I mess it up.

    The folder path is /home/myaccount/shared/target_folder.

    Target folder holds several new folders with files inside. How can I easily change ownership to all folders and files within target_folder?

    I tried this:

    Code:
    sudo chown myusername /home/myusername/shared/target_folder
    But I get error:
    Unnable to resolve. No such file or directory.
    Sure there are something wrong with my input .
    Last edited by piergen; 02-09-2011 at 01:24 PM.

  2. #2
    Super Moderator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,144
    Try the man pages. The answer is there.
    Code:
    man chown
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

  3. #3
    Just Joined!
    Join Date
    Jan 2011
    Posts
    93
    Btw I have corrected the code in post #1, I had forgotten to put in chown.

    Hmm tried man shown but couldnt make anything out of it, cause that seems just what I allready tried and could not get to work, except the <-hR> part. At least I should be able to get parent folder owner to change by using the line I did earlier.

    The example said this:

    chown -hR root /u
    Change the owner of /u and subfiles to "root

  4. #4
    Just Joined!
    Join Date
    Nov 2010
    Posts
    61
    yes you need to use the "-R" switch on the parent folder. The -R switch (recursive) applies the permissions to all files and sub directories inside the parent folder.

  5. #5
    Just Joined!
    Join Date
    Jan 2011
    Posts
    93
    Tks. What means recursive? Little language barrier here.
    Seems like most of the commands are rather natural so to learn and make the commands stick best for me to understand the linux-meaning of recursive.

    Btw. If I at later time add a new folder with files from elsewhere on pc into "target_folder" which I have made myself owner of, will those new folder with files also have me as owner or do I have to make sure I do a new chown command every time?

  6. #6
    Just Joined!
    Join Date
    Nov 2010
    Posts
    61
    Quote Originally Posted by piergen View Post
    Tks. What means recursive? Little language barrier here.
    Seems like most of the commands are rather natural so to learn and make the commands stick best for me to understand the linux-meaning of recursive.
    Recusrive mean that it will not only apply to the named folder but all sub-folders and files within it.

    Its a common switch and can be used in many differnt commands like the command
    Code:
    rm -Rf folder1
    will remove the folder "folder1" and all files and subfolder inside it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...