View, install, and update packages using the RPM command in Linux

Home > Search > Linux commands
  by

View information about a package

The -qip or --query --install --print options can be used to view information about a package after it has been downloaded and before it has been installed

[root@server1 ~]# rpm -qip php-mbstring-version.rpm
[root@server1 ~]# rpm --query --install --print php-mbstring-version.rpm
Name        : php-mbstring-version
Version     : 1.0.4				   
Vendor      : CentOS 
Build Date  : Mon 01 Jun 2016
. . . 

 


Install a package

The -i or --install option to install a package. It can also be helpful to use the -v or --verbose and -h (show hash marks during install) options.

[root@server1 ~]# rpm -ivh php-mbstring-version.rpm

[root@server1 ~]# rpm -h --install --verbose php-mbstring-version.rpm
Updating /installing...
  1:php-mbstring-version  ####################### [100%]

 


Dependencies 

The -q or --query and -R or --requires options can be used to check if a package requires dependencies

[root@server1 ~]# rpm -qR php-mbstring-version.rpm
[root@server1 ~]# rpm --query --requires php-mbstring-version.rpm
dependency1
dependency2
dependency3

 


List installed files

The -ql or --query --list options can be used to view all of the files installed by the package

[root@server1 ~]# rpm -ql php-mbstring-version.rpm
[root@server1 ~]# rpm --query --list php-mbstring-version.rpm
php-mbstring-version
php-mbstring-file1
php-mbstring-file2
php-mbstring-file3

 


List all installed packages

The -qa or --query --all options to view all installed packages.

[root@server1 ~]# rpm -qa
[root@server1 ~]# rpm --query --all
php-mbstring-version
some-other-rpm
another-rpm

 


Recently installed packages

The -qa --last or --query --all --last options can be used to view recently installed packages

[root@server1 ~]# rpm -qa --last
[root@server1 ~]# rpm --query --all --last
php-mbstring-version
some-other-rpm
another-rpm

 


Update a package

The -U or --update option can be used to update a package

[root@server1 ~]# rpm -U package_name
[root@server1 ~]# rpm --upgrade package_name

 


Remove a package

The -e or --erase option can be used to remove a package, but does not remove the configuration files

[root@server1 ~]# rpm -e package_name
[root@server1 ~]# rpm --erase package_name

 


Import public keys

The --import option can be used to import the public keys being used by a package. In this example, the CentOS version 6 public keys are imported.

[root@server1 ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

Use the -qa or --query -all options can be used to verify the public keys have been imported

[root@server1 ~]# rpm -qa gpg-pubkey*
[root@server1 ~]# rpm --query --all gpg-pubkey*gpg-pubkey-12345678-9abcdefg

 

Use the -K or --checksig command to ensure the RPM package is OK.

[root@server1 ~]# rpm -K php-mbstring-version.rpm
[root@server1 ~]# rpm --checksig php-mbstring-version.rpm
php-mbstring-version.rpm: rsa sha1 (md5) pgp md5 OK

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments