0

I installed git on my server and cloned my development repository using the root user. The permissions appeared to have been set to:

Files:       -rw-r--r--
Directories: drwxr-xr-x

I previously had been using an FTP client to upload files. I need to still be able to use the FTP editor sometimes, but now when I try uploading a file with it I receive the error:

Can't open that file: Permission denied

I've been reading a lot of content on Linux permissions, but I'm just very confused what I should set the file and directory permissions to in order for my FTP client to work again.

A lot of the information I've been reading seems conflicting.. For example, some websites say to just change the permissions to 777, but other say not to as that allows any user on the system total control of the files.

Would the correct approach here be to change the "owner" of the files from what I assume is root to my FTP user?

  • "and cloned my development repository using the root user" — why, exactly? – Michael Homer Jan 31 '15 at 22:55
  • @MichaelHomer Because I don't know what I'm doing :-) How should I have done it? – Nate Jan 31 '15 at 22:56
  • As the same user you were using for FTP, if that wasn't root and you want to continue accessing the files by FTP. – Michael Homer Jan 31 '15 at 22:58
1

Would the correct approach here be to change the "owner" of the files from what I assume is root to my FTP user?

Yes. As root, run chown -R yourftpuser:yourftpgroup /path/to/tree. Your permissions will be fine for FTP at that point. All files will be owned by the FTP user, who has write access¹.

In future, you can avoid this by cloning as the user you want to end up owning the files.

Note though that all the files are readable by any user on the server with the permissions you posted. If that's a problem, you can remove the r permission from group and other: chmod -R go-r /path/to/tree.

¹ This assumes that your FTP server is set up to use system user accounts for login. They don't all behave that way, and it may be that you need to use its internal account system or change the file owner to the server's user.

Your Answer

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

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