Jump to content

Archived

This topic is now archived and is closed to further replies.

Jen

Explain what chmod does please!

Recommended Posts

I wrote a very simple script that was supposed to update the contents of a news.txt file on the server's system, but I got "permission denied" errors when the script was run on the server.  I searched this forum for answers and found a lot about chmod, which I now understand has to do with file access permissions.  What I need is a clear explanation to a php noob about what chmod does, what's the significance of the number parameters (i.e. 755), and which number I should chmod to in my case.  Thanks!

Share this post


Link to post
Share on other sites
http://webmasterworkshop.com/guides/chmod_guide.shtml

That should explain all

Share this post


Link to post
Share on other sites
Thanks, the link explained a lot.  However, I have more questions.  Could anyone explain in more detail who falls into the "group" category as explained in the linked page?  Also, I want certain pages on my site to be password protected by a simple method which checks the user-entered password against the one on file.  Currently, anyone can view the contents of this file to find out the password.  Should I use 722 for the permission setting for that file?  If I chmod this file once, will it stay that way forever, or will I have to include a chmod somewhere in all my scripts to make sure that the file's permission settings stay like that?

Share this post


Link to post
Share on other sites
a file retains its permissions until intentionally changed

Share this post


Link to post
Share on other sites
OK, well I just stuck a short script on the server and ran it to try and change the permission of the news file I'm writing to, and I got an error saying i'm not the owner, so the chmod failed.  What can I do now?  Here's the script:
<?php
chmod("news.txt", 722);
?>

Share this post


Link to post
Share on other sites
http://ca.php.net/manual/en/function.chmod.php - try chmod 0722 not chmod 722

http://ca.php.net/manual/en/function.chown.php - be careful about changing owners

Share this post


Link to post
Share on other sites
Is there a way to find out who the owner is, or what the current file permission settings are for a particular file?  If I use chown, what exactly becomes the owner?  Is it the file that runs the script with chown("filename", "root")?  And what is the value of "root"?  I'm looking at Tayfun's post:  http://ca.php.net/manual/en/function.chown.php

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.