How to disable selinux while spinning up a redhat vm in alicloud using cloud init. I have tried with below code but it doesn't work
sudo sed -i 's/enforcing/disabled/g' /etc/selinux/config /etc/selinux/config sudo sestatus
any suggestion ?
How to disable selinux while spinning up a redhat vm in alicloud using cloud init. I have tried with below code but it doesn't work
sudo sed -i 's/enforcing/disabled/g' /etc/selinux/config /etc/selinux/config sudo sestatus
any suggestion ?
Best way to disable SELinux while spinning up a VM is by using the following command:
sed -i 's/enforcing/disabled/g' /etc/selinux/config /etc/selinux/config
or
vi /etc/sysconfig/selinux, set selinux=disabled
or
set enforce 0 sestatus
Please try the 3rd command, It usually works well than other two, Sometimes VM restart may be required.
You can use write_file in cloud init like in the documentation here
before encode in Base 64 is recommended.
You want to have this on your /etc/sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted
Use this cloud-init:
#cloud-config
# vim: syntax=yaml
#
# This is the configuration syntax that the write_files module
# will know how to understand. encoding can be given b64 or gzip or (gz+b64).
# The content will be decoded accordingly and then written to the path that is
# provided.
#
# Note: Content strings here are truncated for example purposes.
write_files:
- encoding: b64
content: CiMgVGhpcyBmaWxlIGNvbnRyb2xzIHRoZSBzdGF0ZSBvZiBTRUxpbnV4...
owner: root:root
path: /etc/sysconfig/selinux
permissions: '0644'