日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
輕松自如關(guān)閉與開啟SELinux

SELinux 主要由美國國家安全局開發(fā)。2.6 及以上版本的 Linux 內(nèi)核都已經(jīng)集成了 SELinux 模塊,SELinux 的結(jié)構(gòu)及配置非常復(fù)雜,而且有大量概念性的東西,要學(xué)精難度較大。很多 Linux 系統(tǒng)管理員嫌麻煩都把 SELinux 關(guān)閉了,本篇文章就為大家分享一下如何方便的關(guān)閉與開啟SELinux。

腳本代碼

#!/bin/bash  
#  -------------+--------------------  
# * Filename    :       selinux.sh          
# * Revision    :       2.0            
# * Date        :       2017-09-02
# * Author      :       Aubin          
# * Description :                      
#  -------------+---------------------
#       www.shuaiguoxia.com
#

path=/app/selinux
selinux=`sed -rn "/^(SELINUX=).*\$/p" $path`

case $1 in
enforcing|en)

       sed -ri "s@^(SELINUX=).*\$@\1enforcing@g" $path
       if [ $selinux ==  'SELINUX=disabled' ];then
               read -p "SELinux enforcing. you need reboot system ( yes or no ):" input
               [ $input == 'yes' -o $input == 'y' ] && reboot || echo "please Manual operation reboot"
       else
               echo "SELinux enforcing."
       fi
       ;;
permissive|per|pe)
       sed -ri "s@^(SELINUX=).*\$@\1permissive@g" $path
       if [ $selinux == 'SELINUX=disabled' ];then
               read -p "SELinux permissive. you need reboot system ( yes or no ):" input
               [ $input == 'yes' -o $input == 'y'] && reboot || echo "please Manual operation reboot"
       else
               echo "SELINUX permissive"
       fi
       ;;
disabled|dis|di)
       sed -ri "s@^(SELINUX=).*\$@\1disabled@g" $path
       if [ $selinux == 'SELINUX=enforcing' ];then
                read -p "SELinux permissive. you need reboot system ( yes or no ):" input
               [ $input == 'yes' -o $input == 'y' ] && reboot || echo "please Manual operation reboot"
       else
               echo "SELINUX disabled"
       fi
       ;;
l|a)
       echo `sed -nr 's@(^SELINUX=.*)@\1@p' $path`
       ;;
help|--help)
       echo "$0 [ enforcing | permissive | disabled  ]"
       ;;
*)
       echo "$0 [ enforcing | permissive | disabled  ]"

       ;;
esac

腳本測試

根據(jù)case語句對用戶的位置變量(輸入的參數(shù))進(jìn)行判斷,進(jìn)而根據(jù)不同的參數(shù)實(shí)現(xiàn)不同的效果。

SELinux在enforcing狀態(tài)與disabled狀態(tài)切換時必須要進(jìn)行重啟才能生效,所以要在腳本中判斷用戶之前的SELinux的狀態(tài)是什么樣的,詢問用戶是否進(jìn)程重啟操作系統(tǒng)。


本文題目:輕松自如關(guān)閉與開啟SELinux
網(wǎng)址分享:http://www.5511xx.com/article/dpgehds.html