6

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

Edward
  • 4,858
  • 9
  • 37
  • 42
  • 1
    Could you use upper case letters correctly, please? For those who don't read English well, it helps to use `I` correctly. – S.Lott Jun 15 '10 at 15:23
  • Sorry for any wrong spell, english is not my native language. Could you tell me where i should change 'i' to 'I'? is the word 'i' should always be upper case? – Edward Jun 15 '10 at 15:35

5 Answers5

4

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
  • 3,200
  • 4
  • 23
  • 21
  • 2
    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 Jun 15 '10 at 15:37
  • The wordpress package i downloaded and uploaded is in zip format, never used tar or tar.gz – Edward Jun 15 '10 at 15:41
  • 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 Jun 15 '10 at 15:49
  • 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 Jun 15 '10 at 15:59
2

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
  • 198,401
  • 62
  • 356
  • 264
  • 1
    I dont' understand why in filesystem. Usecase: i created .sh script in windows. pushed to git. cloned it on linux. trying to execute: no chance. giving chmod +x ../script.sh, force push. cloning on another linux machine. trying to execute - profit. – Alexander.Iljushkin Dec 14 '16 at 13:07
  • @Alexander.Iljushkin I think in your case it comes from the fact that git acts as the middleman and knows the mode. OP wants to upload directly. See https://stackoverflow.com/a/40979016/860246 for how git handles it – Mickael V. May 28 '20 at 13:02
0

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
  • 3
  • 1
0

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
  • 384,516
  • 81
  • 508
  • 779
0

So you could use the Windows FTP command "quote" which lets you send arbitrary commands to the FTP server.

Assuming your Linux FTP server supports SITE UMASK...

e.g. ftp> quote SITE UMASK 111

This would be equivalent to doing: chmod 666 * on the Linux command line but via FTP on Windows.