CentOS – semanage command not found error – The fix is here!

Updated on September 3, 2017

Question: I was trying to setup Apache web server on a different port other than port 80. For instance, on port 81, but the httpd daemon refused to start on port 81 and thrown an error message as “httpd already running”. Though, I verified that the port is changed  from 80 to 81 in httpd.conf file, still I could not get httpd to listen on port 81. After googling for few mins, I understood that SELINUX was not allowing the service to listen on a different port. Also, I got the below command that shows the list of accepted ports in SELINUX for httpd.

semanage port -l|grep http

Here’s my problem – semanage, command not found error in CentOS machine. I tried to install ‘semanage’ via yum, but couldn’t find any such package. Can you please tell me which package will have semanage command?

selinux

Solution:

Here are the steps.

How to find which package provides ‘semanage’ command using yum

# yum provides /usr/sbin/semanage

(or)

# yum whatprovides /usr/sbin/semanage

Sample output:

policycoreutils-1.33.12-14.13.el5.x86_64 : SELinux policy core utilities.
Repo : base
Matched from:
Filename : /usr/sbin/semanage

policycoreutils-1.33.12-14.13.el5.x86_64 : SELinux policy core utilities.
Repo : centos
Matched from:
Filename : /usr/sbin/semanage

Install policycoreutils-python package for ‘semanage’ command.

# yum -y install policycoreutils-python
..............................
Installed:
policycoreutils-1.33.12-14.13.el5.x86_64

Now, you’ll find ‘semanage‘ command.

# semanage port -l|grep http

If you need to add port 81 to the list of allowed ports for http, then below is the command.

# semanage port -a -t http_port_t -p tcp 81

Was this article helpful?

Related Articles

Comments Leave a Comment

Leave a Comment