Thread: CHMOD all files

    #1
  1. The Basketball Star
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2001
    Location
    H-Town
    Posts
    550
    Rep Power
    14

    CHMOD all files


    How would I CHMOD all files with a .pl extension to 755 in my cgi-bin directory (and its subdirectories)? I know how to CHMOD one file, but not recursively on an extension. Thanks for the help.
  2. #2
  3. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    I would have thought the following would work:

    chmod -R 755 *.pl
  4. #3
  5. The Basketball Star
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2001
    Location
    H-Town
    Posts
    550
    Rep Power
    14
    Seems to only work for the current directory. It doesn't go to the subdirectories.
  6. #4
  7. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    Hrm, you're right, I tried a few things and couldn't get it to work. You could write a shell or perl script to recurse through the directories and execute the chmod command for you.
  8. #5
  9. The Basketball Star
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2001
    Location
    H-Town
    Posts
    550
    Rep Power
    14
    I've seen it done straight from the command line because I saw my DBA do it once before. I don't know how to write a shell script and I don't know how to recurse through directories in Perl.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    Try this:

    1) In current working directory:
    Code:
    find . -type f -name "*\.pl" | xargs chmod 755
    2) Or specify the root dir:
    Code:
    find /path/to/that/dir -type f -name "*\.pl" | xargs chmod 755
  12. #7
  13. The Basketball Star
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2001
    Location
    H-Town
    Posts
    550
    Rep Power
    14
    Great! It worked. Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo