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…..

Networking related Linux Basic commands

Networking related Linux commands

Networking:
It is a connection between two or more machines to communicate with each other.

The basic requirements for networking are:
  • NIC (Network interface Controller or Card)
  • Media
  • Topology
  • Protocol
  • IP Addresses

How to create a new partition using fdisk unix commands in linux and unix.

MANAGING PARTITIONS

What is partition?
Partitioning is a means to divide a single hard drive into many logical drives. A partition is a contiguous set of block on a drive that are treated as an independent disk. A partition table is an index that relates sections of the hard drive to partitions.
This tutorial shows you how to actually partition your hard drive with the fdisk utility. Linux allows only 4 primary partitions. You can have a much larger number of logical partitions by sub-dividing one of the primary partitions. Only one of the primary partitions can be sub-divided.

How to Change Permission of Files and Directories in Unix/Linux

Unix / Linux File and Directories Permissions:

File Ownership is very important component of Unix that provide a secure method for storing files. Every File In Linux/Unix has three following attributes.

How many types of files are there in Linux/Unix and what are they?

File types In Linux/Unix

This is because Linux considers every thing as a file. When ever you start working on Linux/Unix box you have to deal with different file types(linux/unix) to effectively manage them

File Hierarchical Structure in Unix/Linux

File Hierarchical Structure in Linux

A file system is a logical collection of files on a partition or disk. A partition is a container for information and can span an entire hard drive if desired. Your hard drive can have various partitions which usually contains only one file system, such as one file system housing the / file system or another containing the /home file system.

How To Search a File In Linux /Unix or Use Of FIND Unix Command

How To Search a File In Linux /Unix

In Linux For Searching a file use Find Command.

Find command is used to find the files or directory’s path, it is exactly like the find option in Windows where you can search for a file.

How to Create Symbolic Links ( Soft Link or Hard Link) in Linux/Unix

How to Create Symbolic Links in Linux/Unix

Understanding shortcuts or links is a piece of cake. Most of us have already did that on Windows. Some of us have even tried creating links on Linux. A link in Linux is presented with an arrow -> that points to the target or original file. A link is nothing more than a way of matching two or more file names to the same set of files data.

How to use File Filters commands in Linux/Unix

File Filters commands in Linux/Unix

Linux flavors come with various powerful file filtering commands. Filter commands are used to filter the output so that the required things can easily be picked up. You can get fast results and which O/P you want just with the help of some simple commands.

Different file filter commands used in Linux or Unix are as follows: 

#wc
#less
#more
#head
#tail
#sort
#sed

1) Wc:



 The wc command used to see the no of characters in a file
$wc - c <file name>

[root@rahul ~]# wc –c file1


The wc command used to see the no of words in a file
 $wc -w <file name>

[root@rahul ~]# wc –w file1


The wc command used to see the no of lines in a file
 $wc -l <file name>

[root@rahul ~]# wc –l file1


The wc command used to see the no of lines, words, characters at a time
$wc <file name>

[root@rahul ~]# wc file1



2)Less :


The less command is used to see the output line wise or page wise
$less  <file name>

[root@rahul ~]# less /etc/passwd


Note : press Enter key to scroll down line by line
      Use d to go to the next page
      Use b to go to previous page
      Use / to search for a word in the file
Use v to go vi mode where you can edit the file and once you save it you will back to less command

      3)  More :

More is exactly same like less command
$more <file name>

[root@rahul ~]# more /etc/passwd


Note : press Enter key to scroll down line by line
      Use d to go to the next page
      Use b to go to previous page
      Use / to search for a word in the file
Use v to go vi mode where you can edit the file and once you save it you will back to more command

     4)      Head :

It is used to display the top 10 lines of the file
$head <file name>

[root@rahul ~]# head /etc/passwd


To Display the custom lines:
$head –n  <file name> (where n can be any number)

[root@rahul ~]# head -5 /etc/passwd


     5)      Tail :

It is used to display the last 10 lines of the file
$tail <file name>

[root@rahul ~]# tail /etc/passwd


        To Display the custom lines:
         $tail –n  <file name> (where n can be any number)

[root@rahul ~]# tail -5 /etc/passwd


    6)      Sort :

It is used to sort the output in numeric or alphabetic order
$sort <file name>

[root@rahul ~]# sort file1

Linux is opensource
Linux is opensource
Linux is opensource
Welcome to linux
Welcome to linux


To sort the file according to numbers:

$sort –d <file name> or $sort –h <file name>


[root@rahul ~]# sort –h file1

1.Welcome to linux
2.Linux is opensource
3.Linux is opensource
4.Welcome to linux
5.Linux is opensource


To remove the duplicate entries from the output

$sort –u <file name>


[root@rahul ~]# sort –u file1

Linux is opensource
Welcome to linux


     7)      Sed :

Sed stands for stream editor, which is used to search a word In the file and replace it with the word required to be in the output.

Note: it will only modify the output, but there will be no change in the original file

$sec  ‘s/searchfor/replacewith/g’ <file name>


[root@rahul ~]# sed ‘s/linux/unix/g’ file1

Linux is opensource
Welcome to unix
Linux is opensource



How to create file with size in Linux.


 To create file with size you can use following commands on different platform.

On Solaris, you can use this command:

$ mkfile file-size file-name


$ mkfile 10m output.dat


How to use VI or VIM in Linux/Unix ?


VIM EDITOR                            

·                                      VI -- Visual display editor
·                                      VIM -- Visual Display Editor Improved

Description

Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing programs.
This is command mode editor for files. Other editor in Linux are emacs, gedit.
Vi editor is most popular editor in Linux/Unix.

How to Create, Delete, Copy, Rename and Move Directories in Linux / Unix





Create(Make) Directories:

In Linux and Unix mkdir command is used to create a directories or sub-directories. Lets see Some mkdir commands.


[root@rahul ~]# mkdir emaildir


How to create, view and edit simple file in Linux/Uinx using Terminal

Linux / Unix operating system provide many command line tools and text editors for creating single or multiple text files. We can use gedit, vi/vim text editor. It is a terminal based text editor in Linux/ Unix Systems, available under the GPL.  There are many, many text editors available and it is designed to be easy to use. These are follows.

How to install Linux OS in Virtual Machine

  • Step By Step installation of Linux Os in Virtual Box
  • Install the VM virtual box then click on desktop icon and open it. It will show the following window.

How to add user in linux and unix

In Linux/Unix user is one who use the system. There can be at least one or more than one users in Linux/Unix at a time. Users on a system are identified by a username and a userid. The username is typically a user friendly string, such as your name, whereas the user id is a number. The user id numbers should be unique (one number per user).