restorecon, secon, setfiles, fixfiles, semodule command not found
restorecon: command not found
I saw the above error when I tried to save the IPtables rules on my linux server. restorecon command is used on linux servers to set security contexts. Also The below commands are missing on the server.
-bash: fixfiles: command not found
[root@server ~]# load_policy
-bash: /sbin/load_policy: No such file or directory
[root@server ~]# restorecon
-bash: restorecon: command not found
[root@server ~]# setfiles
-bash: setfiles: command not found
[root@server ~]# semodule_unpackage
-bash: semodule_unpackage: command not found
[root@server ~]# semodule_package
-bash: semodule_package: command not found
[root@server ~]# semodule_deps
-bash: semodule_deps: command not found
[root@server ~]# semodule_expand
-bash: semodule_expand: command not found
[root@server ~]# semodule_link
-bash: semodule_link: command not found
[root@server ~]# secon
-bash: secon: command not found
How to Install Secon, Semodule_deps, semodule_link, semodule_expand, semodule_package, semodule_unpackage, setfiles, restorecon, load_policy, fixfiles Command
You must have server root access to install the required package to fix the above command missing error.
1. Log into Linux server via SSH as ‘root’user
You can use software like ‘Putty’ to SSH to linux server.
2. Run the below command to check what package provides “restorecon”
Command : yum whatprovides restorecon
policycoreutils-2.1.12-5.23.amzn1.x86_64 : SELinux policy core utilities
Repo : amzn-main
Matched from:
Filename : /usr/sbin/restorecon
Yum provides or whatprovides command will show which package provides that command.
3. Type the command “rpm -qa | grep policycoreutils” to check whether the package is installed or not.
4. You must install the policycoreutils package to fix the error.
Install policycoreutils package using yum command like shown below
Command : yum install policycoreutils
Resolving Dependencies
–> Running transaction check
—> Package policycoreutils.x86_64 0:2.1.12-5.25.amzn1 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
policycoreutils x86_64 2.1.12-5.25.amzn1 amzn-updates 623 k
Transaction Summary
========================================================================================================================================================================
Install 1 Package
Total download size: 623 k
Installed size: 1.8 M
Is this ok [y/d/N]: y
Downloading packages:
policycoreutils-2.1.12-5.25.amzn1.x86_64.rpm | 623 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : policycoreutils-2.1.12-5.25.amzn1.x86_64 1/1
Verifying : policycoreutils-2.1.12-5.25.amzn1.x86_64 1/1
Installed:
policycoreutils.x86_64 0:2.1.12-5.25.amzn1
Complete!
[root@server /]#
Run the below command if policycoreutils package is already installed on the server and if you’re still facing the above error.
Command : yum reinstall policycoreutils
This will reinstall policycoreutils and that should fix the error.