Unzipping file whilst getting correct permissions?
I unzipped a file on my server using:
unzip filename
However this seems to have caused all the files having owner/group permissions of 0 0
.
The files I uploaded were a PHP
software script, so I'm wondering how I set the permissions properly when unzipping the files and what they should be set to?
Zip doesn't support saving file ownership/permission as far as I know. You can try setting the umask so unzip should create the files with these permissions. Run
umask 644
before unzip
.
Actually, some answers here are not correct. ZIP files can also have file permissions. (*) You can list the permissions of the files in your ZIP file with:
unzip -Z
Maybe the tool you used to create the ZIP file didn't store the permissions or didn't store them correctly.
So, if you made the ZIP file yourself, check the tool you made the ZIP file with. Maybe there is a way to set permissions before zipping (like with maven), or it preserves the original permissions (but that would only work on a system that supports permissions - i.e. not on Windows).
If you didn't make the ZIP file yourself, your only chance is to set the correct the permissions after unzipping, for example with
chmod -R [permissions] [directory]
(*) We use that feature in combination with the maven assembly plugin, where you can specify the fileMode for files that go into the ZIP file.