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

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?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

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.

share|improve this answer
It was actually zipped with window, sorry. – Brett Jun 3 '13 at 10:31
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
Oh ok..... got a bit confused when you said "so zip should create the files with these permissions". :) – Brett Jun 3 '13 at 10:49

ZIP archives do not store Unix permissions. If you want to retain those, you need to archive them using tar (and possibly gzip the archive as well).

If you unzip PHP files and they don't have proper permissions, this is what you should set it up like :

  • Files should be owned by some user account and group.
  • Files and folders should be readable (but not writable) by the web server process.
  • Folders should get the execute permission, but shouldn't be writable either.

So, for example, if you unzipped your files to /var/www/foo, and want your user (whoami) and group (id -gn):

find /var/www/foo -exec chown $(whoami):$(id -gn $(whoami)) {} \+
find /var/www/foo -type f -name '*.php' -exec chmod 644 {} \+
find /var/www/foo -type d -exec chmod 755 {} \+
share|improve this answer
I'm not sure exactly where I do that? Just inside the files in the dir I unzipped to? – Brett Jun 3 '13 at 10:32
In the folder you unzipped them to, or by supplying an absolute path to find. – slhck Jun 3 '13 at 10:49

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.

share|improve this answer
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 at 15:20
@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 at 7:38

Your Answer


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.