Skip to main content
简体中文版经机器翻译而成,仅供参考。如与英语版出现任何冲突,应以英语版为准。

chown

贡献者

XCP NFS chown 命令扫描并更改给定目录结构中所有文件的所有权。。 chown 命令需要使用NFS共享或POSIX路径作为变量。XCP chown以递归方式更改给定路径的所有权。。 chown 命令可显示文件的已更改用户ID (UID)。

语法
xcp chown -user/-group <user-name/group-name> <source NFS export path>
显示示例
[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]#

下表列出了 chown 参数及其问题描述。

参数 Description

<<nfs_chown_exclude,chown -排除();过滤器();

排除与筛选器匹配的文件和目录。

<<nfs_chown_match,chown -match ();过滤器(gt);

仅处理与筛选器匹配的文件和目录。

<<nfs_chown_group,chown -group

设置源上的Linux组ID (GID)。

<<nfs_chown_user,chown -user

设置源上的Linux UID。

<<nfs_chown_user_from,chown -user-from ();user_from (gt);

更改UID。

<<nfs_chown_group_from,chown -group-from ();group_from (gt);

更改GID。

<<nfs_chown_reference,chown -参考();参考();

指定引用的文件或目录点。

chown -v

报告处理的每个对象的输出。

chown -排除<filter>

使用 -exclude <filter> 参数 chown 命令以排除与筛选器匹配的文件和目录。

语法
xcp chown -exclude <filter> -user <user_name> <source NFS export path>
显示示例
[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>

使用 -match <filter> 参数 chown 命令以仅处理与筛选器匹配的文件和目录。

语法
xcp chown -match <filter>  -user <user_name> <source NFS export path>
显示示例
[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>

使用 -group <group> 参数 chown 命令以设置源上的Linux GID。

语法
xcp chown -match <filter> -user <user_name> <source NFS export path>
显示示例
[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>

使用 -user <user> 参数 chown 命令以设置源上的Linux UID。

语法
xcp chown -user -user <user_name> <source NFS export path>
显示示例
[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>

使用 -user-from <user_from> 参数 chown 命令以更改UID。

语法
xcp chown -user-from user1 -user <user_name> <source NFS export path>
显示示例
[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>

使用 -group-from <group_from> 参数 chown 命令以更改GID。

语法
xcp chown -group-from <group_name> -group <group_name> <source NFS export path>
显示示例
[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>

使用 -reference <reference> 参数 chown 用于指定引用的文件或目录点的命令。

语法
xcp chown -reference <reference> <source NFS export path>
显示示例
[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

使用 -v 参数 chown 用于报告已处理的每个对象的输出的命令。

语法
xcp chown -user-from <user_name> -v -user <user_name> <source NFS export path>
显示示例
[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]