Jump to content

Explain what chmod does please!


Jen

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!
Link to comment
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?
Link to comment
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);
?>
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.