views:

46

answers:

4

For example, i want a file has permission of 644 automatically when i uploaded it to my linux host, before upload, it is under windows. How could i do this?

Btw, i use Filezilla for upload

Updated: Before post this question, actually, i ever thought it is impossible too. But, as i has many wordpress sites, i remembered that i never need to set permission for wordpress files. So i did an experiment,

  1. dowload a new wordpress package, zip format (under windows)
  2. uploaded it to my linux host,
  3. unarchive
  4. check permissions of these files

I saw all files had their permission naturely right, some 644, some 755, exactly as described in wordpress document

+1  A: 

You can't. The permission is not written in the file itself, but rather in the filesystem. So it has to be done once the file has being uploaded.

Cristian
+2  A: 

I think this is not possible in most cases.

Could you give more information on how you upload? FTP, SFTP, SMB? :-)

For example for FTP you could configure the FTP server in order to give all new files the 644 umask (see this example for ProFTPd).

For SFTP, the client might be able to change the permissions after the upload, because it has SSH access, after all.

pableu
About your Update: This depends on the archive format. Tar, for example, is aware of linux file permissions, so files inside a .tar or a .tar.gz archive can keep their permissions. It doesn't matter if you transfer if via FTP or if you store in on a windows machine in between, because the permissions are stored *inside* the archive.
pableu
The wordpress package i downloaded and uploaded is in zip format, never used tar or tar.gz
Edward
And continue your thoughts, maybe it is because wordpress build their zip package under linux? And as i compress my files in windows, thus though permissions is stored but linux can't recognize the windows permission info, it looks make sense
Edward
Yes, that makes sense. I just tested it with a Zip-file on my linux-workstation. Indeed the Zip-file also keeps the permissions, at least when compressed and extracted under linux. And yes, permissions under Windows and Linux don't go very well together, so it makes sense that linux ignores any windows-permissions inside the Zip-file.
pableu
A: 

Assuming that you are using FTP to upload the files, better FTP clients (FileZilla) will allow you to set the permissions IF THE SERVER is setup to allow the FTP client to set it.

As far as "default settings", 644 is typically the default already for files. This again is set by the server. I would assume that there is an FTP client out there that will auto set it for every file, but I don't know for sure. If you go monkeying with permissions, remember that directories are 755, not 644, and it is possible that the server could let you remove your own access to the file.

Cody
A: 

First, what username owns the files? What username do you connect as when you upload?

What is that user's default umask setting?

S.Lott