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.

  • It was actually zipped with window, sorry. – Brett Jun 3 '13 at 10:31
  • 1
    It doesn't matter if it was created on windows or *nix. Zip still doesn't support unix file permissions. Regardless where it was created. – lawl0r Jun 3 '13 at 10:33
  • Yeah, I know.... but you said I could try setting the umask so it would create the zip with these permissions; but don't think I can do that on windows? – Brett Jun 3 '13 at 10:40
  • Before unziping – lawl0r Jun 3 '13 at 10:41
  • 8
    @lawl0r yes it does. Use the -Z option to see them. – Stop Harming Monica Jul 27 '15 at 16:31

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.

  • 1
    i think you are right, but the way how you propose the answer it not right. you should focus to provide a good answer than criticize in a new one... – Francisco Tapia Jul 14 '15 at 15:20
  • 2
    @FranciscoTapia I updated my answer (with some things one could try), but I'll leave the hint that other answers are incorrect in there. I think it's important. – David Tanzer Jul 22 '15 at 7:38
  • 1
    UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. on Windows / mingw. I currently don't have access to my linux box, but there -Z works too. Anyway, thanks for the hint! – David Tanzer Dec 23 '15 at 11:15
  • 3
    @David Tanzer, your answer is the best even while it's not accepted. Indeed, the origin of an archive (e.g. Windows, Linux, etc) is important. I've tested on Linux (Zip 3.0, UnZip 6.00). Once a file is put into an archive the permissions are saved. And they being restored on the extracted file (e.g. when the file is extracted on Linux). Obviously, the permissions will be not applied when extracting on Windows box. It will be really cool to see in unzip a specific switch (like tar's --no-same-permissions) that doesn't preserve permissions and respects umask while extracting. – flaz14 Jun 6 '17 at 17:58
  • 1
    @DanielF Permissions are only there if the creating program put them there, so if your archive was created on Windows, zipinfo/unzip -Z can only guess. To see if the permissions are there, use zipinfo -v/unzip -Zv and look for “non-MSDOS external file attributes”; the two most significant bytes are the UNIX permissions (in hex, not octal!) provided the “file system or operating system of origin” is UNIX. – Alex Shpilkin Apr 10 at 12:39

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.