Skip to content

Instantly share code, notes, and snippets.

@etigui
Last active October 30, 2019 16:47
Show Gist options
  • Save etigui/503bd17faf9a8abb9a1af702b1049315 to your computer and use it in GitHub Desktop.
Save etigui/503bd17faf9a8abb9a1af702b1049315 to your computer and use it in GitHub Desktop.
Centos7: repare corupted/truncated/deleted file (from packages)

Centos7

If you got corupted/truncated/deleted file while updating/writing a bad commands, and as a result you cannot run service/app. You might be interested in this command to reinstall them:

rpm -Va --nodeps --nodigest --noscripts --nosignature --nofiledigest --nomode --nordev --nouser --nogroup --nomtime | grep '/lib64' | awk '/^S..../{system("rpm -qf "$2)}' | sort | uniq | xargs yum reinstall -y
  1. rpm
  • Verifying a package compare information about the installed files in the package with information about the files taken from the package metadata stored in the rpm database. Among other things, verifying compares the size, type, hash of each file.
  1. grep
  • Take only file located where you want to verify,
  1. awk
  • Get the package for the corresponding file to verify.
  1. sort/uniq
  • Sort and get unique package
  1. xargs
  • Reinstall the packages

Ref:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment