Linux command
chown 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Change
chown [user] [file]
Change
chown [user]:[group] [file]
Recursive
chown -R [user]:[group] [directory/]
Change
chown :[group] [file]
说明
chown (change owner) modifies file ownership. It can change the user owner, group owner, or both. File ownership determines who has ultimate control over file permissions. The command typically requires root privileges to change ownership to other users.
参数
- -R, --recursive
- Change files and directories recursively
- -v, --verbose
- Verbose output
- -c, --changes
- Report only changes
- --reference=_file_
- Use ownership from reference file
- -h, --no-dereference
- Affect symbolic links instead of targets
- -f, --silent, --quiet
- Suppress most error messages
- --from=_current_owner_:_current_group_
- Change only if current owner and/or group matches
- --dereference
- Affect the referent of each symbolic link (this is the default)
- -H
- If a command line argument is a symbolic link to a directory, traverse it (used with -R)
- -L
- Traverse every symbolic link to a directory encountered (used with -R)
- -P
- Do not traverse any symbolic links (default, used with -R)
- --preserve-root
- Fail to operate recursively on /
- --no-preserve-root
- Do not treat / specially (default)
FAQ
What is the chown command used for?
chown (change owner) modifies file ownership. It can change the user owner, group owner, or both. File ownership determines who has ultimate control over file permissions. The command typically requires root privileges to change ownership to other users.
How do I run a basic chown example?
Run `chown [user] [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -R, --recursive do in chown?
Change files and directories recursively