Bash: cloning the ownership and permissions of another file using reference

If you need to create a file that has the exact same ownership and permission bits as an existing file, the ‘reference’ flag provides a convenient shortcut.

For example, if you had a file named ‘myoriginal’ that had the exact ownership and permissions required for a new file ‘mynewfile’, you could use the commands below to inherit them.

sudo chmod --reference=myoriginal mynewfile
sudo chown --reference=myoriginal mynewfile

sudo is required if the ownership or permissions being assigned are beyond the permissions of the logged in user.

REFERENCES

man7.org, chmod man page

man7.org, chown man page

tecmint.com, copy file permission