How to copy the permissions of a file to another?
Solution 1:
You can use a file as a reference file for both chown and chmod
chown --reference=index.php patch.log
chmod --reference=index.php patch.log
It's all in the man pages btw
chown
--reference=RFILE use RFILE’s owner and group rather than specifying OWNER:GROUP values
chmod
--reference=RFILE use RFILE’s mode instead of MODE values
Solution 2:
If there's any possibility of extended ACLs on the files in question, it's better to use getfacl/setfacl:
getfacl index.php | setfacl --set-file=- patch.log