chcon -t system_u:object_r:etc_t:s0 nova.conf
执行上面的命令修改nova.conf的安全上下文,报错提示:
chcon: failed to set type security context component to ‘system_u:object_r:etc_t:s0’: Invalid argume
这是因为-t参数是修改上下文类型的,也就是etc_t。如果连用户、role都要改,则需要下面的命令:
chcon -u system_u -r object_r -t etc_t nova.conf
上面这条命令组装起来比较麻烦,我们还可以直接将其他文件的安全上下文引用过来,设置给需要设置的文件:可以使用 --reference将file1的安全上下文赋给file2。
chcon --reference file1 file2