hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : [FEATURED] How to chmod 777 recursively for files underneath a folder?
Reply

Forum Jump

How to chmod 777 recursively for files underneath a folder?

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-10-2010, 07:24 PM
x264-BB x264-BB is offline
Junior Guru Wannabe
 
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!


Thread Summary
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:

Quote:
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

Share This Summary:

Sponsored Links
  #2  
Old 04-10-2010, 07:33 PM
vapetrov vapetrov is offline
Web Hosting Guru
 
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

  #3  
Old 04-10-2010, 07:55 PM
x264-BB x264-BB is offline
Junior Guru Wannabe
 
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...

Sponsored Links
  #4  
Old 04-10-2010, 08:46 PM
PCS-Chris PCS-Chris is offline
The VPS Guru
 
Join Date: Dec 2005
Location: Berkshire, UK
Posts: 3,008
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?

__________________
Chris E | Linux SysAdmin looking for work
RHCSA, RHCE

  #5  
Old 04-10-2010, 08:52 PM
x264-BB x264-BB is offline
Junior Guru Wannabe
 
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....

  #6  
Old 04-10-2010, 09:23 PM
Lightwave Lightwave is offline
Web Hosting Master
 
Join Date: Apr 2003
Location: San Jose, CA.
Posts: 1,621
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.

  #7  
Old 04-10-2010, 09:44 PM
drspliff drspliff is offline
Aspiring Evangelist
 
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!

  #8  
Old 04-10-2010, 09:51 PM
x264-BB x264-BB is offline
Junior Guru Wannabe
 
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!!!

  #9  
Old 04-10-2010, 10:03 PM
x264-BB x264-BB is offline
Junior Guru Wannabe
 
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.
  #10  
Old 04-10-2010, 10:04 PM
xerophyte xerophyte is offline
Junior Guru
 
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]

  #11  
Old 04-10-2010, 10:41 PM
x264-BB x264-BB is offline
Junior Guru Wannabe
 
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!

  #12  
Old 04-10-2010, 10:58 PM
Lightwave Lightwave is offline
Web Hosting Master
 
Join Date: Apr 2003
Location: San Jose, CA.
Posts: 1,621
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.

  #13  
Old 04-11-2010, 12:41 AM
CNSERVERS CNSERVERS is offline
Web Hosting Master
 
Join Date: Jun 2004
Location: Oregon
Posts: 1,230
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.

  #14  
Old 04-11-2010, 01:50 AM
Vamsii Vamsii is offline
WHT Addict
 
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 ?

  #15  
Old 04-11-2010, 03:45 AM
tim2718281 tim2718281 is offline
Web Hosting Master
 
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.
Reply

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

Related posts from TheWhir.com
Title Type Date Posted
Think Encrypted Cloud Storage is Secure? Think Again, Researchers Say Web Hosting News 2014-04-30 18:21:56
Single Tweet Brings Dropbox DMCA Takedown Policy into Spotlight Web Hosting News 2014-03-31 04:30:00
BitTorrent Sync Announces Platform Updates, 1M+ Users Web Hosting News 2013-11-06 13:36:26
Dimension Data to Launch Three-Tier Cloud Backup Add-On Service Web Hosting News 2013-08-06 15:55:24
Egnyte Synchronizes Google Drive with Private Cloud Storage Web Hosting News 2013-07-17 12:36:21


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?