LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-24-2008, 06:31 PM   #1
htamayo
Member
 
Registered: Jan 2005
Location: san salvador, el salvador
Distribution: Debian Stable, UbuntuStudio Karmic Koala
Posts: 190

Rep: Reputation: 30
how to set "rw-r--r--" file permission instead of rwx------


Hi, I've coded an app with LAMP, in one html form I use 6 images files, but just 2 of them are displayed, now, I was fighting checking everything: the php code, html tags, css tags, and apache2 conf and nothing works, but guess what, I decided to view the permission of the files an I obtained these:

Code:
-rw-r--r-- 1 tamayo tamayo 170325 2007-10-22 08:18 linux01.jpg
-rw-r--r-- 1 tamayo tamayo 170325 2007-10-22 08:18 linux02.jpg
-rwx------ 1 tamayo tamayo 204256 2007-03-22 14:01 linux03.jpg
-rwx------ 1 tamayo tamayo 137271 2007-03-22 14:02 linux04.jpg
-rwx------ 1 tamayo tamayo 534135 2007-03-22 14:27 ubuntu001.jpg
-rwx------ 1 tamayo tamayo 268203 2007-03-22 14:25 ubuntu004.jpg
So, the "displayed files" are:

Code:
-rw-r--r-- 1 tamayo tamayo 170325 2007-10-22 08:18 linux01.jpg
-rw-r--r-- 1 tamayo tamayo 170325 2007-10-22 08:18 linux02.jpg
I figured out that is a file permission problem.

My question is:
1. how can I set "rw-r--r--" permission to all my images files instead of "rwx"?

2. I thought that "rwx" is greater than "-rw-r--r--", exactly what is the difference between them?

Thanks for your help

Tamayo
 
Old 07-24-2008, 06:45 PM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,117
Blog Entries: 2

Rep: Reputation: 113Reputation: 113
use the chmod to change the permissions chmod 0644 filename

If you read the manpage for chmod you'll see a good explanation of the different permissions.
Essentially its broken into 3 parts, user, group and world
-rwx------ is read, write, and execute permissions for user
-rw-r--r-- is read, write for user, read for group and world
 
Old 07-24-2008, 06:45 PM   #3
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
Does this Quick and Dirty Guide to Linux File Permissions help you?
 
Old 07-24-2008, 06:47 PM   #4
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by estabroo View Post
use the chmod to change the permissions chmod 0644 filename

If you read the manpage for chmod you'll see a good explanation of the different permissions.
Essentially its broken into 3 parts, user, group and world
-rwx------ is read, write, and execute permissions for user
-rw-r--r-- is read, write for user, read for group and world
-rwx------ is read, write, and execute permissions for owner of the files
 
Old 07-24-2008, 07:03 PM   #5
htamayo
Member
 
Registered: Jan 2005
Location: san salvador, el salvador
Distribution: Debian Stable, UbuntuStudio Karmic Koala
Posts: 190

Original Poster
Rep: Reputation: 30
You were right, It works, now all images are displayed,

Thanks for your help

Regards
 
Old 07-24-2008, 07:16 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You might also want to look at your personal umask value. The umask command can change your default mask when creating file. However having a umask of 022 would create files with rw-r--r-- permissions. You don't want x permissions by default. This is usually set in ~/.profile.

Enter "help umask" in the bash shell. The umask command is a bash builtin command.

Last edited by jschiwal; 07-24-2008 at 07:18 PM.
 
Old 07-24-2008, 10:21 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Actually Bruce

Quote:
A combination of the letters ugoa controls which users’ access to the
file will be changed: the user who owns it (u), other users in the
file’s group (g), other users not in the file’s group (o), or all users
(a). If none of these are given, the effect is as if a were given, but
bits that are set in the umask are not affected.
from the chmod man page
 
Old 07-24-2008, 11:11 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Even though I've lived on *nix systems for > 25 years, I still have to go back a a mnemonic UGO (User, Group, and Other) when using the chmod letters (octal requires no thought). So if you have trouble with these (or stalactite/stalagmite), avoid thinking Owner because the letter O is otherwise owned (used!) by chmod's Other.
 
Old 07-25-2008, 06:04 AM   #9
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 813

Rep: Reputation: 195Reputation: 195
"tamayo" is both a group and a user.

There are baically two differences between files that got rendered and those that didn't.

(1) Those that got rendered had no execute permission for the user.
(2) Those that got rendered had also read rightfor all (group and others).

So which is it?

Normally one assumes that in Apache server (php is the front end) controlled by the user permission. But if this were so, all 6 files should be readable. (since all have read permission for the user tamayo).

Howeevr, the four files that don't get rendered by apache have an "x". Maybe its a security issue.

I dont have access to an Apache server but if you could try it out and post the result, it would really help.

End

So it looks like Apache renders based on the group flag.
 
Old 07-25-2008, 03:36 PM   #10
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
The apache process runs under its own UID/GID, lets' call it www/www.

Therefore, any files that apache needs to read must readable by www/www. The execute permission has no relevance.

If the files have owner/group tamayo/tamayo, then the files must have minimally --6 permission (where -'s are irrelevant).

If the files are owner/group tamayo/www, then the files may have either or both of -6- or --6 permission.

If the files are owner/group www/tamayo, then the files may have either or both of 6-- or --6 permission.

When suexec is enabled, things change.

[ AnanthaP - the term "rendered" is inaccurate and misleading; access permission is the appropriate concept, as this has nothing to do with bit blasting, but is about simple file access permissions ]

Last edited by Mr. C.; 07-25-2008 at 03:38 PM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
tshark gives "permission denied" writing to (any) file in home dir. kr0m3 Linux - Networking 5 08-16-2016 12:22 PM
"Permission denied" and "recursive directory loop" when searching for string in files mack1e Linux - Newbie 5 06-12-2008 08:38 AM
can't set leading "s" in file permission toddcurry Linux - General 2 10-19-2006 06:34 PM
what is "S" instead of "X" in the file permission when i look at /usr/bin/chsh? Linux_interest Linux - Newbie 4 08-28-2004 10:22 AM
"rwx" and "valid users" - which one has precedence? kenji1903 Linux - Networking 8 07-27-2004 11:21 AM


All times are GMT -5. The time now is 02:26 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration