Normally set the ownership and permission for a file using chown and chmod command, If you want to Clone ownership and permissions from another, update using chmod and chown with parameter called --reference,
chown --reference=source thisfile
chmod --reference=source thisfile
Now, the linux.txt file same ownership and permissions set to test.txt.
Set Ownership,
# chown --reference=linux.txt test.txt
Set Permission,
# chmod --reference=linux.txt test.txt
Check the file permission,
# ls -al
-rwxr-xr-x 1 test test 0 Feb 18 23:50 linux.txt
drwxr-xr-x 60 root root 4096 Jan 24 02:42 locale
-rwxr-xr-x 1 test test 0 Feb 18 23:49 test.txt
-rw-r--r-- 1 root root 41532 Jun 4 2013 Errordn
Comments (0)