LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-22-2009, 02:47 AM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 50
Apache: difference between chmod 644 and chmod 666 and chmod 600 for output/txt/dat?


Hello,

What is the difference between chmod 644 and chmod 666 and chmod 600 for output/txt/dat on website/apache server?
Little confused, in terms of security, and for board / messages... ?

Quote:
Permissions
u - User who owns the file.
g - Group that owns the file.
o - Other.
a - All.
r - Read the file.
w - Write or edit the file.
x - Execute or run the file as a program.

Numeric Permissions:
CHMOD can also to attributed by using Numeric Permissions:

400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
Best regards
 
Old 04-22-2009, 05:10 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,089

Rep: Reputation: 207Reputation: 207Reputation: 207
Hi

The files always have an owner. If the file is written by the web-server, the owner will be www-data or similar.

600 : Only owner can read/write
644 : Only owner can write, others can read
666 : All uses can read/write.
 
Old 04-22-2009, 07:02 AM   #3
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by Guttorm View Post
Hi

The files always have an owner. If the file is written by the web-server, the owner will be www-data or similar.

600 : Only owner can read/write
644 : Only owner can write, others can read
666 : All uses can read/write.
I chmoded 600 on a website and if you hit the direct link/url, people (world) can read that txt file.

And why fput (php) says it is better to be 666 than 644, since 644 is working too.

Code:
   $file = fopen("usernamefile.txt","w");
    fputs($file,$_POST[name]);
    fclose($file);
works with a chmod 644.
 
Old 04-22-2009, 08:02 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,089

Rep: Reputation: 207Reputation: 207Reputation: 207
Well, the web-server is the owner of the file then, and then only the first digit matters.
 
Old 04-22-2009, 10:46 AM   #5
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by Guttorm View Post
Well, the web-server is the owner of the file then, and then only the first digit matters.
I still dont understnd why people want something un-secured,
I quote this:


Quote:
5. Make sure file test.txt inside "logs" folder is writable by PHP scripts. On Unix (Linux) servers CHMOD this file to 666 (rw-rw-rw-).
That's it. To test if PHPGCounte works fine open graphcount.php?page=test in your browser, for example:
 
Old 04-22-2009, 12:58 PM   #6
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,089

Rep: Reputation: 207Reputation: 207Reputation: 207
Well, that's a different question. Usually www-data does not have many privileges, while other accounts on a web server have a lot more. So preventing e.g. you to read/write the file, does not add much to security. You could of course chown, then chmod it 600, but that's more like securing the web server from you.
 
Old 04-22-2009, 01:10 PM   #7
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
I don't use the numerical permissions, they are rather obscure. Just use the regular ones, that way you know exactly what you are doing.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Will this command work? chmod -R 644 *.php abefroman Programming 3 10-22-2005 08:26 AM
chmod 644 /etc/shadow stomach Linux - General 15 09-12-2005 08:28 PM
did chmod 666 on a directory but it doesn't work r3dhatter Linux - Newbie 6 06-10-2005 10:06 AM
Apache and php + chmod 644 daveo Linux - General 2 10-10-2003 08:33 AM
chmod 666 N_A_J_M Linux - General 4 02-09-2003 03:33 AM


All times are GMT -5. The time now is 08:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration