Find the answer to your Linux question:
Results 1 to 9 of 9
Hi, I'm going to be honest - I'm not very experienced. My question isn't about how to solve a problem. But I need someone to explain to me, in a ...
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    4

    [SOLVED] Using "chown -r"

    Hi, I'm going to be honest - I'm not very experienced. My question isn't about how to solve a problem.
    But I need someone to explain to me, in a way a real person can understand, how to use the "-r" operative of the command "chown". Everything just says it's recursive, but my math class never covered that in enough detail.
    I'd prefer a patient and non-aggressive response, please. I'd just like answers.
    Thanks!

  2. #2
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,114
    To the best of my knowledge, if you apply the command
    to a directory, it will apply to all of its contents, including
    other directories and all their contents comprehensively.

  3. #3
    Just Joined!
    Join Date
    Jun 2009
    Posts
    4
    Quote Originally Posted by rcgreen View Post
    To the best of my knowledge, if you apply the command
    to a directory, it will apply to all of its contents, including
    other directories and all their contents comprehensively.
    Then why not just apply 'chown' straight to the directory? Won't that give the same effect?

  4. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    chown without the recursive flag will only apply to the item you are applying it to, any contents below that will retain their original ownership, with the recursive flag however, every item beyond the item you apply it to will gain the new ownership, including directories and their sub directories and files

  5. #5
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    Assume the following directory structure

    Code:
    /parent/
        /dir1/
            file 1
            file 2
        /dir2/
            file 1
        file 1
        file 2
    running chown in /parent will affect /dir1/ (but not the files in it) /dir 2/ (but not the files) in it and the files in /parent/

    running chown -R in /parent will affect everything under parent including their contents and so on down the tree
    Last edited by MikeTbob; 06-17-2009 at 08:27 PM. Reason: Corrected command Syntax
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  6. #6
    Just Joined!
    Join Date
    Jun 2009
    Posts
    4
    Oh, I get it now.
    Thanks a bunch, guys.

  7. #7
    Linux User saivin's Avatar
    Join Date
    Dec 2008
    Location
    Bengaluru, India
    Posts
    305
    Btw, its 'chown -R' not 'chown -r'.
    A candle looses nothing by lighting other candles. - Khalil Zibran.
    Registered Linux User #490076

  8. #8
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    Quote Originally Posted by saivin View Post
    Btw, its 'chown -R' not 'chown -r'.
    Quite right. Can't edit my post though
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  9. #9
    Super Moderator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,144
    Quote Originally Posted by elija View Post
    Quite right. Can't edit my post though
    Wow, it magically fixed itself!
    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.

Posting Permissions

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