CentOS中更新context(SELinux上下文)主要有以下步骤:
ls -Z /path/to/file_or_directory
查看文件/目录的当前SELinux上下文。sudo chcon -t context_type /path/to/file_or_directory
临时更改(重启后失效)。sudo yum install policycoreutils-python
。sudo semanage fcontext -a -t context_type "/path/to/file_or_directory(/.*)?"
。sudo restorecon -Rv /path/to/file_or_directory
。ls -Z
确认上下文是否更新成功。注意:修改前需了解上下文含义,避免影响系统安全;生产环境建议先在测试环境验证。