Issue
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!
Solution
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.
Answered By - Mark Adler Answer Checked By - Senaida (WPSolving Volunteer)