Linux File Ownership

blog-iconEvery file on your Linux system, including directories, is owned by a specific user and group. Therefore, file permissions are defined separately for users, groups, and others. All hosting accounts will have a user on the server, and file ownership is determined upon file creation. This article attempts to clarify how permissions work on Linux and methods by which ownership and permissions can be modified.


As an example if you login to FTP using your username (lets say USER), and password. If you upload an image called ‘image.jpg’ via FTP into your webspace this ‘image.jpg’ will be owned by ‘USER’ (this also applies to content uploaded via WebShell).

If however you are uploading via a PHP script then Apache is the performing the upload and thus the file is then owned by the user Apache runs as (HTTPD).  This is going to cause problems if you want to edit,remove or override the file via FTP as it will have the incorrect ownership and you will not have the correct permissions (you will be working in FTP as USER but the file will be owned by HTTPD).

There are a number of methods which you can use that will allow you to modify the file:

  1. The first method is to reset the file ownership within the hosting control panel:
    1. Login to your control panel.
    2. Click ‘Domain Settings’.
    3. Click ‘File Ownership’.
    4. Click the ‘Reset Ownership’ button.

    You files will now have been reset to your user.

    fileownership

  2. If you have uploaded the file via a CMS such as Joomla you could modify the file via the same interface.  Alternatively you can delete the file via the same interface and re-upload it using FTP or Webshell thus becoming owned by your user.
  3. You can also modify the permissions on the existing file to allow ‘Others’ to read and write allowing you to modify the file.
  4. Another option would be to change the ownership of the file from within your upload script after the files have been uploaded.

Rate this post 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

This entry was posted in Linux & PHP, Tips & Tricks and tagged , . Bookmark the permalink.

One Response to Linux File Ownership

  1. Pingback: Advanced PHP Configuration | Web Hosting Resource

Leave a Reply

Please DO NOT use this form to submit support requests, all information submitted will be PUBLICLY VISIBLE.

Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.