semanage command not found in CentOS 7 / 6 & RHEL 7 / 6 – Quick Fix

 Run semanage command to make a change in SELinux policy to allow us access to MongoDB on port 27017.

semanage port -a -t mongod_port_t -p tcp 27017

 

To my surprise, I got an error.

-bash: semanage: command not found

 

Note:

semanage is used to configure certain parts of SELinux policy without requiring modification to or recompilation from policy sources.

 

This small post will help you to install the necessary packages for getting semanage command. Let us see which package provides us ifconfig command using the YUM command.

yum whatprovides semanage

OR

yum provides *bin/semanage

 

Output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * extras: ftp.iitm.ac.in
 * updates: ftp.iitm.ac.in
base/7/x86_64/filelists_db                                                          | 6.7 MB  00:00:01
extras/7/x86_64/filelists_db                                                        | 528 kB  00:00:00
nginx/x86_64/filelists_db                                                           |  39 kB  00:00:00
updates/7/x86_64/filelists_db                                                       | 3.1 MB  00:00:00
policycoreutils-python-2.5-17.1.el7.x86_64 : SELinux policy core python utilities
Repo        : base
Matched from:
Filename    : /usr/sbin/semanage

 

From the above command output, you can see that policycoreutils-python package provides you semanage command. Now, install the policycoreutils-python package using the YUM command.

yum -y install policycoreutils-python

 

Once the installation is complete, run semanage to see whether it is available or not.

semanage port -a -t mongod_port_t -p tcp 27017

 

Now, you should not see any errors.

 

That’s All.

Was this answer helpful? 0 Users Found This Useful (0 Votes)