1

Our corporate unix environment automatically gzips files after 30 days. However, after gzipping the file permissions are reset to a default 644 file permission. Is there any way to reset this default for my files so that when they are compressed they retain their uncompressed file permissions?

Given that the script that automatically compresses my files is owned by a system administrator, I would like to offer a direct edit to this script to maintain the original permissions after compression. I would share the original script if I knew where it was located, but barring that are there any functions / edits that can accommodate this? Or am I just at the mercy of what information is retained by the gzip function?

Thanks a lot!

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
Scott L
  • 53
  • 1
  • 7
  • `tar` keeps the permissions after compressed. I think `zip` doesn't has this ability. – brrystrw Mar 11 '15 at 18:40
  • I may have misspoken when I said "zip." The precise format is gzip, i.e. a .sas7bdat file is compressed to a .sas7bdat.gz file format. Does this make a difference? Thanks a lot for getting back to me! – Scott L Mar 11 '15 at 18:48

1 Answers1

3

I just tried it, and gzip does in fact retain the file permissions when compressing and decompressing. I.e. when doing gzip xx and then gunzip xx.gz, the permissions of the initial xx, xx.gz, and the final xx are all the same.

It is possible that you are using a pipe, e.g. gzip -c xx > xx.gz, in which case the permissions of xx.gz would be determined by your umask, so the permissions of xx would be lost.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158