mohanraj-r
4/10/2017 - 10:16 PM

Utils for working with centos

Utils for working with centos

# list files from a rpm file on disk without extracting it 
# source: http://stackoverflow.com/a/18787544
rpmx(){
  rpm_file=$1
  rpm2cpio $rpm_file | cpio -idmv
  }
  
# uninstalling package with issues
# http://serverfault.com/a/613258
yum clean all && rpm --rebuilddb
package-cleanup --problems
yum erase foo
# if that fails (due to errors in scripts)
yum --setopt=tsflags=noscripts remove foo
# if that fails ..
rpm -e --noscripts 

# print metadata from a rpm file
# http://serverfault.com/a/414557
rpm -qip /path/file.rpm

# bunch of info about current sys - including hostname, kernel
hostnamectl

# centos version
rpm --query centos-release