Updated: 28 September 2026 · Applies to: AlmaLinux 9 / Rocky Linux 9
semanage manages SELinux settings such as file contexts and allowed ports. On AlmaLinux 9 / Rocky Linux 9 it is in the policycoreutils-python-utils package, which minimal installations do not include.
- Find the package (optional):
dnf provides '*/semanage' - Install it:
dnf install policycoreutils-python-utils - Use it, for example to let MongoDB use a custom port:
semanage port -a -t mongod_port_t -p tcp 27018
Useful commands
semanage port -l | grep http # ports allowed for web servers semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/app/uploads(/.*)?" restorecon -Rv /var/www/app/uploads semanage boolean -l | grep httpd # on/off switches for Apache/Nginx
The package also installs audit2allow and audit2why, which explain denials from the audit log.
Common examples
semanage port -a -t http_port_t -p tcp 8080 # let Apache/Nginx listen on 8080 semanage port -m -t http_port_t -p tcp 8443 # -m if the port is already assigned to another type semanage port -d -t http_port_t -p tcp 8080 # remove it again
After a change, restart the service. If it is still blocked, run ausearch -m avc -ts recent | audit2why to see the reason.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
