In this article, I will to share way to how to fix the “semanage command not found” error in Centos or RHEL?

I was trying to use the semanage command to configure the Samba share with the correct boolean and security context values, to change the SELinux policy to allow access to the Samba share from a remote client on the RHEL 8 server. However I ran into the “semanage command not found” error.

The command code:

# semanage fcontext --at samba_share_t "/finance(/.*)?"

-bash: semanage: command not found
semanage command not found error in Centos

The error info shows: semanage command not found. Why?

Semanage is a Selinux administrative tool for configuring specific elements without any adjustments or reconfigurations of policy sources.

Semantic management includes mapping from Linux user names to Selinux user identities, as well as security contexts that map multiple objects such as interfaces, network ports, and so on.

I wanted to know how to fix the ” semanage command not found” error. But I couldn’t find the package that was providing the semanage command.

After some google research, I know that I need to use the option provided by yum to find packages that provide a query file named / USR / SBIN / semanage.

I will explain how to use the yum command to install the necessary packages to get the semanage command. You also can read this article to know how to use the yum command.

# yum provides /usr/sbin/semanage

Then to find the package that provides the query file. From the sample output above, you can see that we need to install  policycoreutils-python-utils-2.8-16.1.el8.noarch package can use the semanage command.

Use yum command to install policycoreutils-python-utils-2.8-16.1.el8.noarch package.

 #yum install policycoreutils-python-utils

When the installation of policycoreutils-python-utils package is completed, try running the semanage command again, and it will work well.

You can use the following command to get a man page about semanage commands, options, and usage.

# man semanage
# semanage --help