How to install/uninstall/upgrade rpm package with/without dependencies

I have already written an article with 15 practical examples on various rpm based commands which are used in real world of IT on a day to day basis.
Also do you know what every field of rpm name represents? This is one of the most trickiest interview questions asked many times
A RPM package abbreviated as Red Hat Package Manager refers to Red Hat package installed on Fedora, CentOS, OEL and all Red Hat source code derived OS.
 

Installing from the downloaded rpm package

Use -ivh switch along with rpm command as shown below

# cd /root/rpms
# rpm -ivh cvs-1.11.23-16.el6.i686.rpm
Preparing...                ########################################### [100%]
   1:cvs                    ########################################### [100%]

 

Installing directly from the package available on web.

But for this you need to have the proper link of the rpm you want to download or install

# rpm -ivh ftp://ftp.pbone.net/mirror/ftp.centos.org/6.5/os/i386/Packages/cvs-1.11.23-16.el6.i686.rpm
Retrieving ftp://ftp.pbone.net/mirror/ftp.centos.org/6.5/os/i386/Packages/cvs-1.11.23-16.el6.i686.rpm
warning: /var/tmp/rpm-tmp.z3VsTc: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:cvs ########################################### [100%]

 

Installing a package forcefully without dependencies

Use --force argument along with -ivh switch as shown below to install forcefully without dependencies

# rpm -ivh vsftpd-2.2.2-11.el6_4.1.i686.rpm --force
warning: vsftpd-2.2.2-11.el6_4.1.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

 

Upgrading a package

Use -Uvh switch along with rpm command

# rpm -q vsftpd
vsftpd-2.0.5-28.el5.i386
# rpm -Uvh vsftpd-2.2.2-11.el6_4.1.i686.rpm
warning: vsftpd-2.2.2-11.el6_4.1.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

 

Removing a package

You can uninstall a package using -e switch along with rpm command

NOTE:

Before removing a package make sure you get the complete name of the package using the below command
# rpm -qa | grep cvs
cvs-1.11.23-16.el6.i686
# rpm -e cvs-1.11.23-16.el6.i686

 

Removing a package without dependencies

Use an extra argument --nodeps along with rpm command to remove/uninstall a package without dependencies

# rpm -e vsftpd-2.2.2-11.el6_4.1.i686 --nodeps