DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
VGSources
Blog

SELinux Explained: How to Configure It on a Linux VPS

A practical SELinux VPS guide covering distribution prerequisites, permissive testing, labels, ports, booleans, AVC diagnosis, custom modules, and persistent enforcing mode.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SELinux is a mandatory access-control layer that can stop a compromised or misconfigured service from reading files, opening ports, or using capabilities outside its policy—even when ordinary Linux permissions would allow the action. On a VPS, the safe configuration path is to verify image support, install the distribution’s policy and audit tools, inspect the current mode, test in permissive mode, correct labels, ports, and booleans, investigate AVC denials, and then return to enforcing mode permanently.

Do not treat permissive mode as a production fix. It records policy violations without blocking them. Keep a controlled maintenance path, such as the provider console, while changing security policy so an unexpected denial does not strand the server.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What SELinux controls on a VPS

Traditional Linux access checks are discretionary: a file owner or administrator can change permissions, and a process running with sufficient identity may gain broad access. SELinux adds mandatory access control (MAC). The loaded policy evaluates the process domain, the security label on a file or directory, the label on a network port, and the requested operation. A process can therefore be denied even when its Unix owner and mode bits appear correct.

SELinux policy is made of rules describing which confined domains may perform actions on labeled objects. Web, database, SSH, backup, and other services normally run in distinct domains. If an attacker gains control of one service, confinement can limit what that process can read or execute elsewhere on the host.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

SELinux does not replace ordinary ownership, mode bits, firewall rules, patching, or least-privilege service accounts. Those controls still apply. SELinux supplies an additional policy decision that is evaluated against labeled objects and the service’s domain.

SELinux modes: enforcing, permissive, and disabled

Mode What happens Appropriate use Persistence
Enforcing The loaded policy is applied and denied operations are blocked and logged. Normal production operation; Red Hat documentation calls this the default and recommended mode. Set in /etc/selinux/config or the distribution-equivalent file, then reboot.
Permissive The policy is loaded and denials are logged, but the requested operations are allowed. Short, controlled testing, policy development, and troubleshooting. setenforce 0 changes the running system only until reboot unless configuration is also changed.
Disabled The policy is not loaded and persistent SELinux labeling is not maintained. Only when the image or kernel cannot support SELinux, or during a deliberate migration plan. Requires the persistent configuration setting and usually a reboot.

Use getenforce for the current mode and sestatus for a fuller report, including policy type, configuration state, and relevant status details. A host can also have a single domain made permissive while the rest remains enforcing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

semanage permissive -a {{domain_name}}

That exception is narrower than making the whole host permissive, but Red Hat warns that permissive domains can still compromise security. Remove the exception after testing with semanage permissive -d {{domain_name}}.

Check VPS support before changing policy

Start by identifying the provider image, distribution release, kernel, and filesystem layout. Red Hat-family distributions, Fedora, Debian, and Ubuntu do not ship identical SELinux packages, defaults, or troubleshooting utilities. A provider may also customize its image.

  • Confirm that the image advertises SELinux support and that its kernel includes SELinux.
  • Confirm that the filesystems used for the operating system and service data support SELinux extended attributes. Debian’s SELinux documentation specifically lists kernel and filesystem capability as prerequisites.
  • Record how you will access the VPS if SSH is affected: provider console, serial console, or an out-of-band recovery path.
  • Inventory services and nonstandard paths before enforcement: SSH, web and application servers, databases, backup agents, deployment runners, monitoring, cron jobs, mounted volumes, and containers.
  • Take a restorable snapshot or backup and record current service configuration.

If the image cannot load SELinux policy, do not copy commands from a different distribution and assume they will work. Select an image and kernel that support SELinux, or keep the host’s existing security model and document that SELinux is unavailable.

Install the policy, management, and audit tooling

Use the official repository for the exact distribution and release. Install three categories of packages: the distribution’s SELinux policy (including the policy type used by the image), management utilities such as semanage, and audit/troubleshooting tools that provide ausearch, audit2why, and related commands. Package names and package-manager commands differ between Red Hat-family, Fedora, Debian, and Ubuntu images, so follow that release’s documentation rather than using a universal package line.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

After installation, verify that the commands are present:

  • command -v sestatus getenforce semanage restorecon ausearch audit2why
  • sestatus

If a command is missing, install the package that owns it from the image’s official repositories. Do not download policy modules from an untrusted site or mix modules built for another distribution release.

Inspect the current state and existing denials

Before enabling enforcement, capture a baseline. Run sestatus and getenforce, note whether a policy is loaded, and determine whether AVC (Access Vector Cache) denials already exist. Audit records normally appear in /var/log/audit/audit.log; some systems also expose them through the journal.

Use ausearch to filter SELinux records and include the time window in your notes. For example, after a controlled test, inspect recent AVC events with the distribution-supported ausearch options for today or the relevant boot. Preserve the complete event, not just the final “denied” line: source domain, target type, class, requested permission, executable, and path determine the correct fix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An AVC is evidence of a policy decision, not automatically proof that a new allow rule is needed. The denial may be caused by an incorrect label, an unrecognized port, an unset boolean, or a service running in the wrong domain.

Stage the change in permissive mode

On a running system, setenforce 0 switches to permissive mode immediately. It does not change the persistent boot setting and it does not survive a reboot.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
  1. Record the baseline. Save sestatus, getenforce, mounted filesystems, listening ports, enabled services, and current AVC records.
  2. Enter permissive mode for the test window. Run setenforce 0, then confirm with getenforce. Keep the window as short as practical.
  3. Exercise real workflows. Log in through SSH, deploy the application, serve representative web requests, connect to the database, run backup and restore checks, execute scheduled jobs, and test monitoring. A service that is idle during the test will not generate the evidence needed to configure its policy.
  4. Collect AVCs. Use ausearch and the audit log or journal to associate each denial with the action that produced it. Record timestamps and the exact service operation.
  5. Classify each denial. Check labels, ports, booleans, and service-domain transitions before considering a custom rule.
  6. Repeat after every correction. A changed label or boolean can expose the next genuine problem, so rerun the same workflow and review only new events.

Permissive mode is useful because it reveals attempted operations without interrupting testing. It is not equivalent to a secure configuration: unauthorized operations are allowed while it is active.

Fix labels, ports, and booleans before writing policy

Apply persistent file-context rules

Services commonly fail because data was moved to a nonstandard directory. SELinux uses file labels, not just path names. Add a persistent file-context mapping with semanage fcontext, then apply the mapping with restorecon:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

semanage fcontext -a -t {{selinux_type}} "{{path_regex}}"
restorecon -Rv {{path}}

Use the type appropriate for the service and a regular expression that covers the intended directory. The -a rule is persistent; changing a label manually without a file-context rule can be undone by a relabel or restore operation. Verify the resulting labels with the platform’s standard file-label display command before retesting.

Label nonstandard network ports

A daemon moved from its conventional port may be denied even though the process is otherwise correctly confined. Inspect existing port assignments and add the port to the service’s SELinux port type:

semanage port -a -t {{port_type}} -p tcp {{port_number}}

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Use the protocol that the service actually listens on, and check for an existing assignment before adding one. A port label grants SELinux permission to the appropriate domain; it does not open a firewall or make the service listen. Configure the VPS firewall separately.

Check and set booleans deliberately

Booleans are policy switches for common, documented service behaviors. List available settings and their current values with:

semanage boolean -l

When a service’s documented behavior is controlled by a boolean, enable it persistently with the distribution-supported setsebool -P {{boolean_name}} on form, then retest. Record why the boolean is required and avoid enabling broad options merely to silence a denial.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Diagnose an AVC denial without disabling SELinux

Use a repeatable sequence rather than reacting to the first command that produces output.

  1. Reproduce one failure. Trigger the specific request, job, or deployment step once, noting the timestamp.
  2. Read the complete AVC. Identify the source domain, target type, object class, requested permission, executable, and path. Confirm that the event belongs to the service you tested.
  3. Ask for an explanation. Pass the relevant audit record to audit2why using the distribution’s documented invocation. It can indicate a likely labeling error, a boolean, a wrong domain, or a missing policy rule.
  4. Check alternatives. Inspect file contexts, port contexts, available booleans, and the service’s expected domain transition. SELinuxProject’s troubleshooting sequence recommends these checks before policy generation.
  5. Correct the smallest configuration issue. Apply a file-context rule and restorecon, assign the correct port type, enable the narrowly relevant boolean, or fix the service launch context.
  6. Retest in enforcing mode. Once the cause is addressed, use setenforce 1 and repeat the workflow. A clean test should produce no unexplained AVCs.

Several superficially similar denials can have different causes. For example, a web process reading an application directory may need a file label, while binding a new listener may need a port label. Treat the object and requested permission in the AVC as the starting point.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a custom local policy module is justified

Some applications genuinely perform an operation not covered by the shipped policy. Only after labels, ports, booleans, and service-domain transitions have been checked should you consider a local module.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
  1. Reproduce the specific required operation and collect only the related AVC records.
  2. Use the distribution’s policy-development tools to generate a candidate module from that narrow evidence.
  3. Review every requested permission and remove rules unrelated to the documented application behavior. Check whether the generated rule grants access to an overly broad path, object class, or domain.
  4. Install the reviewed module with semodule using the release’s documented syntax.
  5. Test the application in enforcing mode, inspect new AVCs, and document the business reason, source package, review date, and removal procedure.

Red Hat explicitly advises that audit2allow should not be the first response to an SELinux denial. Blindly converting every denial into allow rules can hide a compromised process, preserve a bad label, or grant more access than the application needs. A local module should represent a verified requirement, not an automatic bypass.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Return to enforcing mode and make it survive reboot

When testing is complete, switch the running host back with:

setenforce 1
getenforce

This runtime change is immediate but temporary. Set the persistent configuration to SELINUX=enforcing in /etc/selinux/config, or use the equivalent configuration mechanism documented by the distribution. Reboot during a planned maintenance window, then verify both the effective and configured state with getenforce and sestatus.

Do not assume that a successful setenforce 1 proves the next boot will enforce policy. Only the persistent setting controls startup. After reboot, exercise the critical SSH, web, database, backup, and deployment paths again and review AVC records for unexplained events.

Why a web server is blocked: a decision guide

Symptom First checks Likely corrective action
Web process cannot read files in a new document root Inspect the directory’s SELinux label and compare it with a working document root. Add the correct persistent file-context rule with semanage fcontext, then run restorecon.
Service starts on its usual port but fails on a custom port Inspect SELinux port assignments and the AVC’s target port. Map the port to the service’s expected port type with semanage port; configure the firewall separately.
Uploads, network connections, or another optional feature are denied List booleans and read the AVC explanation with audit2why. Enable only the documented boolean that matches the required behavior, persistently.
Service runs under an unexpected domain Check the executable, launch method, transition records, and source domain in the AVC. Correct the service unit, executable labeling, or transition; do not immediately add an allow rule.
Denial remains after labels, ports, and booleans are correct Reproduce once, isolate the exact permission, and review the candidate policy. Consider a narrow, reviewed local module and document why the shipped policy is insufficient.

Operational checklist for a production VPS

  • Verify the provider image, kernel, filesystems, policy type, and installed management and audit tools.
  • Keep a console or recovery path available before changing enforcement.
  • Use permissive mode only for a defined test window and record when it starts and ends.
  • Exercise every production service path, including backups and scheduled jobs, while collecting AVC evidence.
  • Fix file contexts, port contexts, booleans, and service transitions before considering custom policy.
  • Review generated rules line by line; never install an unexamined stream of audit2allow output.
  • Return to enforcing mode, set SELINUX=enforcing persistently, reboot, and verify.
  • Document custom labels, booleans, modules, rationale, owner, and rollback steps so future administrators can maintain the policy.

Key takeaways

For a supported Linux VPS, enforcing mode should be the destination. Permissive mode helps you observe and develop policy but leaves operations unblocked. Most application failures are resolved by correcting labels, assigning nonstandard ports, enabling a narrowly relevant boolean, or fixing the service domain. AVC records and audit2why provide the evidence; a custom module is the last, reviewed option when the application truly needs a permission outside the shipped policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.