Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question about chmod

Discussion in 'General Discussion' started by Radio_Head, Jul 28, 2004.

  1. Radio_Head

    Radio_Head Well-Known Member

    Joined:
    Feb 15, 2002
    Messages:
    2,051
    Likes Received:
    1
    Trophy Points:
    343
    everytime I do chmod -R 644 *.php, it will only do the files in the
    current directory, and not recursively.


    Why and how to execute a 644 *.php on all subdrectories ?

    Thank you
     
  2. bamasbest

    bamasbest Well-Known Member

    Joined:
    Jan 10, 2004
    Messages:
    531
    Likes Received:
    0
    Trophy Points:
    166
    assuming you have no directories ending in .php that you want chmoded and are only looking to chmod files and are explicit about case sensitivity, the following should get you started:

    ls *.php | xargs chmod 644

    I'm sure someone else can chime in with a better way;)
     
  3. Radio_Head

    Radio_Head Well-Known Member

    Joined:
    Feb 15, 2002
    Messages:
    2,051
    Likes Received:
    1
    Trophy Points:
    343

    Yes I want chmod *.php files on all subdirs ..
    Your idea is good , but it doesn't work ..
    I receive this

    chmod: getting attributes of `info.php*': No such file or directory

    so as it seems it doesn't work on file which was chmoded 755 (with an * )
    and as it seems it doesn't work on subdirectories
     
    #3 Radio_Head, Jul 28, 2004
    Last edited: Jul 28, 2004
  4. Radio_Head

    Radio_Head Well-Known Member

    Joined:
    Feb 15, 2002
    Messages:
    2,051
    Likes Received:
    1
    Trophy Points:
    343
    this works better but it doesn't work on subdirectory

    ls --indicator-style=none *php | xargs chmod 644


    other ideas ?
     
  5. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    503
    Likes Received:
    4
    Trophy Points:
    168
    This may help.
    Take a look at the find command

    You can use something like
    cd dir (where dir is your starting point) (you could also just replace the . in the find command)

    find . -name "*.php" -exec chmod 644 {} \;

    Caution: use at your own risk.
    I might do this
    find . -name "*.php" -ls | awk '{print $3,$11}' > tmpchmodfile

    this will create a tmp file to use for backup purposes. looks something like
    -rwxr-xr-x ./myfile.php

    this way I know the myfile.php is currently set to 755
     
  6. Radio_Head

    Radio_Head Well-Known Member

    Joined:
    Feb 15, 2002
    Messages:
    2,051
    Likes Received:
    1
    Trophy Points:
    343

    Great ! Thank you
     
  7. bamasbest

    bamasbest Well-Known Member

    Joined:
    Jan 10, 2004
    Messages:
    531
    Likes Received:
    0
    Trophy Points:
    166
    Great if you've got the find command;)
     
  8. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    503
    Likes Received:
    4
    Trophy Points:
    168
    what server are you using?
     
  9. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    503
    Likes Received:
    4
    Trophy Points:
    168
    what server os are you using?
     
  10. Radio_Head

    Radio_Head Well-Known Member

    Joined:
    Feb 15, 2002
    Messages:
    2,051
    Likes Received:
    1
    Trophy Points:
    343
    me ? rh 7.2
     
Loading...

Share This Page