On Linux, how the <rights and Owners> assign a file to another file it?
chown command to set the owner and user groups; chmod can set file permissions. Both commands support the use of another file as a reference (RFILE).
Copy a file / directory permissions to another file
The syntax is as follows:
1
2
|
chmod --reference=RRFILE FILE
chmod [options] --reference=RRFILE FILE
|
Replace RRFILE you want to use the file permissions, for example:
The file permissions assigned to a file b.
You can also specify multiple files:
1
|
$ chmod --reference=a b file2 file3
|
And find, xargs combination (set all file permissions of a directory):
1
|
$ find /path/to/dest/ -type f -print0 | xargs -O -I {} chmod --reference=/path/to/rfile {}
|
The owner of the copy of a file / directory to another file
chown general use OWNER: GROUP as an option argument.
And chmod syntax used here is similar:
1
2
|
chown --reference=RRFILE FILE
chown [options] --reference=RRFILE FILE
|
E.g: