How to Fix ‘semanage command’ Not Found Error on Rocky Linux

This tutorial intends to teach you How to Fix the ‘semanage command’ Not Found Error on Rocky Linux.

Semanage is a tool used to configure certain elements of SELinux policy without modifying or recompiling policy sources. This includes mapping Linux usernames to SELinux user identities and security context mappings for objects like network ports, interfaces, and hosts.

By default, SELinux only allows known services to bind to known ports. If we want to modify a service to use a non-default port we will need to modify the port type with the semanage command.

Fix ‘semanage command’ Not Found Error on Rocky Linux

We were trying to run a command by using the semanage command to make changes in the SELinux policy in our case. But we are faced with the following command error:

-bash: semanage: command not found

We found that there is a package that provides semanage command on Rocky Linux.

It is called dnf provides. It is an option to find out the package that provides the queried file called /usr/sbin/semanage.

At this point, we will show you how to use this package to install the necessary packages to get the semanage command.

Fix semanage error with “dnf provides” option on Rocky Linux

At this point, use the following command to see what packages you need to install to use your semanage command:

dnf provides /usr/sbin/semanage

In your output you will see:

Output
policycoreutils-python-utils-2.9-19.el8.noarch : SELinux policy core python
: utilities
Repo : baseos
Matched from:
Filename : /usr/sbin/semanage

At this point, you need to install the “policycoreutils-python-utils-2.9-19.el8.noarch“ package to use the semanage command:

dnf install policycoreutils-python-utils

When your installation is completed, try running the semanage command again and it will work!

Also, you can use the following commands to get more help with semanage command:

# man semanage
OR
# semanage --help
Output
usage: semanage [-h]
{import,export,login,user,port,ibpkey,ibendport,interface,module,node,fcontext,boolean,permissive,dontaudit}
…
semanage is used to configure certain elements of SELinux policy with-out
requiring modification to or recompilation from policy source.
positional arguments:

{import,export,login,user,port,ibpkey,ibendport,interface,module,node,fcontext,boolean,permissive,dontaudit}
import Import local customizations
export Output local customizations
login Manage login mappings between linux users and SELinux
confined users
user Manage SELinux confined users (Roles and levels for an
SELinux user)

port Manage network port type definitions
ibpkey Manage infiniband ibpkey type definitions
ibendport Manage infiniband end port type definitions
interface Manage network interface type definitions
module Manage SELinux policy modules
node Manage network node type definitions
fcontext Manage file context mapping definitions
boolean Manage booleans to selectively enable functionality
permissive Manage process type enforcement mode
dontaudit Disable/Enable dontaudit rules in policy

optional arguments:
-h, --help show this help message and exit
...

That’s it, you are done.

Conclusion

At this point, you learn to Fix the ‘semanage command’ Not Found Error on Rocky Linux.

Hope you enjoy it.

Also, we are pleased that you subscribe to us on Facebook and Twitter.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular