Page 1 of 1

regarding chown

Posted: Wed Sep 22, 2010 1:29 pm
by skway
Dear All,

I am having problem changing owner of file . what I am doing is uploading file and after that changing its owner
by writing chown command , I am not able to change the owner at all .

can any body let me know how to do that ... by default it is giving owner as apache

Re: regarding chown

Posted: Thu Sep 23, 2010 1:08 am
by cpetercarter
On Unix/Linux systems, only the root user can change the owner of a file, as the php manual explains.

Re: regarding chown

Posted: Thu Sep 23, 2010 7:59 am
by skway
cpetercarter wrote:On Unix/Linux systems, only the root user can change the owner of a file, as the php manual explains.

is there any other option to tackle this situation, I have seen ftp commands but there is no command for changing the ownership

Re: regarding chown

Posted: Thu Sep 23, 2010 8:48 am
by requinix
Work around it. Probably will end up chmod 0777-ing instead.

Why do you need to change the ownership? Are you on shared hosting? What files are you dealing with?

Re: regarding chown

Posted: Thu Sep 23, 2010 10:12 am
by pickle
There should be no reason to change the ownership, unless

a) you've got users logging into the shell that need to modify them or
b) you've got a cron job running on the server as a different user.

In both of those cases, you may put the Apache user in a group with the other users, then set the sticky group writable bit on the directory. All future created files will then be writable by group members.

Re: regarding chown

Posted: Thu Sep 23, 2010 12:29 pm
by skway
@tasairis
I am working on dedicated server..


@pickle &
the thing is whenever I upload any file I am getting apache as user,
and ftp user which is not able to overwrite these files when I do all change all files user as ftp user I am able to overwrite files, the ftp user has access to all folders on server...
this the problem I am facing

Re: regarding chown

Posted: Thu Sep 23, 2010 12:33 pm
by pickle
Forget what I said about the sticky bit - apparently I was misunderstanding what it did.

You can do what ~tasairis suggestd & change the permissions on the file to world writable.

Re: regarding chown

Posted: Thu Sep 23, 2010 2:04 pm
by skway
@pickle

here is the summary what I have done
1-->uploaded file
2-->changed permission as 777 with php chmod function
3--> tried to set owner with php chown function

no success on 3rd point not able to change owner , i must change the owner :!:

Re: regarding chown

Posted: Thu Sep 23, 2010 2:14 pm
by pickle
Well you're screwed then. Only the root user can change ownership.

Re: regarding chown

Posted: Thu Sep 23, 2010 2:49 pm
by skway
ohhhhhhhhh allright .... will check it out ....