显示及更改selinux模式
1.selinux两种模式:
*getenforce
*setenforce 0 ##表示permissive,警告(同意并警告)
1 ##表示enforcing,强制(拒绝并警告)
2.更改selinux开机状态
vim /etc/sysconfig/selinux
SELINUX=enforcing
3.reboot重启
4.显示上下文
例如:
ls -Z /var/ftp/pub
ps auxZ |grep vsftpd
5.修改安全上下文
一次性修改:chcon -t ##执行restorecon刷新后还原
永久修改:semanage fcontext
**例如:semanage fcontext -a -t public_content_t '/westos(/.*)?'
6.管理selinux布尔值
[root@localhost ~]# setsebool -P ftp_home_dir 1 ##打开上传权限
[root@localhost ~]# getsebool -a |grep ftp
ftp_home_dir --> on
[root@localhost ~]# chmod u+w /home/student
[root@localhost ~]# lftp 172.25.254.140 -u student
Password:
lftp student@172.25.254.140:~> put /etc/passwd
2050 bytes transferred
lftp student@172.25.254.140:~> ls
-rw-r--r-- 1 0 0 0 Apr 23 03:26 file
-rw-r--r-- 1 1000 1000 2050 Apr 29 02:12 passw