1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to mass chmod thousands of files?

Discussion in 'Site & Server Administration' started by aj22, Jul 17, 2006.

  1. #1
    How could I mass chmod thousands of files in the same folder? The FTP programs I've used (CoreFTP and SmartFTP) only show up to 2000 files in my folder, but there's about double that realistically (cPanel shows them all).

    Anyone know how I can do a mass chmod using another program or method?

    Thanks!!!!
     
    aj22, Jul 17, 2006 IP
  2. DrMalloc

    DrMalloc Peon

    Messages:
    130
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you have shell access, the command-line chmod program can do it for you. Just use the -R switch (chmod -R 755 dir/ for instance).
     
    DrMalloc, Jul 18, 2006 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    T0PS3O, Jul 18, 2006 IP
  4. aj22

    aj22 Peon

    Messages:
    643
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've heard about shell access before, but I'm more of an FTP guy... how would I go about doing that?


    Thanks again!
     
    aj22, Jul 18, 2006 IP
  5. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Download PuTTy, find your login credentials, login, CD to the right folder (optional) and issue that command.
     
    T0PS3O, Jul 18, 2006 IP
  6. aj22

    aj22 Peon

    Messages:
    643
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ok thanks for the quick reply.

    If putty comes back and tells me I don't have shell access enabled, what should I do? Ask my host?
     
    aj22, Jul 18, 2006 IP
  7. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes, that would be the best thing to do.
     
    T0PS3O, Jul 18, 2006 IP
  8. tdsii

    tdsii Member

    Messages:
    175
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #8
    any php script that can do that rather than having root access which is relatively hard.
     
    tdsii, Nov 29, 2008 IP
  9. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #9
    If they can't enable the shell access, you can request them to change the permissions of all the files. It will not take more than a minute to change the permissions.

    Kailash
     
    kailash, Nov 29, 2008 IP
  10. ianne2376

    ianne2376 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hello,

    I had a problem about this when I was installing magento commerce, since I am hosted at hostgator. Magento's installation files does not allow for permission 777 and 664, so I had to change all of magento's files to 755 and 644 (that's several hundred files).

    So I researched a bit and found a script that worked for me.

    In my situation, since all directories are in 777 and files are in 664, I had the script like this:


    -----------------------------------------------------------------------


    <?php

    function rChmod( $dir = "./", $dirModes = 0755, $fileModes = 0644 ){
    $d = new RecursiveDirectoryIterator( $dir );
    foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){
    if( $path->isDir() ) chmod( $path, $dirModes );
    else if( is_file( $path ) ) chmod( $path, $fileModes );
    echo $path."<br />\n";
    }
    }

    rChmod( "./some/dir" );

    ?>

    -----------------------------------------------------------------------


    Just replace "./some/dir" with the path of your folder, mine looks like: "home/xxxx/ssss/nnn/"

    Save the file as something.php

    Load the file in your root, and then run the file in any browser, and voila!

    It should work, it worked for me flawlessly ;)

    Good Luck!


    --Marianne
    Get a Free 5 Minute Psychic Reading at http://www.trupsychics.com
     
    ianne2376, Jan 20, 2009 IP
  11. zvezda

    zvezda Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
     
    zvezda, Mar 10, 2009 IP
  12. mysoogal

    mysoogal Guest

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    sudo chmod -R 777 /var/www/*

    notice the Asterisk * it says that all files after www/ will be set to 777 :D
     
    mysoogal, Apr 24, 2009 IP
  13. thuankkk

    thuankkk Active Member

    Messages:
    503
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    95
    #13
    thuankkk, Apr 25, 2009 IP
  14. alfa_375

    alfa_375 Active Member

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #14
    Excellent tips for chmod, I love this post. Thanks everybody
     
    alfa_375, Apr 26, 2009 IP
  15. postcd

    postcd Well-Known Member

    Messages:
    1,037
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    190
    #15
    or something like:
    find /root/folder/name -type f -exec chmod 644 {} \;
    may change all files recursivelly permissions.

    -type d
    means directory, type f is files
     
    postcd, Jul 16, 2014 IP