Sunday, October 2, 2022

How to Fix ‘semanage command’ Not Found Error in AlmaLinux

In this tutorial, we intend to teach you How to Fix the ‘semanage command’ Not Found Error in AlmaLinux.

semanage is used to configure certain elements of SELinux policy without requiring modification to or recompilation from policy sources. This includes the mapping from Linux usernames to SELinux user identities (which controls the initial security context assigned to Linux users when they log in and bounds their authorized role set) as well as security context mappings for various kinds of objects, such as network ports, interfaces, and nodes (hosts) as well as the file context mapping.

Fix ‘semanage command’ Not Found Error in AlmaLinux

We are 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 in AlmaLinux.

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

In this guide, we intend to show you how to use this package to install the necessary packages to get the semanage command.

Fix ‘semanage command’ Not Found Error with “dnf provides” option

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
Last metadata expiration check: 86 days, 20:38:05 ago on Mon 23 May 2022 08:02:48 AM EDT.
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 in AlmaLinux.

Hope you enjoy it.

Also, you may be interested in these articles:

Install and Configure Elasticsearch on AlmaLinux 8

How To Configure Networking on AlmaLinux

Install and Configure OpenLiteSpeed on AlmaLinux 8

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles