[命令] Linux 命令 chown (归属文件或目录)

案例一:将 test.txt 的所属主设置为 root

# chown root test.txt

或者:

# chown root: test.txt

案例二:将 test.txt 的所属组设置为 root

# chown :root test.txt

案例三:将 test.txt 的所属主设置为 root,所属组设置为 root

# chown root:root test.txt

案例四:将 test 目录和目录里的所有文件的所属主设置为 root,所属组设置为 root

# chown -R root:root test

案例五:将 test 链接的所属主设置为 root,所属组设置为 root,但是不影响这个 test 链接指向的源文件

# chown -h root:root test