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

selinux --chcon命令的更多相关文章

  1. chcon命令详解

    导读 chcon命令是修改对象(文件)的安全上下文,比如:用户.角色.类型.安全级别.也就是将每个文件的安全环境变更至指定环境.使用--reference选项时,把指定文件的安全环境设置为与参考文件相 ...

  2. centos Linux系统日常管理2 tcpdump,tshark,selinux,strings命令, iptables ,crontab,TCP,UDP,ICMP,FTP网络知识 第十五节课

    centos  Linux系统日常管理2  tcpdump,tshark,selinux,strings命令, iptables ,crontab,TCP,UDP,ICMP,FTP网络知识 第十五节课 ...

  3. 0060 Linux SELinux 管理命令

    1. SELinux 的起源 SELinux 是一个面向政府和行业的产品,由 NSA.Network Associates.Tresys 以及其他组织设计和开发.尽管 NSA 将其作为一个补丁集引入, ...

  4. Linux 关于SELinux的命令及使用

    1. 模式的设置 : 修改/etc/selinux/config文件中的SELINUX=”" 的值 ,然后重启.enforcing:强制模式,只要selinux不允许,就无法执行 permi ...

  5. [TimLinux] selinux sesearch命令详解

    1. 描述 sesearch用于搜索SELinux安全策略规则集,命令来自包:yum install setools-console. 2. 命令 命令使用方法: sesearch [OPTIONS] ...

  6. SELinux处理命令

    1 查看SELinux状态 Enforcing为开启状态:Disabled为关闭状态. [root@localhost /]# getenforce Enforcing 2 临时关闭SELinux [ ...

  7. Linux 命令之chcon

    chcon命令:修改对象(文件)的安全上下文.比如:用户:角色:类型:安全级别.主要用在selinux中用来更改安全上下文.命令格式: Chcon [OPTIONS…] CONTEXT FILES…. ...

  8. 《鸟哥的linux私房菜》 - linux命令温故而知新

    在公司的某角落里,看到了<鸟哥的linux私房菜>,顿时想看看是什么鬼. 其他时候还要自己去买才有,现在正好,比图书馆方便.看完了,写点啥! 编辑器很重要,一个vim就主要是我的使用方向: ...

  9. [转]SELinux管理与配置

    原文链接:http://blog.csdn.net/huangbiao86/article/details/6641893 1.1 SElinux概述 SELinux(Security-Enhance ...

随机推荐

  1. HDU3341 Lost's revenge(AC自动机&&dp)

    一看到ACGT就会想起AC自动机上的dp,这种奇怪的联想可能是源于某道叫DNA什么的题的. 题意,给你很多个长度不大于10的小串,小串最多有50个,然后有一个长度<40的串,然后让你将这个这个长 ...

  2. delphi 从TWebBrowser WebBrowser得到全部html源码

    delphi 从TWebBrowser WebBrowser得到全部html源码 http://blog.csdn.net/webouse/article/details/3912174   网上查询 ...

  3. 一个Form中2个按钮,PHP后台如何判断提交的是哪一个按钮

    方法一: <div class="container theme-showcase" role="main"> <form class=&qu ...

  4. 一个轻量级的3D CSS 库

    JavaScript 3D library 该项目的目的是为了打造轻量级的.实用简单的3D CSS库. Usage使用方法 下载 minified库文件 和 css文件,并将其包含于你的HTML中,就 ...

  5. 2013 ACM/ICPC Asia Regional Changsha Online G Goldbach

    比赛的时候,被题目误导了,题目最后说结果可能很大,要取模,那时就想直接求会TLE的!!! 赛后才知道,坑啊………… 代码如下: #include<iostream> #include< ...

  6. http://www.cnblogs.com/yjmyzz/p/dubbox-demo.html

    http://www.cnblogs.com/yjmyzz/p/dubbox-demo.html

  7. myeclipse 8.6 安装svn插件

    第一种:在线安装 1.打开HELP->MyEclipse Configuration Center,切换到SoftWare标签页. 2.点击Add Site 打开对话框,在对话框Name输入Sv ...

  8. 弹性ScrollView,和下啦刷新的效果类似 实现下拉弹回和上拉弹回

    今天做了一个弹性ScrollView,和下啦刷新的效果类似,我想这个很多需求都用的这种效果 其实这是一个自定义的scrollView,上代码,这是我写在一个公共的组件包里的 package com.p ...

  9. C++多继承的观察和7点体会(都是实用派的观点) good

    这历来是一个受争议的话题,书上的样板话我就不说了.我只说说自己的一点观察和体会: 1. 多重继承在理论上是有道理,21天学通C++里举了一个例子,就是飞马继承于飞鸟(会飞)和马(会跑),你可以定义一个 ...

  10. MyBatis主键返回

    在使用MyBatis做持久层时,insert语句默认是不返回记录的主键值,而是返回插入的记录条数:如果业务层需要得到记录的主键时,可以通过配置的方式来完成这个功能. 比如在表的关联关系中,将数据插入主 ...