An occasional outlet for my thoughts on life, technology, motorcycles, backpacking, kayaking, skydiving...

Friday, December 5, 2008

RPM One-liners

I prefer the apt package manager used by Debian based Linux distributions, but am forced to deal the Red Hat Enterprise Linux professionally. For that, I keep this list handy.

###############
## rpm tasks ##
###############

# Get a (sorted) list of install packages
rpm -qa|sort|less

# find out what version of samba-client is installed
rpm -qa samba-client

# Find out how a certain file got here
rpm -q --whatprovides `locate libmysqlclient.so | sed '1p;d'`
# or
rpm -q --whatprovides `which smbmount`

# Extract files from an rpm
mkdir tmp; cd tmp; rpm2cpio ../pkg.rpm | cpio -id

# import a public key to resolve error like:
# Warning: ...rpm: 3 DSA signature: NOKEY, key ID 5072e1f5
k=5072e1f5; gpg --recv-keys $k; gpg --export -a $k > /tmp/$k.asc; sudo rpm --import /tmp/$k.asc;
# and to verify and clean-up...
rpm -qa | sort | grep pubkey; rm /tmp/$k.asc

##################################
## yum based package management ##
##################################

# add Fedora epel repository to CentOS
wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-2.noarch.rpm
k=217521f6; gpg --recv-keys $k; gpg --export -a $k > /tmp/$k.asc; sudo rpm --import /tmp/$k.asc;
sudo yum install epel-release-5-2.noarch.rpm

# find out what versions of samba-client are are available
yum search samba-client

# install samba-client
yum install samba-client

# update an old version of samba-client
yum update samba-client

######################################
## up2date based package management ##
######################################

# Get help on using RPM repositories
up2date|less

# Get a list of all available packages
up2date --showall > /tmp/up2date.all.txt

# Install the package perl-DBD-MySQL from the repository
up2date -i perl-DBD-MySQL

No comments:

Post a Comment

Followers