Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

SELinux Configuration Change

Posted on July 21, 2016December 21, 2017 By David Kittell
clear
sudo cp /etc/selinux/config /etc/selinux/config.bk
sudo sed -i '/^#/d' /etc/selinux/config
sudo sed -i '/^$/d' /etc/selinux/config
	
SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2)
echo Current Status: $SELinuxStatus

clear
# SELinux - Enforcing
sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=enforcing|" /etc/selinux/config
SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2)
echo New Status: $SELinuxStatus
clear
# SELinux - Permissive
sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=permissive|" /etc/selinux/config
SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2)
echo New Status: $SELinuxStatus
clear
# SELinux - Disable
sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=disabled|" /etc/selinux/config
SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2)
echo New Status: $SELinuxStatus

A couple ways to do this, I like this method below most as it bundles some stuff above into a nice package.

clear
sudo cp /etc/selinux/config /etc/selinux/config.original
sudo sed -i '/^#/d' /etc/selinux/config
sudo sed -i '/^$/d' /etc/selinux/config
SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2)
echo "Current Status: $SELinuxStatus"
sudo sed -i "s|SELINUX=$SELinuxStatus|SELINUX=permissive|" /etc/selinux/config
SELinuxStatus=$(cat /etc/selinux/config | grep SELINUX=|cut -d'=' -f2)
echo "New Status: $SELinuxStatus"
sudo shutdown -r now

Reference: https://www.crypt.gen.nz/papers/how-to-disable-selinux/

Originally Posted on July 21, 2016
Last Updated on December 21, 2017
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

CentOS Code Fedora Red Hat UNIX UNIX Shell Scripts

Post navigation

Previous post
Next post

Related Posts

Windows 10 – Chocolatey Developer Setup

Posted on June 26, 2018October 7, 2020

# Install Chocolatey if not installed # Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’)) Write-Host "Installing VSCode…" choco install vscode -y Write-Host "Installing Slack…" choco install slack -y Write-Host "Installing Git…" choco install git -y Write-Host "Installing 7zip…" choco install 7zip -y # OPTIONAL…

Read More

PowerShell – List Sites with App Pool

Posted on November 10, 2015February 12, 2016

Import-Module WebAdministration clear $sites = @{Expression={$_.Name};Label="Site Name"}, ` @{Expression={$_.applicationPool};Label="Site App Pool";}, ` @{Expression={$_.PhysicalPath};Label="Site Physical Path";} dir IIS:\Sites | Format-Table $sites -AutoSize # List File Path for web.config files ForEach($item in (dir IIS:\Sites)) { write-host $item.Name $filePath = $item.PhysicalPath $fileName = "web.config" Get-ChildItem -Recurse -Force $filePath -ErrorAction SilentlyContinue | Where-Object {…

Read More

Classic ASP Send Email

Posted on March 3, 2014May 25, 2017

<% Set myMail=CreateObject("CDO.Message") if Request("subject") <> "" then myMail.Subject=Request("subject") else myMail.Subject="<Subject>" end if if Request("from") <> "" then myMail.From=Request("from") else myMail.From="<From Email Address>" end if if Request("To") <> "" then myMail.To=Request("To") else myMail.To="<To Email Address>" end if if Request("Cc") <> "" then myMail.CC=Request("Cc") else myMail.CC="<CC Email Address>" end if myMail.TextBody=…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes