Results 1 to 10 of 10

Thread: Change files / folders permission

  1. #1
    Join Date
    May 2012
    Beans
    309

    Change files / folders permission

    Hello everybody,

    I would like to change files persmission to 644 and folders to 755 at once, structure is like this:

    Code:
    +Folder1
    ++ SubFolder1
    +++ File1
    +++ File2
    +++ File3
    ++ SubFolder2
    ++ SubFolder3
    
    + Folder2
    Etc
    how can I do that at once.

    Thanks in advance

  2. #2
    Join Date
    Apr 2012
    Beans
    5,909

    Re: Change files / folders permission

    You can use

    Code:
    find Folder1 -type d -exec chmod 755 {} +
    find Folder1 -type f -exec chmod 644 {} +
    or maybe just

    Code:
    chmod -R u=rwX,go=rX Folder1

  3. #3
    Join Date
    May 2012
    Beans
    309

    Re: Change files / folders permission

    Thx, but in this case I should go folder by folder if I have 20 folders from 1 to 20, I should do it 20 times

  4. #4
    Join Date
    Apr 2012
    Beans
    5,909

    Re: Change files / folders permission

    No both methods act recursively (from Folder1 down to all files / folders below)

  5. #5
    Join Date
    May 2012
    Beans
    309

    Re: Change files / folders permission

    yes, I agree with you, but this will take effect for Folder1 and subFolders (down of Folder1), will not take in action Folder2, Folder3 etc

  6. #6
    Join Date
    Apr 2012
    Beans
    5,909

    Re: Change files / folders permission

    Apologies, I didn't notice that requirement

    It depends what else is in the parent directory of Folder1 and Folder2 - if you want to change EVERY folder you could use a * shell glob (wildcard)

    Code:
    chmod -R u=rwX,go=rX */
    in the parent directory. Or if all the folders you want to change have some identifying element in their name (e.g. if they really are called 'Folder1', 'Folder2' etc.) then you could do

    Code:
    chmod -R u=rwX,go=rX Folder*/
    I don't think it's possible to come up with a general rule that works 100% of the time if we don't know what other files/folders you have in the same directory.

  7. #7
    Join Date
    May 2012
    Beans
    309

    Re: Change files / folders permission

    and how about files?

  8. #8
    Join Date
    May 2012
    Beans
    309

    Re: Change files / folders permission

    I used this for folders and it works, how about files permission, to be set on 644:

    Folders:
    [code]

    chmod -R u=rwX,go=rX */
    [code]

  9. #9
    Join Date
    Apr 2012
    Beans
    5,909

    Re: Change files / folders permission

    Code:
    chmod -R u=rwX,go=rX */
    matches all directories ('*/') in the current directory, then recursively changes all directories and files below that - the only files it will exclude are those at the top level of the current directory, if you want to include those you can just match everything ('*')

    Code:
    chmod -R u=rwX,go=rX *

  10. #10
    Join Date
    May 2012
    Beans
    309

    Re: Change files / folders permission

    could explain to me please this one:

    Code:
    u=rwX,go=rX

Bookmarks

Posting Permissions

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