CentOS 禁用 SELinux 方法(临时和彻底关闭)

Kevin 教程 2,028 次浏览 47条评论

SELinux 是 Linux 内核的一个安全增强功能,其主要作用是控制程序服务的操作权限,包括对系统服务、网络端口、文件资源方面的访问约束。也因其严格限制策略和复杂配置门槛,一般个人用户很难驾驭。基本装完系统就默认关掉它,不然以后部署服务很容易遇到被限制问题。

查看 SELinux 状态

CentOS 原版系统默认启用 SELinux,可以用sestatus命令查看。有些主机商可能为了避免用户遇到不必要麻烦,所提供的系统模板默认关闭了 SELinux,阿里云和 Linode 的 CentOS 系统就是这样。

[vpsdp@centos ~]$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted

彻底关闭 SELinux

修改 SELinux 配置文件/etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled

[vpsdp@centos ~]$ sudo vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.


sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

之后sudo reboot重启系统生效。

临时关闭 SELinux

准确的说,这种方式不是关闭 SELinux,而是切换到permissive模式(不执行 SELinux 安全策略,但打印警告信息)。

# 切换至 permissive 模式
sudo setenforce 0

# 恢复至 enforcing 模式
sudo setenforce 1



  1. #1

    hydroxychloroquine use in taiwan https://hydroxychloroquine.webbfenix.com/

  2. #2

    reliable careprost source https://carepro1st.com/

  3. #3

    hydroxychloroquine coronavirus trial results https://hhydroxychloroquine.com/

  4. #4

    naltrexone shot for alcohol abuse https://naltrexoneonline.confrancisyalgomas.com/

  5. #5

    alternative to ivermectin https://ivermectin.mlsmalta.com/

  6. #6

    hydroxychloroquine use for fibromyalgia https://hydroxychloroquine.mlsmalta.com/

  7. #7

    recommended dosage for cialis http://www.lm360.us/

  8. #8

    vidalista 5mg costco https://vidalista.mlsmalta.com/

  9. #9

    ivermectin 3 mg for humans https://ivermectin.webbfenix.com/

  10. #10

    is viagra better than sildenafil http://droga5.net/

  11. #11

    vidalista canada https://vidalista40mg.mlsmalta.com/

  12. #12

    where to buy priligy in usa https://ddapoxetine.com/

  13. #13

    cialis vs levitra reviews https://wisig.org/

  14. #14

    how does albuterol help bronchitis https://amstyles.com/

  15. #15

    chewable viagra and cialis https://tadalafili.com/

  16. #16

    over the counter hydroxychloroquine https://hydroxychloroquinee.com/

  17. #17

    plaquenil for psoriatic arthritis https://hydroxychloroquine.mymvrc.org/

  18. #18

    plaquenil for psoriatic arthritis https://hydroxychloroquine.grassfed.us/

  19. #19

    what is better cialis or viagra https://tadalafil365.online/

  20. #20

    what is better cialis or viagra https://tadfil.online/

  21. #21

    drugs used to prevent malaria https://hydroxychloroquine.grassfed.us/

  22. #22

    drugs used to prevent malaria https://hydroxychloroquine.lm360.us/

  23. #23

    cheap prescription medications from canada https://medpills.bee-rich.com/

  24. #24

    cheap prescription medications from canada https://edmeds.buszcentrum.com/

  25. #25

    generic cialis fast delivery https://tadalafil.cleckleyfloors.com/

  26. #26

    sildenafil 100 online india https://zsildenafil.com/

  27. #27

    best tadalafil brand in india http://ciaalis2u.com/

  28. #28

    aurogra 100mg tabs https://aurogra.buszcentrum.com/

  29. #29

    cialis destroyer https://cialis.mlsmalta.com/

  30. #30

    cialis destroyer https://cialis.webbfenix.com/

  31. #31

    generic vidalista pills http://vidallista.com/

  32. #32

    tadalafil prescription drugs https://cialis.bee-rich.com/

  33. #33

    tadalafil prescription drugs http://cialis.audiovideoninja.com/

  34. #34

    pharmacy store https://atadalafil.online/

  35. #35

    viagra internet http://viaagra1.com/

  36. #36

    best price for viagra 100mg http://viiagra.co/

  37. #37

    Hello excellent blog! Does running a blog such as this
    take a large amount of work? I have virtually no expertise in programming but I
    had been hoping to start my own blog in the near future.
    Anyhow, if you have any ideas or techniques for new blog owners please share.
    I know this is off subject but I simply wanted to ask. Thanks a lot! http://cleckleyfloors.com/viagra

  38. #38

    Right now it appears like Movable Type is the preferred blogging platform available right now.
    (from what I’ve read) Is that what you are using on your blog? https://cialis.cleckleyfloors.com/tadalafil

  39. #39

    This paragraph is truly a good one it helps new the web visitors, who are wishing in favor
    of blogging. https://hydroxychloroquines.studiowestinc.com/

  40. #40

    generic soft tabs cialis https://cialis.stdstory.com/

  41. #41

    I take pleasure in, result in I discovered exactly what I was
    having a look for. You’ve ended my 4 day
    long hunt! God Bless you man. Have a nice day. Bye https://hydroxychloroquineg.grassfed.us/

  42. #42

    You’ve made some really good points there. I checked on the web for
    additional information about the issue and found most individuals will go along
    with your views on this site. http://www.deinformedvoters.org/sildenafil-price

  43. #43

    Great blog! Is your theme custom made or did you download
    it from somewhere? A theme like yours with a few simple adjustements would really make my blog
    stand out. Please let me know where you got your design. Thanks https://cialis.grassfed.us/tadalafil

  44. #44

    vidalista and alcohol effects http://viidalista.co/

  45. #45

    You are so cool! I do not believe I have read a single
    thing like this before. So good to discover somebody with a few genuine thoughts on this subject matter.
    Seriously.. many thanks for starting this up. This site is one thing that’s needed
    on the web, someone with some originality! https://hydroxychloroquinec.cleckleyfloors.com/

  46. #46

    Hello there, You’ve done a fantastic job. I will definitely digg it and personally recommend to my friends.

    I am confident they’ll be benefited from this web site. http://www.deinformedvoters.org/viagra-generic

  47. #47

    buy prednisone from canada https://bvsinfotech.com/


电邮地址用于 Gravatar 头像显示,不会被公开可见。