find: unrecognized: -chcon
时间: 2023-07-02 15:07:53 浏览: 118
解决python脚本中error: unrecognized arguments: True错误
The error message "unrecognized: -chcon" typically occurs when using the `find` command with the `-exec` option to run a command that requires changing the SELinux context (`-exec chcon` for example), but the system does not support SELinux or the user running the command does not have sufficient permissions to change SELinux contexts.
To resolve this issue, you can try the following:
1. Check if SELinux is enabled on your system by running the command `sestatus`. If SELinux is not enabled, then you do not need to worry about changing SELinux contexts.
2. If SELinux is enabled, make sure that you have the necessary permissions to change SELinux contexts. You may need to be logged in as the root user or a user with sudo privileges.
3. If you are still experiencing issues, try using the `--context` option with the `find` command instead of using `-exec chcon`. For example:
```
find /path/to/files -type f -name "*.txt" --context unconfined_u:object_r:httpd_sys_content_t:s0 -exec echo {} \;
```
This will print the name of any files with a ".txt" extension in the specified directory that have the SELinux context `unconfined_u:object_r:httpd_sys_content_t:s0`. You can replace the `echo` command with whatever command you need to run on those files.
阅读全文