Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm very new to server management, I literally just set this up for the first time a couple weeks ago, no idea what I'm doing.

In order to allow WordPress to run updates, apparently everything needs to be owned by www-data, but if everything is owned by www-data, I can't FTP with the user revxx14. When I try, I can't make any changes (deletions, additions, updating files, nothing. I get permission denied errors across the board). Is there a way to give my user the same permissions as www-data, so that I'll be able to keep www-data the owner, but still be able to make changes via FTP?

Thanks.

share|improve this question
1  
have you added the right users to the right groups on the system? –  PatomaS Feb 28 at 2:13
    
I've only set up one user, so I think so? How could I check? I'm completely new to Linux and hosting a server. –  Rev Feb 28 at 17:03
1  
I suggest to use scp or rsync over ssh instead of ftp. –  Kasper Souren Aug 23 at 15:05
    
I suggest you use a control panel, such as ZPanel. –  William D. Edwards Sep 26 at 17:07

2 Answers 2

When in your Terminal window, you can type ls -l to see the current file permissions and user and group that owns the file. This article from Ubuntu's Community explains how the file permissions are built:
https://help.ubuntu.com/community/FilePermissions

Now, to anwer your question, if you want to change a file or folder as a certain user, the user must either be:

  • the owner/creator of the file (again refer to ls -l) or;
  • member of the group the file is owned/created with.

Thus, if ls -l shows something like -rw-rw-r-- root www-data, the file is owned by root and is in the www-data group and can gives Read and Write access to the user and group and only Read access to the World. Since revxx14 is not root nor in the group www-data you cannot edit the file.

Now, in terminal you can add yourself to the www-data group:
usermod -a -G www-data revxx14

Now you're a part of the group you also have Read/Write access to the file. If you still get permisison errors after adding yourself to the group, make sure the file is in the www-data group (you can change this with chgrp www-data somefile.txt) and the file is writable by the group (you can change this with chmod g+w somefile.txt).

Last but not least, if you want to create a file in a folder, you need to have write access to the given folder. The file created will be owned by you and the primary you're in, thus should have Read/Write access by default.

share|improve this answer

Yes you can. I do not know WordPress, but this seems like just a permissions issue anyway. You can do one of several things. First, if the user www-data can FTP then that would be expedient, but perhaps not as safe as you want it to be since www-data should not have FTP permissions for security reasons. Alternatively, your user revxx14 could be modified to join the group that www-data belongs to and the file permissions modified to allow group modifications. This would allow you to drop the files into place, but you may still need to change file permissions.

However, the best solution is what I do. I create a temporary directory within the users home directory (in this case revxx14). I FTP the files there. Then I SSH in and copy the files from the temporary directory to the website with appropriate permissions. You would use cp to copy the files from your temporary directory to the destination, chown to change the destination file ownership, chgrp to change the destination file group ownership, and lastly chmod to change the permissions of the destination files. Lastly, use ls to check that you did your work correctly. Take note of the file ownership, group ownership, and permissions before you begin.

If you are not familiar with this process, create a situation where you practice using these commands where it would not matter if you make a mistake. Perhaps from one user to another user temporary directories. You may need to use mk to make the temporary directories.

Keep in mind that the files withing the web space are set specifically for security reasons and that should not change. If you copy these files from your temporary directory to the web space, then the files would have revxx14 users ownership, group ownership, and default permission. This means that for each file you copy, you would need to set the ownership, group ownership, and default file permissions to match the original file or other similar files. For example, some may have execute permissions while others only have read or read/write.

For myself, I know my files ownership and permissions natively so I can do mass file ownership and permissions changes using wild cards. I would only recommend using wild cards when you are sure of what you are doing. If you feel comfortable with the commands above, then you can use wildcards too.

share|improve this answer
    
I'm pretty sure the user is part of the same group, so how could I allow group modifications? A string to type in to my SSH client or an article explaining this would be very helpful. Thanks. –  Rev Feb 28 at 17:04
    
First become familiar with chmod. From shh, type man chmod and read. This is important because without seeing exactly what you are seeing, I cannot give you specific advice. However, I can give you this. Chmod changes file permissions. At the very least, you will need to change write permissions for the group. The command would be chmod g+w filename where g means group and +w means add write permission. To remove, use -w. File name can be a wildcard. This example may be enough to get you started. O'Reilly has a pocket sized Linux command reference I use often. You should get a copy. –  closetnoc Feb 28 at 17:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.