LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   How to disable SELINUX? (https://www.linuxquestions.org/questions/linux-security-4/how-to-disable-selinux-4175472740/)

SimpleTricks 08-09-2013 02:07 AM

How to disable SELINUX?
 
I tried to use this command

vi /etc/selinux/config

but i do not know what to press to disable SELINUX, and when it is already disabled, does it need a reboot for it to be recognized as already disabled?

itlb 08-09-2013 02:13 AM

How to disable SELINUX?
 
vi is a text editor, if you don't know how to use it I recommend using nano.
To disable selinux you will need to make sure SELINUX=disabled is in /etc/selinux/config. You will need to reboot for changes to take effect

SimpleTricks 08-09-2013 02:18 AM

Quote:

Originally Posted by itlb (Post 5006080)
vi is a text editor, if you don't know how to use it I recommend using nano.
To disable selinux you will need to make sure SELINUX=disabled is in /etc/selinux/config. You will need to reboot for changes to take effect

Im not that good w linux can you help me know what are the steps i should do ti disable this using nano?

itlb 08-09-2013 02:38 AM

First ensure you are the root user:

su - root

enter root password.

Instead of:

vi /etc/selinux/config

run:

nano /etc/selinux/config

you should be able to figure out how nano works but if you have issues: http://www.debianadmin.com/nano-editor-tutorials.html

in the /etc/selinux/config file you should see a line starting with "SELINUX=", make sure that "SELINUX=disabled"

save the file then run:

shutdown -r now

SimpleTricks 08-09-2013 02:45 AM

Quote:

Originally Posted by itlb (Post 5006095)
First ensure you are the root user:

su - root

enter root password.

Instead of:

vi /etc/selinux/config

run:

nano /etc/selinux/config

you should be able to figure out how nano works but if you have issues: http://www.debianadmin.com/nano-editor-tutorials.html

in the /etc/selinux/config file you should see a line starting with "SELINUX=", make sure that "SELINUX=disabled"

save the file then run:

shutdown -r now

Can this work on CentOS6?

druuna 08-09-2013 03:09 AM

Quote:

Originally Posted by SimpleTricks (Post 5006101)
Can this work on CentOS6?

Yes, it will.

Here's a CentOS 6 oriented link: Disable SELinux CentOS 6 (basically the same as the earlier provided answer).

BTW: The editor (nano or vi) is your choice and not of any influence of the outcome.


EDIT: I've asked a moderator to move this to a more appropriate location to give it the exposure it deserves.

SimpleTricks 08-09-2013 03:34 AM

Quote:

Originally Posted by druuna (Post 5006113)
Yes, it will.

Here's a CentOS 6 oriented link: Disable SELinux CentOS 6 (basically the same as the earlier provided answer).

BTW: The editor (nano or vi) is your choice and not of any influence of the outcome.


EDIT: I've asked a moderator to move this to a more appropriate location to give it the exposure it deserves.

Thanks druna, yes it was that guide ive read a while ago that made me to use vi, however it does not say what specific controls to do on how to change the targeted from disabled.

Sorry im really not that good with ssh.

druuna 08-09-2013 03:52 AM

Quote:

Originally Posted by SimpleTricks (Post 5006123)
... however it does not say what specific controls to do on how to change the targeted from disabled.

I'm not sure what you mean by the above.

Once you have changed SELINUX=enforcing to SELINUX=disabled in the /etc/selinux/config file and rebooted, you should be set.

Selinux is still installed, but will not bother you any more with its restrictions.

Quote:

Originally Posted by SimpleTricks
Sorry im really not that good with ssh.

I'm failing to see what ssh has got to do with this. ssh is a program that makes it possible to remotely log into machines and selinux is a security enhancement.

Please elaborate.


EDIT: I'm starting to wonder what your initial problem is and why you decided that disabling selinux would be the solution.

scratchyrat 08-09-2013 03:57 AM

Quote:

Originally Posted by SimpleTricks (Post 5006123)
Thanks druna, yes it was that guide ive read a while ago that made me to use vi, however it does not say what specific controls to do on how to change the targeted from disabled.

Sorry im really not that good with ssh.

The sestatus command should tell you if its enforcing or not.

You can then run setenforce 0 to turn it off and setenforce 1 to turn it back on. This is temporary so you can do this to see if it has any effect on the problem before turning it off permanently as detailed above.

I wouldn't recommend turning it off though. Why do you want to? Unless its an isolated/testing machine, really you should try to make it work, it has a purpose.

SimpleTricks 08-09-2013 04:49 AM

Quote:

Originally Posted by druuna (Post 5006130)
I'm not sure what you mean by the above.

Once you have changed SELINUX=enforcing to SELINUX=disabled in the /etc/selinux/config file and rebooted, you should be set.

Selinux is still installed, but will not bother you any more with its restrictions.

I'm failing to see what ssh has got to do with this. ssh is a program that makes it possible to remotely log into machines and selinux is a security enhancement.

Please elaborate.


EDIT: I'm starting to wonder what your initial problem is and why you decided that disabling selinux would be the solution.

Im doing it on my putty, or areyou referring to another platform where this should be done? By SSH, i meant linux, sorry.

Using the vi command, it just shows the codes on the SELINUX. The ones found here: http://www.how2centos.com/disable-selinux-centos-6/

The guide says: Change SELINUX=enforcing to Change SELINUX=disabled and layed out some codes below it however it does not say how you will actually change it, i mean should you just type a command, or edit the code and then what?

scratchyrat 08-09-2013 05:32 AM

Quote:

Originally Posted by SimpleTricks (Post 5006150)
The guide says: Change SELINUX=disabled to Change SELINUX=disabled and layed out some codes below it however it does not say how you will actually change it, i mean should you just type a command, or edit the code and then what?

Change it to say SELINUX=disabled instead of SELINUX=disabled, then save that. That is what will change it. SELinux reads that file for its configuration.

Run the command sestatus as this will actually tell you if SELinux is enabled and what state is is in.

druuna 08-09-2013 05:42 AM

Quote:

Originally Posted by SimpleTricks (Post 5006150)
Im doing it on my putty, or areyou referring to another platform where this should be done? By SSH, i meant linux, sorry.

I assume you are working on a Windows machine and use putty to log into a Linux machine. This shouldn't be related to your selinux problem.

Quote:

Using the vi command, it just shows the codes on the SELINUX. The ones found here: http://www.how2centos.com/disable-selinux-centos-6/

The guide says: Change SELINUX=enforcing to Change SELINUX=disabled and layed out some codes below it however it does not say how you will actually change it, i mean should you just type a command, or edit the code and then what?
Ok, it seems your Linux knowledge is limited.

Before I answer the above question I do have to ask one myself: Why do you need to change the selinux setting? Are you running into a specific problem and decided that disabling it would be the best choice? We might come up with a better solution if you tell us what the actual problem was that made you (or someone else) think that selinux should be disabled.

About changing the /etc/selinux/config file:

1) Using putty log into the machine that needs to be changed.
2) Make sure you are the root user (id -un <- should show root)
2a) If you are not the root user use the following to do so: su - You will be asked the root password.

I could explain how to do this using vi, but I'm going to use sed instead (less chance of something going wrong):

3) Use the following to change enforcing into disabled:
Code:

sed -i.bak 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
The above sed command makes a backup of the original file (just in case).

You can check /etc/selinux/config, using vi or cat, to see if the entry is changed. If that is the case: Reboot.

sbrown1038 05-01-2018 07:41 AM

Permissive setting
 
I just want to add, albeit 5 years later, that there is also a 'permissive' setting that can be used instead of 'disabled'. Using the permissive setting resolved the problem I was having with Drupal telling me that a directory was not writable.

Steve

AwesomeMachine 05-05-2018 03:58 AM

I just want to add that '/usr/sbin/setenforce 0' works without rebooting.


All times are GMT -5. The time now is 05:57 AM.