Yum – Interview Questions

1. What is yum  ?
Answer: yum is yellow update manager which is a front end tool for package management.
All the rpm commands activity can be carried out using yum command in automated way.
Yum mechanism will automatically resolve the dependencies unlike rpm commands.

2. How to install packages using yum ?
Answer:yum install package_name


3.How to configure yum repository in Linux ?
Answer: createrepo -o <Package folder Path > .

4.How to update the package using yum ?
Answer:yum update package_ name

5.How to search the package in yum ?
Answer:yum search package_name

6.How to remove the package using yum ?
Answer:yum remove package_name

7.How to check the updates for yum repository ?
Answer:yum check-update


8.How to update the yum repo ?
Answer:yum update

9.How to get the package information using yum ?
Answer:yum info package_name

10.How to list the installed packages on Redhat linux using yum  command ?
Answer:yum list installed

11.How to know the particular files belongs to which package ?
Answer:yum provides file_path

12.How to list the enabled repositories ?
Answer: yum repolist

How to Setup YUM repositories From ISO CD-ROM Image

Creation of yum repositories is handled by a separate tool called createrepo, which generates the necessary XML metadata.

Step 1: Mount an ISO file

a) First you need to have the ISO CDROM image of the respective operating system.

b) Then you need to mount that iso image. Mounted devices are stored at: /mnt folder.

So lets create a directory named as “ISO” in /mnt folder. To create a directory use the below command:

   # mkdir -p /mnt/ISO

Once the directory is created then the path will look like /mnt/ISO

c) Now mount the iso image (filename.iso) using the below command:

 # mount -o loop filename.iso /mnt/ISO

 Then to install createrepo package, type the below command:

# yum install createrepo

 During this process if you get message as “createrepo command not found, then that package (createrepo) may not have been availoable on that system and so you need to first install it using the rpm -ivh command and the name of the createrepo-xxx.rpm pakage availabel on your ISO image/DVD.

 Step 2: Create a repository

You need to creat a folder for storing the repository data.
You can create the folder to any desired path but we prefer to create a directory named as “repo” in /mnt folder only for ease of understanding. Once the directory is created then the path will look like /mnt/repo

Use createrepo to generate the necessary XML metadata. Type the below command to do so:

# createrepo -o /mnt/repo .

Step 3: Create config file

a) You need to create a repo config file in /etc/yum.repos.d/ directory. Then add the below content in that file which shares the path where the ISO image has been mounted.

To create a file named as “file.repo” in /etc/yum.repos.d/ directory, type the below command:

# vi /etc/yum.repos.d/file.repo

Then add the below content in that file and then save & close the file:

 [My ISO Repository]
baseurl=file:///mnt/iso
enabled=1

 Step 4: Install the required package from ISO image using the “yum” command

# yum install <package name>

YUM

YUM stands for Yellow dog Updater, Modified because it is based on YUP, the Yellow dog Updater. Yellow Dog is a version of Linux for the Power Architecture hardware. YUP, and later YUM, were written by the Linux community as a way to maintain an RPM-based system.

Advantages of YUM

  1. Automatic resolution of software dependencies. If a package installation or upgrade request is made and requires the installation or upgrade of additional packages, YUM can list these dependencies and prompt the user to install or upgrade them.

2. Command-line and graphical versions. The command-line version can be run on a system with a minimal number of software packages. The graphical versions offer ease-of-use and a user-friendly graphical interface to software management.

3. Multiple software locations at one time. YUM can be configured to look for software packages in more than one location at a time. Ability to specify particular software versions or architectures. Software locations accessible by YUM can contain multiple versions of the same RPM package and different builds for different architectures such as one for i686 and one for x86_64. yum can easily check the appropriate version and download it.

RPM Package Management – Interview Questions

1. How to check the installed software(rpm’s) on Redhat Linux ?
Answer: rpm -qa package_name (or) rpm -qa |grep package_name*

2. How to install  specific software package using rpm command on Redhat Linux ?
Answer: rpm –ivh package_name 

3. How to remove the software package from on Redhat  Linux ?
Answer: rpm -ev package_name

4.How to upgrade the existing Redhat package using rpm command ?
Answer: rpm -Uvh package_name

5.How to display the list of installed software package’s files ?
Answer: rpm -ql package_name 

6. How to get the installed software information like package version and short description of package ?

Answer: rpm -qi package_name

7.How to find files belongs to which rpm package ?

Answer:rpm -qf file_location  

8.How to display list of configuration files for specific package ?

Answer:rpm -qc package_name

9.How to display a list of recently installed software ?

Answer:rpm -qa –last

10.How to get the list of dependencies for specific rpm file ?

Answer:rpm -qpR rpm_file

11.How to get the list of dependencies for specific package ?

Answer:rpm -qR package_name

12.How to remove the package without checking the dependencies on Redhat Linux ?
Answer:rpm -ev –nodeps package_name

RPM (RPM Package Manager)

rpm is a powerful Package Manager, which can be used to build, install, query, verify, update, and erase individual software packages. A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package. Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.

One of the following basic modes must be selected: Query, Verify, Signature Check, Install/Upgrade/Freshen, Uninstall, Initialize Database, Rebuild Database, Resign, Add Signature, Set Owners/Groups, Show Query tags, and Show Configuration.

Installing

To install a package, log in as root and type the following command at a shell prompt:

# rpm -Uvh foo-1.0-1.i 386.rpm

Where U-upgrade v-verbose h-hash

Package Already Installed

# rpm -ivh –replacepkgs foo-1.0-1.i 386.rpm

Conflicting Files

# rpm -ivh –replacefiles foo-1.0-1.i 386.rpm

Unresolved Dependency

RPM packages can, essentially, depend on other packages, which means that they require other packages to be installed to run properly. If you try to install a package which has an unresolved dependency, output similar to the following is displayed:

error: Failed dependencies:

bar.so.2 is needed by foo-1.0-1

Suggested resolutions:

bar-2.0.20-3.i386.rpm

Use below command

# rpm -ivh foo-1.0-1.i 386.rpm bar-2.0.20-3.i 386.rpm

If it does not suggest a package to resolve the dependency, you can try the –redhatprovides option to determine which package contains the required file. You need the rpm db-redhat package installed

to use this option.

   # rpm -q –redhatprovides bar.so .2

If the package that contains bar.so.2 is in the installed database from the rpm db-redhat package, the name of the package is displayed:

bar-2.0.20-3.i386.rpm

To force the installation anyway (which is not recommended since the package may not run correctly), use the –nodeps option.

Uninstalling

Uninstalling a package is just as simple as installing one. T ype the following command at a shell prompt:

     # rpm -e foo

You can encounter a dependency error when uninstalling a package if another installed package depends on the one you are trying to remove. For example:

error: Failed dependencies:

foo is needed by (installed) bar-2.0.20-3.i386.rpm

To cause RPM to ignore this error and uninstall the package anyway, which may break the package depending on it, use the –nodeps option.

Upgrading

Upgrading a package is similar to installing one. Type the following command at a shell prompt:

  # rpm -Uvh foo-2.0-1.i 386.rpm

To force RPM to upgrade anyway, use the –oldpackage option:

  # rpm -Uvh –oldpackage foo-1.0-1.i 386.rpm

Querying

Use the rpm -q command to query the database of installed packages. The rpm -q foo command displays the package name, version, and release number of the installed package foo

Instead of specifying the package name, use the following options with -q to specify the package(s) you want to query. These are called Package Selection Options.

-a queries all currently installed packages.

-f <file> queries the package which owns <file>. When specifying a file, you must specify the full path of the file (for example, /bin/ls).

-p <packagefile> queries the package <packagefile>.

There are a number of ways to specify what information to display about queried packages. The following options are used to select the type of information for which you are searching. These are called Information Query Options.

-i displays package information including name, description, release, size, build date, install date, vendor, and other miscellaneous information.

-l displays the list of files that the package contains.

-s displays the state of all the files in the package.

-d displays a list of files marked as documentation (man pages, info pages, READMEs, etc.).

-c displays a list of files marked as configuration files. These are the files you change after installation to adapt the package to your system (for example, sendm ail.cf, passwd, inittab, etc.).

For the options that display lists of files, add -v to the command to display the lists in a familiar ls –l format.

Verifying

The command rpm -V verifies a package. You can use any of the Package Verify Options listed for querying to specify the packages you wish to verify.

Linux Patch Process

This Procedure documents is standard method to  update RHEL from a base OS version dot release (ex  RHEL6) to a specific later dot release.

   * Upload RHEL iso image on the server.

    * Create file.repo file to the server in to /etc/yum.repos.d/

    * Add below lines to the file.repo

                        [RHEL6.9-Server]

                        name= RHEL 6.9 Server Repository

                        baseurl=file:///cdrom

                        enabled=1

                        gpgcheck=0

Complete the “dot release” updates:

    # mkdir -p /cdrom/iso

    * Mount iso on the server

     # mount -o loop <absolute path of iso image >  /cdrom/iso

    * Go to directory /cdrom/iso/Server in RHEL6  /cdrom/iso/Package in RHEL6

     Install createrepo rpm.

            # rpm -ivh <createrepo rpm name >

    # cd /cdrom

    # createrepo .

    # yum clean all

    # vi /etc/yum.conf

          o If the line “tsflags=repackage” does not exist under the [main] section, then add it without the quotes to enable rollback capability within yum

           # yum  –disablerepo=rhn-* check-update

          o This should result in updates from several “cdrom/iso” based repositories

          o If the patch list looks accurate, then run:

                # yum –disablerepo=rhn-* update

    * Once patching completes:

          # unmount /cdrom/iso

    * check /etc/grub.conf for latest kernel entry (default should be 0 for the installed kernel)

          # Reboot the target server

    * When the target server is available, Log back in

    * cat /etc/redhat-release and confirm that it references the correct dot release

    * cd /etc/yum.repos.d

    * yum clean all

How to create LVM Partition in Linux

How to create LVM Partition in Linux

Physical volume (PV):- PV is the partitions on hard disk, or hard disk itself. PV are the base of LVM structure and referred as physical volumes.

Volume Group (VG):- VG are the combined physical volume into a single pool of storage. Think it is as a group of PV.

Logical volume (LV):- LV is the actual partitions on system created from VG.

Follow below steps to create file systems in Linux machines:

  • fdisk -l command will list the current partitions.
  • Use following command to create PV from hard disk.

      #pvcreate [disk]

           If you have more than one partition to be configured as PV, you can list them as well

               #pvcreate [disk partition] [disk partition] [disk partition]

    Run below command to check physical volumes

      # pvs or pvdisplay

  • To create new volume using fdisk

fdisk /dev/sdx [Replace /dev/sdx with your hard disk mount point]

n [command to create new partition in fdisk prompt]

press enter [ accept default first cylinder ]

+200M [ Size of LVM, specify it at as per your need and availability of space ]

t [command to set the partition type]

6 [Number or our created partition, make sure here you specify current number.]

8e [Code to set partition type LVM]

w [command to save the change ]

  • To create Volume group

# vgcreate VGname pvname

           Run below command to check Volume groups

      # vgs or vgdisplay

  • We can create logical volume by giving the name of a new logical volume, its size, and the volume group it will live on.

# lvcreate -L size(GB/MB/No. of Blocks)-n LVname VGname

  • Create Directory to mount file system

# mkdir –p /NEWFS

  • Mount new FS

# mount /dev/vgname/lvname /NEWFS

  • To mount them permanently add new FS edit  /etc/fstab file

# vi /etc/fstab

eg.

/dev/newvg/newlv mountname fstype defaults 0 0

ABOUT US

Cipherfy, a leading IT and Financial solutions provider, has experienced IT consultants who provide expert insights to our clients to make better decisions. We blend technological expertise, industry best practices, client’s business model and strategies to achieve the optimum benefits of the IT and maximum ROI.