Help with chmod

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Calvinguy
    Confirmed User
    • Oct 2002
    • 1752

    #1

    Help with chmod

    How do I change filepermission for all .jpg images, folders and subfolders?

    I want to change to 0777 for a short period while a script make some changes (some images have different owners) and then back to normal again.

    After the script is finished I want all folders to be 0755 and all .jpg images to be 0644.
  • darksoul
    Confirmed User
    • Apr 2002
    • 4997

    #2
    Code:
    find /path/to/dir -name "*.jpg" -or -type d -print|xargs chmod 777
    reverse
    Code:
    find /path/to/dir -name "*.jpg" -print|xargs chmod 0644
    find /path/to/dor -type d -print |xargs chmod 0755
    1337 5y54|)m1n: 157717888
    BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
    Cambooth

    Comment

    • Calvinguy
      Confirmed User
      • Oct 2002
      • 1752

      #3
      Thanks,

      Never seen it like this before. Can you explain how it's working?

      Comment

      • darksoul
        Confirmed User
        • Apr 2002
        • 4997

        #4
        Originally posted by Calvinguy
        Thanks,

        Never seen it like this before. Can you explain how it's working?
        I assume you've seen stuff like:
        Code:
        chmod -R 777 /path/to/dir
        which for your 1st phase would work fine (except that it would chmod everything to 777 not just jpg's and directories).

        To reverse it you can't run a recursive chmod because you need different
        chmod for files and directories
        Code:
        find /path/to/dir -name "*.jpg" -print
        finds all images in that directory and prints them
        xargs executes "chmod 0644" for each image
        1337 5y54|)m1n: 157717888
        BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
        Cambooth

        Comment

        Working...