semanage
Linux

‘semanage command’ Not Found Error in CentOS/RHEL

You are running the semanage command and you get the output bellow :

[root@Linux ~]# semanage fcontext --at samba_share_t "/finance(/.*)?"
-bash: semanage: command not found

Clearly the command is not installed, So you try to install it by running the command bellow, but there is no package with this name :

[root@kubernetes ~]# dnf install semanage
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.evoluso.com
 * extras: mirrors.evoluso.com
 * updates: mirror.librelabucm.org
No package semanage available.
Error: Nothing to do

In this article we will learn how to find the package provides semanage command on CentOS/RHEL.

What is semanage ?

It allows administrators to manage SELinux policies by configuring various settings, such as SELinux policy modules, file contexts, user mappings, and port mappings. This utility provides a high level of control over SELinux policies and is useful for managing complex security policies.

Find the package provides SELinux command

To install necessary packages for getting this tools run the following command :

[root@Linux ~]# yum provides /usr/sbin/semanage
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.evoluso.com
 * extras: mirrors.evoluso.com
 * updates: mirror.librelabucm.org
policycoreutils-python-2.5-34.el7.x86_64 : SELinux policy core python utilities
Repo        : base
Matched from:
Filename    : /usr/sbin/semanage

As you can see we need to install policycoreutils-python to to use our command :

[root@Linux ~]# yum install policycoreutils-python
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.evoluso.com
 * extras: mirrors.evoluso.com
 * updates: mirror.librelabucm.org
Resolving Dependencies
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                                       Arch                                          Version                                            Repository                                   Size
==================================================================================================================================================================================================================
Installing:
 policycoreutils-python                                        x86_64                                        2.5-34.el7                                         base                                        457 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package

Total download size: 457 k
Installed size: 1.2 M
Is this ok [y/d/N]:

Once the package is installed, you can use the command, and that’s it.

[root@Linux ~]# semanage --help
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

You might also like

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *