How to install a package forcefully in Linux

Install a package forcefully in Linux

Before installing a package forcefully, first understand a situation where we need this force option.
Let me corrupt one command and show you how to install it's package forcefully.
First check the package of the command we are going to corrupt. Let say mount command.

# which mount
# rpm -qf /bin/mount


[root@linuxelearn Packages]# which mount
/bin/mount
[root@linuxelearn Packages]# rpm -qf /bin/mount
util-linux-ng-2.17.2-6.el6.x86_64
[root@linuxelearn Packages]#


Okey, so we know the package of mount let's copy other commands content over mount command. Let copy date commands contents over mount command.

#cp /bin/date /bin/mount


[root@linuxelearn Packages]# cp /bin/date /bin/mount
cp: overwrite `/bin/mount'? y
[root@linuxelearn Packages]#


Now when you run mount command it will show Date, that means it is corrupted.

[root@linuxelearn Packages]# mount
Tue Mar 14 22:59:43 IST 2017
[root@linuxelearn Packages]# date
Tue Mar 14 22:59:49 IST 2017
[root@linuxelearn Packages]#


So to fix the mount command we need to reinstall it's package, let's install the package and check whether mount command is fixed or not. Move to the folder where you kept the package and install it.

#rpm -ivh util-linux-ng...


[root@linuxelearn Packages]# rpm -ivh util-linux-ng-2.17.2-6.el6.x86_64.rpm
warning: util-linux-ng-2.17.2-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
            package util-linux-ng-2.17.2-6.el6.x86_64 is already installed
[root@linuxelearn Packages]#


It says the package already install, check by using mount command whether it is working fine.

[root@linuxelearn Packages]# mount
Tue Mar 14 23:03:41 IST 2017
[root@linuxelearn Packages]#


opps...! It isn't fixed yet, now in such to force the installation to be done, the syntax is

#rpm -ivh <package name> -- force
#rpm -ivh util-linux-ng...


[root@linuxelearn Packages]# rpm -ivh util-linux-ng-2.17.2-6.el6.x86_64.rpm --force
warning: util-linux-ng-2.17.2-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:util-linux-ng          ########################################### [100%]
[root@linuxelearn Packages]#


Okay then we have not only installed package successfully but we have also fixed the command. Congratulations.

Now we run the mount command check output.


[root@linuxelearn Packages]# mount
/dev/sda2 on / type ext4 (rw)
oproc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/RHEL_6.0 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
/dev/sdb on /media/XIAOMI type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
[root@linuxelearn Packages]#


This is step by step solution of install package forcefully.


I Hope You Enjoyed reading This articule…..

Post a Comment