How do I change the ownership of files within my public_html folder?
Posted by on 28 March 2011 07:34 PM
There's several ways to change the ownership of files.
In DirectAdmin it can be done by going to "File Manager", "public_html". Select appropriate file or folder text box and clik "set Permission" right after you type preffered permission mode.
If you don't familiar with permission modes, here's the explanation:
Read 4 - Allowed to read files
Write 2 - Allowed to write/modify files
eXecute1 - Read/write/delete/modify/directory
0477 -r--rwxrwx owner has read only (4), other and group has rwx (7)
0677 -rw-rwxrwx owner has rw only(6), other and group has rwx (7)
0444 -r--r--r-- all have read only (4)
0666 -rw-rw-rw- all have rw only (6)
0400 -r-------- owner has read only(4), group and others have no permission(0)
0600 -rw------- owner has rw only, group and others have no permission
0470 -r--rwx--- owner has read only, group has rwx, others have no permission
0407 -r-----rwx owner has read only, other has rwx, group has no permission
0670 -rw-rwx--- owner has rw only, group has rwx, others have no permission
0607 -rw----rwx owner has rw only, group has no permission and others have rwx
To change permission through SSH, use the following command:
chmod <user><control><permission> <file>
<user>: u user/owner
<control>: + add this permission
- remove this permission
= set exactly this permission
<permission>: r read
To change file/directory owner, use the following command:
chown username filename/directory
You can add -R option to set owner of directory and all files in that directory:
chown -R username filename/directory
It is also possible to set file's group:
chown username:group filename/directory
Also, file permission can be changed with any FTP client. For example, to do it with FileZilla, click on appropriate file or directory right button and choose "File permissions...". The window with permissions attributes will pop up. There you can set owner, group and public permissions by selecting appropriate checkboxes or type'ing numeric value.