Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I followed the answer to this question for setting default file permissions in my web root folder:

http://unix.stackexchange.com/questions/1314/how-to-set-default-file-permissions-for-all-folders-files-in-a-directory

I am trying to set all files/dirs to 775 by default. This works fine when creating files within linux and also when creating files directly on the web root through the samba share but it doesnt seem to work when files are created on the windows disk and ftp'd over.

When I do this the file permissions are set as read/write owner only [-rw-------] so apache cant even read them.

My setup is that Im running ubuntu in a virtualbox with a windows 7 host. I have a local directory on the host where I store the files and I ftp them to the ubuntu machine using netbeans for testing.

When I ftp to the vb I am connecting as an authenticated user (the same one that owns the web root and everything in it - who is also in the same group as apache and this is the group all the files are part of).

How can ensure that files are created with 775 permissions when ftping. (I am using vsftpd)

Thanks in advance for any suggestions

UPDATE - SOLVED

If any one else is having the same issue, I managed to solve this by editing the file .bashrc which is in the root of each users home directory (on ubuntu - I believe different set ups are used elsewhere).

Inside the file I set a umask for the ftp user by adding the line umask 002 to the bottom of the file.

This has the effect of giving all files created by the user permissions of 775.

You will need to reboot (or maybe just logout) for the changes to take effect

share|improve this question

2 Answers

up vote 1 down vote accepted

Sorry, I thought I was helping, didn't mean to offend you. Thanks for the down-vote.

If you want everything go you way, to avoid all the trouble, here is the quick fix that satisfy all your requirements.

Setup a cron job, in which all you need to do is

chmod -R 775 /path/to/vsftpd

The cron job will kickin in whatever interval that you think necessary.

HTH

share|improve this answer
+1 Thank you for your suggestion. I have managed to create the effect I wanted by applying a umask to a user account that I have setup for ftp. I think the cron job approach would cause me problems as I am ftping directly to /var/www and it would overwrite any permissions I deliberately changed within the web root but it's an approach i hadn't thought of and may well come in handy for other purposes. – WebweaverD Mar 12 at 13:57
Glad that you solve it on your own. Sorry that I sound offensive before, -- i had the feeling that the ftpd uploading is interfering with web files, but the OP was not quite clear, thus I asked. – xpt Mar 12 at 14:48
To avoid editing the .bashrc file for each and every user, you can try using the /etc/profile.d/ trick that I answered at superuser.com/questions/557430/…. – xpt Mar 12 at 14:50

That’s kind of Windows mentality: whatever happened, hide the problem by sweeping it under the carpet. In *nix world, we don’t hide the problem, but deal with it.

Another typical Windows mentality is, there have always been silver-bullets that solve problems automagically. What’s the silver-bullets for my case? In *nix world, there isn’t any silver-bullets that solve problems automagically.

All that I want to say is that your issue does not have an easy fix. And, in order to solve the problems, I think the first step is to clearly describe what the problems are. E.g., “when I next try to upload files all the permissions are read only” is not enough for us to understand the situation.

Thanks

share|improve this answer
If that's 'all you want to say' then you are about as useful as a chocolate teapot. Admittedly I was tired when asking and it could have been better but rather than saying what I shouldn't do, how about some suggestions as to what I SHOULD do to help diagnose and solve the issue. Clearly I'm not a linux pro or I probably wouldn't have to ask - I am however trying to learn and embrace linux - I have looked for a solution and the solutions I have found have not worked, I am happy to provide more info if you or some other kind soul could try to be a little more guiding and constructive. – WebweaverD Mar 11 at 17:10

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.