LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-09-2013, 02:07 AM   #1
SimpleTricks
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Rep: Reputation: Disabled
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?

Last edited by SimpleTricks; 08-09-2013 at 02:08 AM.
 
Old 08-09-2013, 02:13 AM   #2
itlb
LQ Newbie
 
Registered: Aug 2013
Distribution: Debian
Posts: 29

Rep: Reputation: Disabled
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
 
Old 08-09-2013, 02:18 AM   #3
SimpleTricks
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by itlb View Post
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?
 
Old 08-09-2013, 02:38 AM   #4
itlb
LQ Newbie
 
Registered: Aug 2013
Distribution: Debian
Posts: 29

Rep: Reputation: Disabled
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

Last edited by itlb; 08-09-2013 at 02:40 AM.
 
Old 08-09-2013, 02:45 AM   #5
SimpleTricks
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by itlb View Post
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?
 
Old 08-09-2013, 03:09 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by SimpleTricks View Post
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.

Last edited by druuna; 08-09-2013 at 03:11 AM.
 
Old 08-09-2013, 03:34 AM   #7
SimpleTricks
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
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.
 
Old 08-09-2013, 03:52 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by SimpleTricks View Post
... 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.

Last edited by druuna; 08-09-2013 at 03:54 AM.
 
Old 08-09-2013, 03:57 AM   #9
scratchyrat
LQ Newbie
 
Registered: May 2010
Location: United Kingdom
Distribution: Debian, Red Hat, AIX, Ubuntu, Fedora
Posts: 27

Rep: Reputation: 3
Quote:
Originally Posted by SimpleTricks View Post
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.
 
Old 08-09-2013, 04:49 AM   #10
SimpleTricks
LQ Newbie
 
Registered: Aug 2013
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
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?
 
Old 08-09-2013, 05:32 AM   #11
scratchyrat
LQ Newbie
 
Registered: May 2010
Location: United Kingdom
Distribution: Debian, Red Hat, AIX, Ubuntu, Fedora
Posts: 27

Rep: Reputation: 3
Quote:
Originally Posted by SimpleTricks View Post
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.
 
Old 08-09-2013, 05:42 AM   #12
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by SimpleTricks View Post
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.
 
Old 05-01-2018, 07:41 AM   #13
sbrown1038
LQ Newbie
 
Registered: Feb 2004
Location: New Windsor, New York, Hudson Valley
Distribution: Red Hat, Fedora Core, Linux Mint, CentOS
Posts: 12

Rep: Reputation: 0
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
 
Old 05-05-2018, 03:58 AM   #14
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable SELINUX on FC9 ZAMO Fedora 4 06-25-2008 05:06 AM
how to disable selinux? xpucto Fedora 2 06-08-2007 06:16 AM
disable selinux mrlucio79 Fedora 3 08-28-2006 01:49 PM
Disable selinux? lucktsm Fedora 2 07-11-2006 10:15 AM
disable selinux on ubuntu linuxmandrake Ubuntu 2 01-11-2006 05:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration