[root@hadoop1 hadoop-2.7.2]# chcon --help
Usage: chcon [OPTION]... CONTEXT FILE...
or: chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
or: chcon [OPTION]... --reference=RFILE FILE...
Change the security context of each FILE to CONTEXT.
-c, --changes like verbose but report only when a change is made
-h, --no-dereference affect symbolic links instead of any referenced file
(available only on systems with lchown system call)
-f, --silent, --quiet suppress most error messages
--reference=RFILE use RFILE's context instead of using a CONTEXT value
-u, --user=USER set user USER in the target security context
-r, --role=ROLE set role ROLE in the target security context
-t, --type=TYPE set type TYPE in the target security context
-l, --range=RANGE set range RANGE in the target security context
-R, --recursive change files and directories recursively
-v, --verbose output a diagnostic for every file processed
--help display this help and exit
--version output version information and exit
字面上理解,就是修改文件安全上下文,感觉跟selinux有关。
比如,在安装jdk7的时候,可能会遇到这个错(在安装jdk6时没遇到这个错,装jdk7的时候遇到了,hadoop2.7是用jdk7编译的)
[root@hadoop1 jdk1.7.0_01]# java
Error: dl failure on line 875
Error: failed /home/devsoftware/jdk1.7.0_01/jre/lib/i386/client/libjvm.so, because /home/devsoftware/jdk1.7.0_01/jre/lib/i386/client/libjvm.so: cannot restore segment prot after reloc: Permission denied
chcon -t texrel_shlib_t /home/devsoftware/jdk1.7.0_01/jre/lib/i386/client/libjvm.so如果问题还得不到解决,检查一下是否关闭selinux,即在/etc/selinux/config里把SELINUX改为disabled
博客介绍了Linux中`chcon`命令的用途,主要用于修改文件的安全上下文,该操作通常与SELinux相关。在安装特定软件如JDK7时,可能需要使用`chcon`来解决权限问题。
1197





