After a power outage, my CentOS server began having a problem where many of the system commands became corrupted. As a result I have been getting messages saying "cannot execute binary file" on critical commands such as rm or mv. Using the linux rescue cd I managed to replace a few of the files to get me back to a mostly working state, but I am still running into issues with lesser-critical commands such as sed or tar. Rather than find and replace each file that may be broken individually, I would like to just go ahead and completely replace or repair these system commands to their default state. I have tried running the upgrade process from my CentOS disc, but this only caused a problem with my initrd file and did not correct any issue with my system commands. Can anyone suggest where I can find a package to reinstall these files without having to reinstall CentOS?
As @Ency suggests:
rpm --verify --all
will show you everything that's changed.
However, I suggest installing "yum-verify" or if it's not already installed and then using something like:
yum verify --verify-filenames='*bin/*'
This is very similar to the "rpm --verify", but you can restrict it to certain directories and it defaults to not showing you configuration file changes.
The output doesn't really tell you what package something is from, so you'd need to use:
rpm -qf /full/path/to/file
yum provides /full/path/to/file
to see what package that file belongs to
Then you could use:
yum reinstall packagename
to reinstall the RPM even if it's the same version.
However, I recommend backing up the files you need (
/etc, `/var/, etc.) and reinstalling everything from scratch. From what you described I suspect you won't find all the problems hiding on the system.
1+1 But if the files became corrupt after a power failure it seems to indicate file system corruption. If reinstalling isn't an option it's probably a good idea to run fsck on the server's disk(s) before replacing the corrupt files. Mar 12, 2011 at 21:51
rpm --verifyhelp you? I mean something like
rpm --verify `rpm -qa`