semanage command not found Not able to apply SELinux context
Suddenly i saw an error bash: semanage command not found while i am applying fcontext to samba share. Oops i am not sure that what is the package missing to bring back semanage command. No need to worry we can simply get an required packages list from yum command.
Before trying yum actual command i just tried yum install semanage it doesn’t know what i was trying to install because there is no package name called semanage.
# semanage fcontext -a -t samba_share_t "/srv/shiny-server(/.*)?" bash: semanage: command not found
Verified whether SELinux is running or not using below command
# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28
Use below yum command to see which packages you have to install in order to get semanage command not found resolved
# yum whatprovides /usr/sbin/semanage Or # yum provides /usr/sbin/semanage Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.ventraip.net.au * epel: mirror.overthewire.com.au * extras: mirror.overthewire.com.au * updates: mirror.overthewire.com.au policycoreutils-python-2.5-8.el7.x86_64 : SELinux policy core python utilities Repo : base Matched from: Filename : /usr/sbin/semanage policycoreutils-python-2.5-9.el7.x86_64 : SELinux policy core python utilities Repo : updates Matched from: Filename : /usr/sbin/semanage policycoreutils-python-2.5-11.el7_3.x86_64 : SELinux policy core python utilities Repo : updates Matched from: Filename : /usr/sbin/semanage
Now install policycoreutils-python to bring back semanage command
semanage command not found will resolve install packages
# yum -y install policycoreutils-python Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.ventraip.net.au * epel: mirror.overthewire.com.au * extras: mirror.overthewire.com.au * updates: mirror.overthewire.com.au Resolving Dependencies --> Running transaction check ---> Package policycoreutils-python.x86_64 0:2.5-11.el7_3 will be installed --> Processing Dependency: setools-libs >= 3.3.8-1 for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libsemanage-python >= 2.5-5 for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Running transaction check ---> Package audit-libs-python.x86_64 0:2.6.5-3.el7_3.1 will be installed ---> Package checkpolicy.x86_64 0:2.5-4.el7 will be installed ---> Package libcgroup.x86_64 0:0.41-11.el7 will be installed ---> Package libsemanage-python.x86_64 0:2.5-5.1.el7_3 will be installed ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed ---> Package setools-libs.x86_64 0:3.3.8-1.1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================== Installing: policycoreutils-python x86_64 2.5-11.el7_3 updates 445 k Installing for dependencies: audit-libs-python x86_64 2.6.5-3.el7_3.1 updates 70 k checkpolicy x86_64 2.5-4.el7 base 290 k libcgroup x86_64 0.41-11.el7 base 65 k libsemanage-python x86_64 2.5-5.1.el7_3 updates 104 k python-IPy noarch 0.75-6.el7 base 32 k setools-libs x86_64 3.3.8-1.1.el7 base 612 k Transaction Summary =============================================================================================================================================== Install 1 Package (+6 Dependent packages) Total download size: 1.6 M Installed size: 5.1 M Downloading packages: (1/7): audit-libs-python-2.6.5-3.el7_3.1.x86_64.rpm | 70 kB 00:00:00 (2/7): libcgroup-0.41-11.el7.x86_64.rpm | 65 kB 00:00:00 (3/7): libsemanage-python-2.5-5.1.el7_3.x86_64.rpm | 104 kB 00:00:00 (4/7): policycoreutils-python-2.5-11.el7_3.x86_64.rpm | 445 kB 00:00:00 (5/7): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00 (6/7): setools-libs-3.3.8-1.1.el7.x86_64.rpm | 612 kB 00:00:00 (7/7): checkpolicy-2.5-4.el7.x86_64.rpm | 290 kB 00:00:00 ----------------------------------------------------------------------------------------------------------------------------------------------- Total 6.3 MB/s | 1.6 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : setools-libs-3.3.8-1.1.el7.x86_64 1/7 Installing : checkpolicy-2.5-4.el7.x86_64 2/7 Installing : libcgroup-0.41-11.el7.x86_64 3/7 Installing : python-IPy-0.75-6.el7.noarch 4/7 Installing : libsemanage-python-2.5-5.1.el7_3.x86_64 5/7 Installing : audit-libs-python-2.6.5-3.el7_3.1.x86_64 6/7 Installing : policycoreutils-python-2.5-11.el7_3.x86_64 7/7 Verifying : audit-libs-python-2.6.5-3.el7_3.1.x86_64 1/7 Verifying : libsemanage-python-2.5-5.1.el7_3.x86_64 2/7 Verifying : python-IPy-0.75-6.el7.noarch 3/7 Verifying : libcgroup-0.41-11.el7.x86_64 4/7 Verifying : policycoreutils-python-2.5-11.el7_3.x86_64 5/7 Verifying : checkpolicy-2.5-4.el7.x86_64 6/7 Verifying : setools-libs-3.3.8-1.1.el7.x86_64 7/7 Installed: policycoreutils-python.x86_64 0:2.5-11.el7_3 Dependency Installed: audit-libs-python.x86_64 0:2.6.5-3.el7_3.1 checkpolicy.x86_64 0:2.5-4.el7 libcgroup.x86_64 0:0.41-11.el7 libsemanage-python.x86_64 0:2.5-5.1.el7_3 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-1.1.el7 Complete!
That’s it now try to run semanage command will work like charm.!! SELinux Guide semanage command not found resolved.
Related Articles
Install KVM Hypervisor in RHEL 7 / Centos 7
Thanks for your wonderful Support and Encouragement