Results 1 to 25 of 25
-
04-10-2010, 07:24 PM #1Newbie
- Join Date
- May 2009
- Posts
- 36
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!
-
04-10-2010, 07:33 PM #2Web 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
-
04-10-2010, 07:55 PM #3Newbie
- Join Date
- May 2009
- Posts
- 36
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...
-
04-10-2010, 08:46 PM #4Web Hosting Master
- Join Date
- Dec 2005
- Posts
- 3,110
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?
-
04-10-2010, 08:52 PM #5Newbie
- Join Date
- May 2009
- Posts
- 36
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....
-
04-10-2010, 09:23 PM #6Web Hosting Master
- Join Date
- Apr 2003
- Location
- San Jose, CA.
- Posts
- 1,624
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.
-
04-10-2010, 09:44 PM #7Aspiring Evangelist
- Join Date
- Aug 2002
- Location
- Milton Keynes
- Posts
- 354
-
04-10-2010, 09:51 PM #8Newbie
- Join Date
- May 2009
- Posts
- 36
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!!!
-
04-10-2010, 10:03 PM #9Newbie
- Join Date
- May 2009
- Posts
- 36
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.
-
04-10-2010, 10:04 PM #10Junior 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.htmlAffordable Linux Server Managament Solution
To order : http://www.linuxnetworkcare.com
Contact :[ AIM : xerophytev] [MSN : support@linuxnetworkcare.com][ Phone : 647-722-5303 ][skype:ksutha5]
-
04-10-2010, 10:41 PM #11Newbie
- Join Date
- May 2009
- Posts
- 36
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!
-
04-10-2010, 10:58 PM #12Web Hosting Master
- Join Date
- Apr 2003
- Location
- San Jose, CA.
- Posts
- 1,624
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.
-
04-11-2010, 12:41 AM #13Web Hosting Master
- Join Date
- Jun 2004
- Location
- Oregon
- Posts
- 1,315
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.
-
04-11-2010, 01:50 AM #14WHT 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/
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 ?
-
04-11-2010, 03:45 AM #15Web Hosting Master
- Join Date
- Mar 2009
- Posts
- 2,222
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.htmlLast edited by tim2718281; 04-11-2010 at 03:51 AM.
-
04-22-2010, 01:46 AM #16Newbie
- Join Date
- May 2009
- Posts
- 36
tim2718281, thanks for the great reply! brilliant.... u r a real pro!!!
-
04-22-2010, 02:45 AM #17Web Hosting Master
- Join Date
- Feb 2005
- Location
- United Kingdom
- Posts
- 3,476
Explore our outstanding VPS choices tailored to your budget, and we welcome reasonable offers.
VPS Price Match Guarantee on: All our range of DDOS protected XEN HVM VPS
== Contact us for any online solution development or managed / unmanaged vps hosting ==
-
04-22-2010, 04:11 AM #18WHT Addict
- Join Date
- Feb 2008
- Location
- Jakarta
- Posts
- 154
It doesn't have to be 777 - Probably, depend on your server config.
I assume you upload the script using http? perhaps via php script?, first, investigate who is the owner of the file after you upload, then you can decide what is the minimum ownership for your script to do the thing it need to do later.
Investigate who need the write access, for example if your script (ex. php) run as an Apache Module, then the user runs the httpd process need write access.
Not sure what you mean by this .
I am fully agree with the previous comment saying don't use 777 , it is better to encourage your self for a different config which doesn't required a 777 permission just to write something from an internal script.Magnet Hosting | Layanan Hosting dan Server Indonesia
http://www.magnet-id.com Indonesian Data Center, Peering with IIX and openIXP
-
07-31-2012, 08:42 PM #19New Member
- Join Date
- Jul 2012
- Posts
- 1
ugh
I can't resist the urge to be a bit of a troll here and say that this guy needs to take it easy on the poor bloke asking a question. One "you don't know what you're doing" reply is enough. A computer is NOT a loaded gun, and as long as its circuits are properly shielded in a case, it poses very little physical danger. I feel like UNIX/Linux elitists like Lightwave are lording their superior knowledge over the otherwise bright-eyed newbies with nerdy diatribes like that, and the hypothetical trauma of potentially getting hacked because of using chmod -R irresponsibly will NOT put a bleedin' hole in your body. So, one warning is enough. If he heeds it great, if he doesn't, he does so at his own risk, but that is exactly how you learn.
-
08-01-2012, 11:57 AM #20Web Hosting Master
- Join Date
- Mar 2003
- Location
- Jaipur, India
- Posts
- 643
Hi,
sometimes, you need to apply 644 to all files and 755 to all directories, then i think you should use these commands :-
#find . -type d -exec chmod 775 {} \;
For all directories
#find . -type f -exec chmod 644 {} \;
For all filesRackNap
Business Automation Platform for Web Hosting and Cloud Solution Providers
-
08-03-2012, 03:28 AM #21Junior Guru
- Join Date
- Mar 2009
- Location
- Chicago, IL
- Posts
- 219
Please stop now.
Quit executing random commands that people on this forum are giving you. At no point in this thread have I seen enough information offered, nor the right questions asked for any of these suggestions to be appropriate.
1. 777 Permissions are a horrible hack, but in some environments, necessary (find a new environment).
2. Your script that modifies them, we'll need to know what user this is running as. Is it a PHP script running as nobody or as your user? Is it another sort of script running as your user?
3. When you connect via FTP, are you using the username for your hosting account?
The "right" want to handle this is to have the user that modifies these files be the same user that uploads them. That negates the need for 777 permissions in the first place and is the 'right' way to handle this.
Anyway, if you could answer those questions, that'd let us help you out better. And please quit running commands from random people on the internet.
-
08-24-2012, 10:48 PM #22New Member
- Join Date
- Aug 2012
- Posts
- 1
wow
I don't know how I stumbled onto this forum. But I joined it to simply make this comment.
PCS-Chris, Lightwave, and drspliff you are all PUTZs. You can not simply answer a question but rather you prefer to show your arrogance and illiteracy by assuming you have any idea what his application or use of the command would be? Your statements are simply not true and your false sense of competency and accomplishment are hilarious.
xerophyte, Vamsii and tim2718281 handled the response as it should be. The correct answers with explanation and a word of caution.
x264-BB the more you learn about Unix and the other varieties the more you will get drawn in and hopefully help others. Be sure not to develop the arrogant, know it all attitude of these three knuckleheads. I have been a system admin with Unix in all it's varieties for over 20 years an am published on the subject. I would never assume to know everything let alone assume I can save the world by not answering someones question. Specially assuming I have a clue to their application of the knowledge. Good luck.
-
08-25-2012, 05:08 AM #23Web Hosting Master
- Join Date
- Mar 2005
- Location
- Ten1/0/2
- Posts
- 2,529
What I find weird is that someone with their first post does a drive-by on a 2 1/2 year old long-forgotten thread...
Even weirder is that yet another first poster does the same.CPanel Shared and Reseller Hosting, OpenVZ VPS Hosting. West Coast (LA) Servers and Nodes
Running Linux since 1.0.8 Kernel!
Providing Internet Services since 1995 and Hosting Since 2004
-
09-18-2012, 09:45 AM #24Newbie
- Join Date
- Sep 2012
- Location
- Sydney, Australia
- Posts
- 7
Wrote a recursive chmod script
So I went trawling the web for an elegant and simple solution to this and decided to write a little script for this myself.
It basically does the recursive chmod but also provides a bit of flexibility for command line options (sets directory and/or file permissions, or exclude both it automatically resets everything to 755-644). It also checks for a few error scenarios.
Check it out:
http://bigfloppydonkeydisk.blogspot....-files-or.html
Hope it helps!
-
12-19-2012, 10:30 AM #25New Member
- Join Date
- Dec 2012
- Posts
- 1
Simple Question
Wow, I am amazed at the rudness and negative comments toward this man that just asked a simple question. He was not asking your personal opinion on sevrer security, he just wanted to know how to do something. I got to this forum because I was looking for the same answer but instead I get a bunch of useless lame negative comments.
Similar Threads
-
/tmp folder 777 ... use as sessions folder... secure?
By marikas in forum Hosting Security and TechnologyReplies: 3Last Post: 08-14-2007, 05:27 AM -
is it safe to chmod your public_html folder to 777?
By strato in forum Web Hosting LoungeReplies: 18Last Post: 10-21-2006, 06:13 PM -
PHP files altered, chmod 777 .htaccess
By NetHosted-Andrew in forum Hosting Security and TechnologyReplies: 2Last Post: 01-23-2006, 02:37 PM -
Pleas help need to run .cgi files in a /777/ folder with cpanel???
By DWHS in forum Hosting Security and TechnologyReplies: 5Last Post: 03-18-2003, 06:32 PM -
chmod 777
By banihani in forum Hosting Security and TechnologyReplies: 5Last Post: 09-05-2001, 07:27 PM