Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Join Date
    May 2009
    Posts
    35

    Question How to chmod 777 recursively for files underneath a folder?

    Hello,

    I like to ask what should I do if I like to chmod 777 recursively for files underneath a folder.

    Thank you!

  2. Thread Summary Permission issues can be tricky on Linux, especially when you want to change the permissions for all files inside a folder as WHT member x264-BB is hoping to do. By default, the "chmod" (Wikipedia) command in Linux only changes permissions for the folder you specify -- not every file inside.

    The right way to go about doing this is to recursively (-R) run the chmod command. For example:

    PHP Code:
    chmod -R 777 /home/admin/domains/domain_name/public_html/folder
    However, several members have also brought up a security concern with 777 permissions on files and folders as that essentially grants open-ended access to those files for all users on the server. Whether that's a real problem depends largely on how your server environment looks like, but generally speaking, 777 permissions can be risky.

    tim2718281 suggests a few workarounds for 777 permissions that won't compromise your server security:

    1) either to have the script run by a user in the group that owns the files, and have the files writable by group. (So chmod 775 rather than 777).

    2) or have the script run as the user that owns the files (see SUID in Linux). This was actually a brilliant idea by the inventors of Unix; an executable file with the SUID set (chmod +4) runs as the owner of the file, rather than the user who executes it.

    Contributors: Orien

  3. #2
    Join Date
    Nov 2003
    Location
    Kherson, Ukraine
    Posts
    267
    Code:
    # chmod --help
    Usage: chmod [OPTION]... MODE[,MODE]... FILE...
      or:  chmod [OPTION]... OCTAL-MODE FILE...
      or:  chmod [OPTION]... --reference=RFILE FILE...
    Change the mode of each FILE to MODE.
    
      -c, --changes           like verbose but report only when a change is made
          --no-preserve-root  do not treat `/' specially (the default)
          --preserve-root     fail to operate recursively on `/'
      -f, --silent, --quiet   suppress most error messages
      -v, --verbose           output a diagnostic for every file processed
          --reference=RFILE   use RFILE's mode instead of MODE values
      -R, --recursive         change files and directories recursively
          --help     display this help and exit
          --version  output version information and exit
    Private remote administrator of Linux servers - www.petrov.ks.ua
    Quality hosting - Host-Web-Site.com

  4. #3
    Join Date
    May 2009
    Posts
    35
    Sorry, I'm really new at this.

    For example, this folder:

    /home/admin/domains/domain_name/public_html/folder/


    What should I type in SSH as root?

    Thanks...

  5. #4
    Join Date
    Dec 2005
    Location
    Berkshire, UK
    Posts
    3,070
    I wont give you the answer because running 777 permissions on all files in a directory is completely insecure.

    Why do you need to give everything read, write and execute permissions to all users?
    SmartServerMangement (SSM)
    Specialists in SolusVM, VPS & cPanel Server Management

  6. #5
    Join Date
    May 2009
    Posts
    35
    I have a script on ftp that allows to change md5 harsh to files but the only way to have the files writable. Is there anyway that I can do it without making the it as insecure as what you mentioned? Maybe another chmod command? thanks....

  7. #6
    Join Date
    Apr 2003
    Location
    San Jose, CA.
    Posts
    1,622
    If you don't even know how to use the chmod command...
    having root access is your first problem. You're a child playing with a loaded firearm.

    Most people reply back saying, 'oh this is just a dev box... and the content doesn't matter'.

    Well then a) figure out how to administrate a machine before you play around online, or b) have someone do the administration for you who can alternatively explain why what you are trying to do is possibly a dumb idea.

  8. #7
    Join Date
    Aug 2002
    Location
    Milton Keynes
    Posts
    352
    Quote Originally Posted by Lightwave View Post
    having root access is your first problem. You're a child playing with a loaded firearm.
    Ahaha, I couldn't have put it better myself!

  9. #8
    Join Date
    May 2009
    Posts
    35
    Anyone can enlighten me other than sarcasm?

    I know how to access root, & I'm learning... somewhere before u knew everything u were a baby too, come on... give me some serious help... thanks!!!

  10. #9
    Join Date
    May 2009
    Posts
    35
    To make things more clear, this is what I need to do:

    1) I have files uploaded to my server into a folder occasionally
    2) They need to be writable
    3) So, my script can add 1kb to each file to change their md5 harsh
    4) Then I re-upload via FTP to another server that need those files with their md5 harsh changed

    Currently Situation
    Each time I upload the needed files to the server, I must access FTP to chmod them to writable before I can utilize the script.
    Now, I'm seeking for professional help from professional people inside here and hoping to find out how professional the answers can be rather than professional sarcasms.
    Anyone who can offer me help here will be deeply appreciated and at least the true professional. Thank you.
    Last edited by x264-BB; 04-10-2010 at 10:06 PM.

  11. #10
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    197
    giving public accessible folder 777 permission insecure, but if you need to know read this

    http://www.unixref.com/guides/chmodGuide.html
    Affordable Linux Server Managament Solution
    To order : http://www.linuxnetworkcare.com
    Contact :[ AIM : xerophytev] [MSN : support@linuxnetworkcare.com][ Phone : 647-722-5303 ][skype:ksutha5]

  12. #11
    Join Date
    May 2009
    Posts
    35
    xerophyte, i totally understand that. thanks!

    But it is an hassle to have files to be chomd writable before I run my script. After having those files made writable, re-uploaded to another server, they will be deleted via the md5 changer script.

    So, I'm looking for a solution which I can skip the steps of connecting to FTP, select the files, chmod them all to 777 then finally run my script, so that each time new files uploaded are being made writable automatically then I run the script to have their md5 harsh changed then re-uploaded to another server that needs them. This way, it improves my productivity.

    Thanks!

  13. #12
    Join Date
    Apr 2003
    Location
    San Jose, CA.
    Posts
    1,622
    What's sad is you think it's sarcasm.
    At some point you'll probably get hacked, all your files deleted...
    and maybe then you'll get the idea that you don't know what you're doing.

    You're not looking for a professional answer from a professional.
    You're looking for the lazy free answer that suits your needs.

    Your question amounts to, "How do I do something stupid?"
    Professionals are telling you simply, "You don't".

    To go back to my earlier analogy, you're asking "How do I load this gun?"
    People are telling you, "If you don't know how to load a gun, you shouldn't be handling one."

    I'm sorry that's not the answer you're looking for.

  14. #13
    Join Date
    Jun 2004
    Location
    Oregon
    Posts
    1,272
    i don't think it's possible to automatically chmod unless you run a chmod command via cron.
    if you run DA+php i would suggest you run them as fastcgi so you don't need to chmod files to make them writable.

  15. #14
    Join Date
    Oct 2009
    Location
    India
    Posts
    123
    hi. giving 777 permissions in public directory is not advised..
    but if you want for some reason
    PHP Code:
    chmod -R 777  /home/admin/domains/domain_name/public_html/folder
    and to learn more about chmod
    type man chmod in terminal

    again giving 777 permissions to files in public directory is not a good idea.
    What happens to cloud when it rains ?

  16. #15
    Join Date
    Mar 2009
    Posts
    2,218
    Quote Originally Posted by x264-BB View Post
    To make things more clear, this is what I need to do:

    1) I have files uploaded to my server into a folder occasionally
    2) They need to be writable
    3) So, my script can add 1kb to each file to change their md5 harsh
    4) Then I re-upload via FTP to another server that need those files with their md5 harsh changed

    Currently Situation
    Each time I upload the needed files to the server, I must access FTP to chmod them to writable before I can utilize the script.
    Now, I'm seeking for professional help from professional people inside here and hoping to find out how professional the answers can be rather than professional sarcasms.
    Anyone who can offer me help here will be deeply appreciated and at least the true professional. Thank you.
    The -R option on chmod changes files and directories recursively, so that's the answer to your question. See "man chmod".

    However, the normal way achieve what you to achieve is:

    1) either to have the script run by a user in the group that owns the files, and have the files writable by group. (So chmod 775 rather than 777).

    2) or have the script run as the user that owns the files (see SUID in Linux). This was actually a brilliant idea by the inventors of Unix; an executable file with the SUID set (chmod +4) runs as the owner of the file, rather than the user who executes it.

    It's worth spending the time to learn about both of these methods. They make it possible to do all just about everything automatically and securely, without a human signing in and executing commands.

    However, some Linux distributions disable SUID for shell scripts, so to use this method from a shell script may take a bit more work. Here's a link with more on this

    http://www.tuxation.com/setuid-on-shell-scripts.html
    Last edited by tim2718281; 04-11-2010 at 03:51 AM.

Page 1 of 2 12 LastLast

Similar Threads

  1. /tmp folder 777 ... use as sessions folder... secure?
    By marikas in forum Hosting Security and Technology
    Replies: 3
    Last Post: 08-14-2007, 05:27 AM
  2. is it safe to chmod your public_html folder to 777?
    By strato in forum Web Hosting Lounge
    Replies: 18
    Last Post: 10-21-2006, 06:13 PM
  3. PHP files altered, chmod 777 .htaccess
    By NetHosted-Andrew in forum Hosting Security and Technology
    Replies: 2
    Last Post: 01-23-2006, 02:37 PM
  4. Pleas help need to run .cgi files in a /777/ folder with cpanel???
    By DWHS in forum Hosting Security and Technology
    Replies: 5
    Last Post: 03-18-2003, 06:32 PM
  5. chmod 777
    By banihani in forum Hosting Security and Technology
    Replies: 5
    Last Post: 09-05-2001, 07:27 PM

Related Posts from theWHIR.com

Posting Permissions

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