Take the 2-minute tour ×
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.

I files I uploaded was a PHP software script, so wondering how I set the permissions properly when unzipping the files and what they should be set to?

share|improve this question
add comment

2 Answers

up vote 4 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
show 1 more comment

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
add comment

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.