Jump to content


Photo

Explain what chmod does please!


  • Please log in to reply
6 replies to this topic

#1 Jen

Jen
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 14 August 2006 - 03:09 AM

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!

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 August 2006 - 03:13 AM

http://webmasterwork...mod_guide.shtml

That should explain all
Legend has it that reading the manual never killed anyone.
My site

#3 Jen

Jen
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 14 August 2006 - 03:31 AM

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?

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 August 2006 - 03:37 AM

a file retains its permissions until intentionally changed
Legend has it that reading the manual never killed anyone.
My site

#5 Jen

Jen
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 14 August 2006 - 03:40 AM

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);
?>

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 August 2006 - 03:45 AM

http://ca.php.net/ma...ction.chmod.php - try chmod 0722 not chmod 722

http://ca.php.net/ma...ction.chown.php - be careful about changing owners
Legend has it that reading the manual never killed anyone.
My site

#7 Jen

Jen
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 14 August 2006 - 03:58 AM

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/ma...ction.chown.php




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users