chcon命令:修改对象(文件)的安全上下文。比如:用户:角色:类型:安全级别。
命令格式:

   Chcon [OPTIONS…] CONTEXT FILES…..

   Chcon [OPTIONS…] –reference=PEF_FILES FILES…

说明:

    CONTEXT 为要设置的安全上下文

    FILES 对象(文件)

    --reference 参照的对象

    PEF_FILES 参照文件上下文

    FILES      应用参照文件上下文为我的上下文。

    OPTIONS 如下:

        -f          强迫执行

        -R         递归地修改对象的安全上下文

        -r ROLE    修改安全上下文角色的配置

        -t TYPE    修改安全上下文类型的配置

        -u USER   修改安全上下文用户的配置

        -v         显示冗长的信息

         -l, --range=RANGE    修改安全上下文中的安全级别

范例:

1、ftp

//If you want to share files anonymously <如果你想把这个共享给匿名的话,需要开启以下> 
chcon -R -t public_content_t /var/ftp

//If you want to setup a directory where you can upload files 
<如果你想让你设置的FTP目录可以上传文件的话,SELINUX需要设置>
chcon -t public_content_rw_t /var/ftp/incoming

//You must also turn on the boolean allow_ftpd_anon_write <允许匿名用户写入权限> 
setsebool -P allow_ftpd_anon_write=1

//If you are setting up this machine as a ftpd server and wish to allow users to access their home directorories<如果你希望你的FTP用户可以访问自己的家目录的话,需要开启> 
setsebool -P ftp_home_dir 1

//If you want to run ftpd as a daemon<如果你希望将vsftpd以daemon的方式运行的话,需要开启> 
setsebool -P ftpd_is_daemon 1

//You can disable SELinux protection for the ftpd daemon<你可以让SElinux停止保护vsftpd的daemon方式动行> 
setsebool -P ftpd_disable_trans 1 

 2、httpd
//If you want a particular domain to write to the public_content_rw_t domain 
<如果希望具体个doman具有可写权限的话,需要设置> 
setsebool -P allow_httpd_anon_write=1 
or 
setsebool -P allow_httpd_sys__anon_write=1

//httpd can be setup to allow cgi s to be executed <HTTP被设置允许cgi的设置> 
setsebool -P httpd_enable_cgi 1

//If you want to allow access to users home directories<允许用户HHTP访问其家目录,该设定限仅于用户的家目录主页> 
setsebool -P httpd_enable_homedirs 1 
chcon -R -t httpd_sys_content_t ~user/public_html

//httpd is allowed access to the controling terminal<允许httpd访问终端> 
setsebool -P httpd_tty_comm 1

//such that one httpd service can not interfere with another 
setsebool -P httpd_unified 0

//loadable modules run under the same context as httpd 
setsebool -P httpd_builtin_ing 0

//httpd s are allowed to connect out to the network 
setsebool -P httpd_can_network_connect 1

// You can disable suexec transition 
setsebool -P httpd_suexec_disable_trans 1

//You can disable SELinux protection for the httpd daemon by executing <关闭Selinux的关于httpd进程守护的保护> 
setsebool -P httpd_disable_trans 1 
service httpd restart

3、named

//If you want to have named update the master zone files <关于named,master更新selinux设定> 
setsebool -P named_write_master_zones 1

//You can disable SELinux protection for the named daemon by executing 
<关闭named的进程守护保护> 
setsebool -P named_disable_trans 1 
service named restart

4、nfs

//If you want to setup this machine to share nfs partitions read only 
<Selinux将本机的NFS共享设置成只读> 
setsebool -P nfs_export_all_ro 1

//If you want to share files read/write<Selinux将本机的NFS共享设置成可读可写> 
setsebool -P nfs_export_all_rw 1

//If you want to use a remote NFS server for the home directories on this machine 
<如果你想要将远程NFS的家目录共享到本机,需要开启> 
setsebool -P use_nfs_home_dirs 1

5、samba

//If you want to share files other than home directorie 
<如果你希望将目录共享给其他用户,你需要设置> 
chcon -t samba_share_t /directory

//If you want to share files with multiple domains 
如果samba服务器共享目录给多个域,则需要: 
setsebool -P allow_smbd_anon_write=1

//If you are setting up this machine as a Samba server and wish to share the home directories 
samba服务器要共享家目录时: 
setsebool -P samba_enable_home_dirs 1

//If you want to use a remote Samba server for the home directories on this machine 
如果你需在本机上使用远程samba服务器的家目录 
setsebool -P use_samba_home_dirs 1

//You can disable SELinux protection for the samba daemon by executing 
关闭selinux关于samba的进程守护的保护 
setsebool -P smbd_disable_trans 1 
service smb restart

6、rsync

//If you want to share files using the rsync daemon 
共享rsync目录时: 
chcon -t public_content_t /directories

//If you want to share files with multiple domains 
允许其他用户写入时 
setsebool -P allow_rsync_anon_write=1

//You can disable SELinux protection for the rsync daemon by executing 
停止rsync的进程保护 
setsebool -P rsync_disable_trans 1

7、kerberos

//allow your system to work properly in a Kerberos environment 
允许系统使用kerberos 
setsebool -P allow_kerberos 1

//If you are running Kerberos daemons kadmind or krb5kdc 
setsebool -P krb5kdc_disable_trans 1 
service krb5kdc restart 
setsebool -P kadmind_disable_trans 1 
service kadmind restart

8、nis

Allow your system to work properly in a NIS environment 
系统工作在nis环境时 

setsebool -P allow_ypbind 1

出处:http://blog.163.com/lin_jianying/blog/static/1309355862012149519935/

linux chcon命令详解相关推荐

  1. linux mingetty 命令详解

    linux mingetty 命令详解 功能说明:精简版的getty. 语 法:mingetty [--long-hostname][--noclear][tty] 补充说明:mingetty适用于本 ...

  2. linux zip 命令详解

    功能说明:压缩文件.  语 法:zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b <工作目录>][-ll][-n <字尾字符串>][-t <日期 ...

  3. linux zipinfo 命令详解

    linux zipinfo 命令详解 功能说明:列出压缩文件信息. 语 法:zipinfo [-12hlmMstTvz][压缩文件][文件...][-x <范本样式>] 补充说明:执行zi ...

  4. Linux chkconfig命令详解

    Linux chkconfig命令详解 (2011-03-07 15:49:04) 转载 标签: linux shell chkconfig 杂谈 分类: 工作*Linux chkconfig:    ...

  5. linux uname 命令详解

    linux uname 命令详解 功能说明:显示系统信息. 语 法:uname [-amnrsv][--help][--version] 补充说明:uname可显示电脑以及操作系统的相关信息. 参 数 ...

  6. linux mread 命令详解

    linux mread 命令详解 功能说明:将MS-DOS文件复制到Linux/Unix的目录中. 语 法:mread [MS-DOS文件...][Linux文件或目录] 补充说明:mread为mto ...

  7. linux sort 命令详解

    linux sort 命令详解 sort命令的功能是对文件中的各行进行排序.sort命令有许多非常实用的选项,这些选项最初是用来对数据库格式的文件内容进行各种排序操作的.实际上,sort命令可以被认为 ...

  8. linux arpwatch 命令详解

    linux arpwatch 命令详解 功能说明:监听网络上ARP的记录. 语 法:arpwatch [-d][-f<记录文件>][-i<接口>][-r<记录文件> ...

  9. linux awk命令详解,使用system来内嵌系统命令,批量github,批量批下载视频, awk合并两列...

    linux awk命令详解 简介 awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分 ...

最新文章

  1. android 实训的背景,Android实训项目作业.doc
  2. 设计模式之facade模式
  3. viwer连接不到服务器 vnc_vnc viewer连不上怎么办 vnc viewer连不上的解决方法
  4. 二进制文件安装mysql_CentOS7下二进制文件安装MySQL5.6
  5. JS的parent对象
  6. mscorsvw.exe 关闭方法
  7. 分布式环境下限流器springboot实现,令牌桶
  8. ps 图片提取线稿方法2种 转
  9. 通过c语言来实现斐波那契数列。斐波那契数列指的是这样一个数列 1, 1, 2, 3, 5, 8, 13...这个数列从第3项开始,每一项都等于前两项之和。
  10. metadata firewall driver issues in openstack hav
  11. 智慧城市的互联网云脑架构,7种城市神经反射弧的建设是重点
  12. java 大数据处理之内存溢出解决办法
  13. 北京内推 | 中科院自动化所招聘机器视觉感知与理解算法工程师/实习生
  14. 格林酒店2019年第三季度营收同比增长20.1%
  15. 云计算实训室课程体系设计
  16. springboot 微信小程序 对接微信支付功能(完整版)
  17. Spring集成Memcached三种方式
  18. oracle计算比例,某字段的百分比
  19. 弥补胸肌缺陷的训练策略
  20. ThinkPhp5源码学习(容器)

热门文章

  1. 小米路由器 梅林_WIFI6真的有用吗?小米ALOT路由器AX3600上手体验!小米智能家居生态之选及选购分析...
  2. ole db 访问接口 sqlncli 无法启动分布式事务_分布式锁真的安全吗?
  3. Docker如何删除一个镜像
  4. 【pytorch】torch.linspace==>返回一个一维的tensor(张量),这个张量包含了从start到end,分成steps个线段得到的向量
  5. express 创建ejs项目,使用html
  6. [UE4]多个Montage之间存在协作问题
  7. yaf php源码,PHP-Yaf执行流程-源码分析
  8. 四轴码垛机器人配件_四轴码垛机器人的应用范围
  9. java 查询windows进程_Oracle查询语句,你知道几个?(下)
  10. Flat Tech html5 前端响应式模板