restorecond: Will not restore a file with more than one hard link (/etc/resolv.conf) No such file or directory Error and Solution

The restorecond command is used in SELinux to restore the default SELinux security context for files and directories. If you encounter the error message “Will not restore a file with more than one hard link (/etc/resolv.conf) No such file or directory,” it means that the file /etc/resolv.conf has more than one hard link and restorecond is unable to restore its SELinux security context.

The hard link is a feature in Unix-like systems that allows multiple names to refer to the same file in the same file system. When a file has multiple hard links, it is not possible to set a different security context for each link.

To resolve this issue, you can try the following steps:

  1. Remove the extra hard links to the file:
find / -samefile /etc/resolv.conf -delete
  1. Restore the default SELinux security context for the file:
sudo restorecon /etc/resolv.conf
  1. Verify that the SELinux security context has been restored:
ls -Z /etc/resolv.conf

This should display the SELinux security context of the file, which should match the default SELinux security context for the file type.

Note that these steps assume that the /etc/resolv.conf file is correctly configured for your network settings. If you encounter any issues with your network connectivity after restoring the SELinux security context for /etc/resolv.conf, you may need to verify and update your network settings.

Leave a Comment