Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Linux folder permissions somehow wrong... [SOLVED]
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Linux folder permissions somehow wrong... [SOLVED]

mahjongmahjong Member
edited April 2014 in Help

Dear Users,

i have a big problem with linux folder permissions.
I have a php script, which downloads files with curl. The default user and group for all my files is my user, john with group john.

Lets see a part of the folder structure:

drwxrwxr-x 7 johndoe www-data 4096 Apr 23 13:48 boritok

drwxrwxr-x 4 johndoe www-data 20480 Apr 23 13:54 cache

drwxr-xr-x 3 johndoe johndoe 4096 Mar 16 12:55 languages

in the folder boritok

drwxr-xr-x 9 johndoe johndoe 4096 Jul 8 2013 2013

drwxr-xr-x 3 johndoe johndoe 4096 Apr 23 13:48 2014

drwxr-xr-x 2 johndoe johndoe 4096 Apr 23 13:48 temp

I can create and delete files with php in the cache folder, also in the boritok/temp folder, but i cannot do the same in boritok/2014/04/23/ folder, where all of the folders has the same permission as 2014, and the file is johndoe:johndoe with chmod of 644. It is very important to note: the same files gets deleted from both the cache folder and the temp folder.

I tried to chmod 777 the folder structure and the file, it still stayed there and never got deleted. I just can't understans. I copied the permission structure of the cache folder and temp folder, still it never worked. How comes? Any help, please? Thank you!

SOLVED:
It was my fault, i never thought that wordpress has changed it's code a little bit, so i had rewrite a part of my script. One function was fired late because of changes in the code of wordpress.

Comments

  • Maybe make all the files and folders belong to www-data:www-data.

  • mahjongmahjong Member
    edited April 2014

    Yes, i know that could work, but i don't understand how can it currently work with the cache folder and temp folder, and why does it fail at the nested folder.

  • blackblack Member

    I don't fully understand what you're saying, but let me try to help. First, you'll notice that there's 2 fields for user permission. for your "boritok" folder, the file owner is johndoe and the group owner is www-data.
    Your folder "2014" has only johndoe as file owner and group owner.


    The permissions set on your "boritok" folder is 777, meaning file owner, group owner, and others all have permission to read, write, and execute.


    Your "2014" folder has 755, which means the file owner "johndoe" has read,write,execute permissions. Group owners and others only have read and execute permissions, not write.


    PHP runs under the username "www-data" so for the folder "2014" it doesn't have permission to write to it, so it means it can't delete files in that folder.


    If the folder "2014" is in the folder "boritok", you need do something like chmod 777 boritok/2014 and whatever file you want it to write / delete.


    There's also a -R flag to recursively assign file &folder permissions.


    Though chmod 777 isn't recommended for security reasons (because everyone on the system can read /write / execute), it's better to use groups to manage permissions for directories.

  • Hi! Thanks for all the help! It was a change in wordpress's function which made my ever-working script fail (i forgot that i updated my wordpress to a newer version a few weeks ago, that is when i lost this function).

    It was not about permissions, but the timing changed for a wordpress function/hook.

    Thanks again!

Sign In or Register to comment.