I have VPS with CentOS 5.4.

This is production server.

The problem is when my webiste installs some scripts from site , then the owner name is not written on the file and as user i can even change the file permissions.

Is there any way that which ever script is writing file , the owner of home directory should the owner of all the files


Note: this solution requires changing permissions for file creation for specific users and directories.

Setting the setgid permission bit on a directory that will be written into will keep all new files written in that directory assigned to the group of that directory (instead of to the group of the user that created them).

If the HTTP server's user creates files with group write permissions by default, then all files written into directories in the proper user group and with the setgit bit set will be fully accessibly by the users in that group.

Setting the setgid bit on directoryname setting proper group ownership:

chmod g+s directoryname
chown :groupname directoryname

If group-write permission is not set by default, you'll need to set the umask of HTTP server user.


The problem is, that the script interpreter runs within the same user context as your webserver (Apache httpd?) does. Any files created by the scripts are owned by the user your webserver is running under.

For Apache httpd, there's the possibility to use SuExec or SuPHP to run CGI scripts within another user context (usually the owner of the script).


if you run ls -ln nameoffile you can get the numeric UID and GID of the process/user writing the files.

then you can use that to do something like chown UID.GID /path/to/where/files/are/ to change ownership of the directory the files are being written to, to the user who needs to access them. then you should do chmod 755 /path/to/where/files/are/ to change the permissions on the directory so that /only/ the USER can create new files in that directory.

i need more information from you about what is going on to help much further than that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy