Skip to main content
XCP

chown

Contributors netapp-aoife

The XCP NFS chown command scans and changes the ownership of all the files for the given directory structure. The chown command requires an NFS share or the POSIX path as a variable. XCP chown recursively changes the ownership for a given path. The chown command displays the changed user ID (UID) for a file.

Syntax
xcp chown -user/-group <user-name/group-name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -user user2 -v 101.101.10.110:/s_v1/smaple_set/D1

Sat Apr 2 23:06:05 2022
changed ownership of 101.101.10.110:/s_v1/smaple_set/D1 from 1001:0 to 1004:0
changed ownership of 101.101.10.110:/s_v1/smaple_set/D1/1.txt from 1001:0 to 1004:0
changed ownership of 101.101.10.110:/s_v1/smaple_set/D1/softlink_1.img from 1001:0 to 1004:0
changed ownership of 101.101.10.110:/s_v1/smaple_set/D1/1.img from 1001:0 to 1004:0
changed ownership of 101.101.10.110:/s_v1/smaple_set/D1/hardlink_1.img from 1001:0 to 1004:0
changed ownership of 101.101.10.110:/s_v1/smaple_set/D1/softlink_to_hardlink_1.img from 1001:0 to
1004:0
Xcp command : xcp chown -user user2 -v 101.101.10.110:/s_v1/smaple_set/D1
Stats : 6 scanned, 6 changed ownership
Speed : 2.25 KiB in (1.82 KiB/s), 1.11 KiB out (923/s)
Total Time : 1s.
STATUS : PASSED
[root@user-1 linux]#

The following table lists the chown parameters and their description.

Parameter Description

chown -exclude <filter>

Excludes the files and directories that match the filter.

chown -match <filter>

Only processes the files and directories that match the filter.

chown -group <group>

Sets the Linux group ID (GID) at the source.

chown -user <user>

Sets the Linux UID at the source.

chown -user-from <user_from>

Changes the UID.

chown -group-from <group_from>

Changes the GID.

chown -reference <reference>

Specifies the referenced file or directory point.

chown -v

Reports the output for every object processed.

chown -exclude <filter>

Use the -exclude <filter> parameter with the chown command to exclude the files and directories that match the filter.

Syntax
xcp chown -exclude <filter> -user <user_name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -exclude "fnm('1.img')" -user user2 101.101.10.210:/s_v1/smaple_set/D1

Excluded: 1 excluded, 0 did not match exclude criteria
Xcp command : xcp chown -exclude fnm('1.img') -user user2101.101.10.210:/s_v1/smaple_set/D1
Stats : 5 scanned, 1 excluded, 5 changed ownership
Speed : 2.10 KiB in (1.75 KiB/s), 976 out (812/s)
Total Time : 1s.
STATUS : PASSED
[root@user-1 linux]#

chown -match <filter>

Use the -match <filter> parameter with the chown command to only process the files and directories that match the filter.

Syntax
xcp chown -match <filter>  -user <user_name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -exclude "fnm('1.img')" -user user2 101.101.10.210:/s_v1/smaple_set/D1

Excluded: 1 excluded, 0 did not match exclude criteria
Xcp command : xcp chown -exclude fnm('1.img') -user user2101.101.10.210:/s_v1/smaple_set/D1
Stats : 5 scanned, 1 excluded, 5 changed ownership
Speed : 2.10 KiB in (1.75 KiB/s), 976 out (812/s)
Total Time : 1s.
STATUS : PASSED
[root@user-1 linux]#

chown -group <group>

Use the -group <group> parameter with the chown command to set the Linux GID at the source.

Syntax
xcp chown -match <filter> -user <user_name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -group group1 101.101.10.210:/s_v1/smaple_set/D1

Xcp command : xcp chown -group group1 101.101.10.210:/s_v1/smaple_set/D1
Stats : 6 scanned, 6 changed ownership
Speed : 2.25 KiB in (1.92 KiB/s), 1.11 KiB out (974/s)
Total Time : 1s.
STATUS : PASSED
[root@user-1 linux]#

chown -user <user>

Use the -user <user> parameter with the chown command to set the Linux UID at the source.

Syntax
xcp chown -user -user <user_name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -user user1 102.101.10.210:/s_v1/smaple_set/D1

Xcp command : xcp chown -user user1 102.101.10.210:/s_v1/smaple_set/D1
Stats : 6 scanned, 6 changed ownership
Speed : 2.25 KiB in (3.12 KiB/s), 1.11 KiB out (1.55 KiB/s)
Total Time : 0s.
STATUS : PASSED
[root@user-1 linux]#

chown -user-from <user_from>

Use the -user-from <user_from> parameter with the chown command to change the UID.

Syntax
xcp chown -user-from user1 -user <user_name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -user-from user1 -user user2
101.101.10.210:/s_v1/smaple_set/D1

Xcp command : xcp chown -user-from user1 -user user2 102.108.10.210:/s_v1/smaple_set/D1
Stats : 6 scanned, 6 changed ownership
Speed : 2.25 KiB in (2.44 KiB/s), 1.11 KiB out (1.21 KiB/s)
Total Time : 0s.
STATUS : PASSED
[root@user-1 linux]#

chown -group-from <group_from>

Use the -group-from <group_from> parameter with the chown command to change the GID.

Syntax
xcp chown -group-from <group_name> -group <group_name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -group-from group1 -group group2
101.101.10.210:/s_v1/smaple_set/D1

Xcp command : xcp chown -group-from group1 -group group2
101.101.10.210:/s_v1/smaple_set/D1
Stats : 6 scanned, 6 changed ownership
Speed : 2.25 KiB in (4.99 KiB/s), 1.11 KiB out (2.47 KiB/s)
Total Time : 0s.
STATUS : PASSED
[root@user-1 linux]#

chown -reference <reference>

Use the -reference <reference> parameter with the chown command to specify the referenced file or directory point.

Syntax
xcp chown -reference <reference> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -reference 101.101.10.210:/s_v1/smaple_set/D2/2.img 101.101.10.210:/s_v1/smaple_set/D1

Xcp command : xcp chown -reference 101.101.10.210:/s_v1/smaple_set/D2/2.img
101.101.10.210:/s_v1/smaple_set/D1
Stats : 6 scanned, 6 changed ownership
Speed : 3.11 KiB in (6.25 KiB/s), 2.01 KiB out (4.05 KiB/s)
Total Time : 0s.
STATUS : PASSED
[root@user-1 linux]#

chown -v

Use the -v parameter with the chown command to report the output for every object processed.

Syntax
xcp chown -user-from <user_name> -v -user <user_name> <source NFS export path>
Show example
[root@user-1 linux]# ./xcp chown -user-from user2 -v -user user1
101.101.10.210:/s_v1/smaple_set/D1

changed ownership of 101.101.10.210:/s_v1/smaple_set/D1 from 1004:1003 to 1001:1003
changed ownership of 101.101.10.210:/s_v1/smaple_set/D1/1.img from 1004:1003 to 1001:1003
changed ownership of 101.101.10.210:/s_v1/smaple_set/D1/1.txt from 1004:1003 to 1001:1003
changed ownership of 101.101.10.210:/s_v1/smaple_set/D1/softlink_1.img from 1004:1003 to
1001:1003
changed ownership of 101.101.10.210:/s_v1/smaple_set/D1/softlink_to_hardlink_1.img from
1004:1003 to 1001:1003
changed ownership of 101.101.10.210:/s_v1/smaple_set/D1/hardlink_1.img from 1004:1003 to
1001:1003
Xcp command : xcp chown -user-from user2 -v -user user1
101.101.10.210:/s_v1/smaple_set/D1
Stats : 6 scanned, 6 changed ownership
Speed : 2.25 KiB in (2.02 KiB/s), 1.11 KiB out (1.00 KiB/s)
Total Time : 1s.

STATUS : PASSED
[root@user-1]