I have zip file created on windows and I want to extract it on Linux. For extracted files, I want to have permissions 644. However, extracting files end with 770.

I have tried

umask 644
unzip update.zip -d . 

But it has no effect and permissions of extracted files are still 770.


Your umask mode is wrong.

# umask 644
# touch test1
# stat -c "%a %n" test1
22 test1

To get resulting files with 644, you need to set umask 0022.

# umask 0022
# touch test2
# stat -c "%a %n" test2
644 test2

From man umask:

umask() sets the calling process's file mode creation mask (umask) to mask & 0777 (i.e., only the file permission bits of mask are used), and returns the previous value of the mask.

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.