Ive got a website (run on Ubuntu Server) that needs to modify and delete files, every now and again it comes across a file that it needs to run "chmod" on in order to perform it's operations.

However it seems as tho the 'www' user does not have permission to run 'chmod' on any files.

So I'm looking for the command to allow the 'www' user to do its thing on files inside the /var/www folder and also the /var/logs folder for example.


  • Who owns these files, and why? It'd be a useless rights concept if any user could give himself permissions to other users' files. Please explain your situation more.
    – Daniel Beck
    Apr 5, 2012 at 10:48
  • The directory is owned by user 1000 (me) and in group 33, the files inside are owned by user 33 and in group 33.
    – CodeChap
    Apr 5, 2012 at 11:02

1 Answer 1


chown can (usually) only be used by the super user (root). To chmod a file, I think you need to be the owner of the file (or be the super user).

To circumvent the restrictions, you could simple always use sudo to change the access modes or ownership.

But, most likely, you don't want to give global sudo rights to your www user.
This is where /etc/sudoers comes into play. Due to higher powers in play I can't work out an example for you right now.
So, for now, the man page for sudoers has to suffice.

I wouldn't recommend doing it anyway. If there are files that need to be manipulated, make sure they're created with proper access rights for your task to complete or somehow redesign the process to circumvent the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .