Tuesday, May 26, 2015

Delete the file and checking the error status - shellscript

This script uses command line arguments ($1 and  $?) and tail out the /root/error.txt file.

#!/bin/bash
#usage of command line arguments
rm $1 2>>/root/error.txt
if [ $? -eq 0 ]
then
echo " Success "
else
tail -1 /root/error.txt
fi

Sleep command - an example shell script

The following script clear screen and update the date every second. So it seems like the running digital clock.

#!/bin/bash
#running digital clock
while [ : ]
do
clear
date
sleep 1
done

Saturday, May 23, 2015

Simple one line script for checking the file existence.


A single line script / command to find the particular file exists or not.
# test -f a.txt && echo "File exists" || echo "File does not exist"

Simple shell script to find out the file exists or not

Script
#!/bin/bash
#name: filecheck.sh
#simple script to find out the file exists or not
if [ -f $1 ]
then
echo " $1 exists "
else
echo " $1 does not exist"
fi
Script usage: ./filecheck filename

Ubuntu 15.04 general features

Well, here we are. After six busy months, one beta and a bunch of minor changes, the final stable release of Ubuntu 15.04 is now ready for you to download.

The bug fixes, improvements in usability and a fresh serving of software updates add up to a somewhat substantive total, creating a release that feels more polished than ever.

Enough chatter. Let’s dive in and see what’s new in Ubuntu 15.04.

Ubuntu 15.04 – New Features

Systemd
‘You may notice a change in boot speed [because of Systemd]…’
The headline change in Ubuntu 15.04 is the introduction of the Systemd init system at boot-time.

This is the software that initializes (hence the name ‘init’) first when booting, and handles loading of the various modules and background processes that make much of a modern computer operating system do what it needs to.

Ubuntu previously used Upstart, its own custom-made Init system, at boot time. When Debian, the Linux distribution that Ubuntu is built upon, chose to adopt Systemd Ubuntu understandably fell in line.

Upstart is available in 15.04. It’s included as a fallback in GRUB and is used for controlling user sessions.

The merits (or lack thereof) of the switch are largely moot for the less technically minded. It is possible that some users will notice a slight change in boot speed depending on their configuration.

Unity 7.3
Locally Integrated Menus Are Now Default
Menus can now be set to ‘always show’
The Unity desktop environment used by default in Ubuntu 15.04 receives a handful of small refinements, most of which aim to either fix bugs or correct missteps in earlier versions.

For example, application menus can now be set to ‘Always Show’.

Yeah; you no longer have to push your mouse to the top of the screen to show the ‘File’, ‘Edit’, ‘Help’, etc menus — not if you don’t want to.

If you prefer having your applications menus available inside application windows use the toggle in System Settings > Appearance > Behaviour to set things up how you like.

These “locally integrated menus”, introduced in 14.10, also support the ‘Always Show’ feature and showing up on mouseover of unfocused windows.

Other improvements to Unity in Vivid Vervet include a fix for showing the overlay elements (HUD, Dash, etc) over fullscreen windows and small adjustments to the speed of login and logout animations.

Compiz 0.9.12
Powering the Unity desktop experience is Compiz, the tried-and-trusted window manager. In keeping with the rest of this release the changes it gets are modest and made up of bug fixes and compatibility with alternative desktop environments.

Ubuntu Linux Kernel 3.19
While not based on the latest version of the Linux Kernel Ubuntu 15.04 ships with a modified version of 3.19.3 one. Expect a few updates to the most recent 3.19.x patch releases shortly after release.

Application Updates
music-rhythmbox
New and updated apps feature, including Rhythmbox
You’ll also find updated versions many of Ubuntu’s default apps, including the latest Firefox web-browser and Thunderbird e-mail client, a new version of the Rhythmbox music player plus an entirely revamped Totem video player.

LibreOffice 4.4
Firefox 37
Thunderbird 31.6
Shotwell 0.20.2
Nautilus 3.14.2
Evince 3.14.2
Rhythmbox 3.1
Totem 3.14.1
GNOME Terminal 3.14
New Default Wallpaper
suru desktop wallpaper ubuntu vivid

The new Ubuntu 15.04 Wallpaper
Ubuntu’s default wallpaper choice is irrelevant to some, integral to others. Whatever side of the fence you sit on the new wallpaper is palatable enough. After all: first impressions count.

Expect to see this new design flash up in various ‘Ubuntu in the wild’ posts over the next six months!

Ubuntu Make
Having been formally introduced in last October’s release the ‘Ubuntu Developer Tools Center’ has undergone a number of changes for Vivid, including being renamed as the more memorable ‘Ubuntu Make’.

Ubuntu Make simplifies the process of installing a host of developer-focused tools, editors, libraries and software development kits including the Android SDK, IDEA, PyCharm, and the new Firefox Developer Edition.


Improvements to the way library managers behave now allows multiple system libraries to be run/used without conflict.

Linux interview questions - UCF3.2 special

  1. SSH connection refused –start the sshd service in client side
  2. Fsck usage
Q. Can I run fsck or e2fsck command when Linux file system is mounted? Do you advice to run fsck on a live file system? I am using Cent OS.
A. No. Do not run fsck on a live or mounted file system. fsck is used to check and optionally repair one or more Linux file systems. Running fsck on a mounted filesystem can usually result in disk / data corruption. So please do not do it. You have two choices
(a) Take down system to single user mode and unmout system
  1. Xfs port number 7100
  2. iptables –F flushing iptable rules
  3. Sendmail configuration file /etc/mail/sendmail.cf,
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
  1. No of hosts in class b
Address Class
Total # Of Bits For Network ID / Host ID
First Octet of IP Address
# Of Network ID Bits Used To Identify Class
Usable # Of Network ID Bits
Number of Possible Network IDs
# Of Host IDs Per Network ID
Class A
8 / 24
0xxx xxxx
1
8-1 = 7
27-2 = 126
224-2 = 16,277,214
Class B
16 / 16
10xx xxxx
2
16-2 = 14
214 = 16,384
216-2 = 65,534
Class C
24 / 8
110x xxxx
3
24-3 = 21
221 = 2,097,152
28-2 = 254


  1. What is the default permission for printer spooler service?
620 – read write – write- no perminssion
  1. File string delete – sed command
  2. What is the advantage of N+1 and one to one cluster?
The advantages of the N + 1 model are that the server load can be distributed to multiple nodes and that only one backup node is necessary to sustain all the possible node failures. Thus, the machine idle ratio is 1/N as opposed to 1/1, as is the case in a single asymmetric model.


Table 3-1  High Availability Model Advantages and Disadvantages
Model
Advantages
Disadvantages
Recommended User
Asymmetric
  • Simple Configuration
  • Backup node is 100 percent reserved
  • Machine resources are not fully utilized
A small service provider with plans to expand in the future.
Symmetric
  • Better use of system resources
  • Higher availability
  • Resource contention on backup node
  • Mirrored disks reduce disk write performance
A medium-sized service provider with no expansion plans on their backup systems in the near future.
N + 1
  • Load distribution
  • Easy expansion
  • Configuration complexity
A large service provider who requires distribution with no resource constraints.


  1. Block level for NAS (Network Attached SCSI) NAS is file level, SAN & DAS are block level
  2. Which cluster has the critical application? Application cluster
  3. What is the security protocol in SAN? LUN masking, zoning - In a storage area network (SAN), zoning is the allocation of resources for device load balancing and for selectively allowing access to data only to certain users.
  4. ls *.txt
  5. iostat which field the processing of time waiting ? 4 th field %iowait
  6. rpm to deb what is the package? alien rpm
  7. How to find send/receive of eth0 statistics? ethtool -S eth0, netstat -e
  8. What is not a routable protocol? Bootp, tcp, arp, rarp
  9. CD drive protocol – ATAPI (ATA Packet Interface)
  10. What is the single point of failure in cluster network?
A single point of failure (SPOF) is a part of a system that, if it fails, will stop the entire system from working.[1] They are undesirable in any system with a goal of high availability or reliability, be it a business practice, software application, or other industrial system.
Systems can be made robust by adding redundancy in all potential SPOFs. For instance, the owner of a small tree care company may only own one wood chipper. If the chipper breaks, he may be unable to complete his current job and may have to cancel future jobs until he can obtain a replacement.
Redundancy can be achieved at various levels. For instance, the owner of the tree care company may have spare parts ready for the repair of the wood chipper, in case it fails. At a higher level, he may have a second wood chipper that he can bring to the job site. Finally, at the highest level, he may have enough equipment available to completely replace everything at the work site in the case of multiple failures.
The assessment of a potential SPOF involves identifying the critical components of a complex system that would provoke a total systems failure in case of malfunction. Highly reliable systems should not rely on any such individual component.


  1. File which is accessible by any process? lsof,top,ps,all the above
  2. echo ENV_VAR what is the output? Same output
  3. iostat –x What is the output? Disk utilization in linux
  4. need to forward mails
.forward
  1. send mail alias file? /etc/aliasis
  2. What is the maxpv size in LVM? 2TB PE size 4MB
  3. Where we install platform in the cloud?Infrastructure or platform
  4. NTP expansion – Network Time Protocol (123-port no)
  5. Advantages of LVM2 (read & write and snapshot)
  6. Partition type of lvm – partition id 08e
  7. Authorize server usage in DNS – Master/ slave a &b
  8. Not included in DNS = restricted zero/ standard primary
  9. Not benefits in clouding = regulatory
  10. 3rd party / partners in for incident report
  11. Password reset is incident management true
  12. Commands to display vgs – vgs, vgdisplay
  13. How to run bourne again scripts ./scriptname.sh
  14. 2 types of zoning in storage – hard zone and soft zone
  15. Command to list route – route –n, netstat –r
  16. Merits of resizefs over ext2 – revision control
  17. One public network down what to do? Remedy
Additional questions:1) How to reduce the lvm, or How to reduce vg? lvreduce -L -200G /dev/vg0/lv0
2) What is the layer nfs supported? Application layer
3) What is the configuration file for squid? /etc/squid/squid.conf
4)Which class multicast is supported class D
5)What is the port no for NIS and NFS ? NFS 2049 NIS
6) How to exit the crontab with saving the command?esc:wq
7) crontab entries – min hours date month day command
8) DNS config file /var/named/chroot/etc
9) What is the use of DAS? Direct-attached storage (DAS) is computer storage that is directly attached to one computer or server and is not, without special support, directly accessible to other ones.
10) How to check the socket details? lscpu | grep 'socket' dmidecode


Other questions:

    1. How to disallow the query from DNS? RFC 1035 transaction signature
    2. How to delete package using dpkg? dpkg –r package name
    3. What is the reconfiguration file in RHEL? sys-unconfig
    4. Block size 8192 mount thru NFS? mount moonshot:/home /home -o rsize=8192,wsize=8192
    5. What is lsof option for subdirectories? lsof +D /directory
    6. xinetd or inetd file for RHEL
    7. default protocol for traceroute ICMP
    8. iostat –d? Only device statistics will be displayed.
    9. How to check sockets thru netstat? netstat -an or lsof -i.
    10. How to check non-listening sockets thru netstat? netstat -al
    11. Highly availability cluster in patching and upgrading?
    12. What is a valid FC topology? Switched fabric
    13. Protocol for TCP/IP? internet
    14. Service desk – for problem analysis and solution providing – False



  1. HBA expansion – Host Bus Adapter
  2. How to check the hops? Traceroute
  3. Incident management and problem management example.
  4. Lvmmaxpvsize=0 what does it mean?
  5. Hybrid cloud concept? A hybrid cloud is a cloud computing environment in which an organization provides and manages some resources in-house and has others provided externally.
  6. OSI & TCP how many layers? 7 & 4 layers respectively
  7. To insert above and below one line in the vi editor esc O/o (capital – above, small – below)
  8. To replace the character? r
  9. Priority – nice value -20 to 19 (lower number has higher priority, 0 is default priority)
  10. What are the ways to change the hostname in RHEL? hostname =hostname, /etc/sysconfig/hostname
  11. How to connect external DAS? The main protocols used for DAS connections are ATA, SATA, eSATA,[1] SCSI, SAS, and Fibre Channel.
  12. What are the things to be mentioned in iSCSI
  13. How to avoid bounced mail in sendmail?
  14. How to avoid mail queue in sendmail?
  15. How to extend lv in linux 2.6 kernel in lvm2 from 12 to 13 gb? lvextend –L +1G /dev/vg0/lv0
  16. 4Gb – 4096Mb
  17. HA cluster, I/O fencing two nodes failed? Fail-over - the operation of moving the service from one cluster node to another.
  18. How to avoid split brain? A good way of avoiding split brain conditions in most cases without having to resort to fencing is to configure redundant and independent cluster communications paths - so that loss of a single interface or path does not break communication between the nodes - that is the communications should not have a single point of failure (SPOF).
  19. VLAN advantage in SCSI?


  1. Split
split -b 22 newfile.txt new
Split the file newfile.txt into three separate files called newaa, newab and newac..., with each file containing 22 bytes of data.
split -l 300 file.txt new
Split the file newfile.txt into files beginning with the name new, each containing 300 lines of text.


  1. How to find the hard link of a particular file
— Test: -samefile NAME
File is a hard link to the same inode as NAME. If the ‘-L’ option is in effect, symbolic links to the same file as NAME points to are also matched.


— Test: -inum n
File has inode number n. The ‘+’ and ‘-’ qualifiers also work, though these are rarely useful. Much of the time it is easier to use ‘-samefile’ rather than this option.


  1. Apache directive
Apache directives are a set of rules which define how your server should run, number of clients that can access your server, etc. you can change them by editing the httpd.conf and related files to meet your requirements
  1. How to delete a character in vi editor – press x to delete
  2. Grep pattern – filtering a text from the file in general
  3. How to disconnect the users
skill -STOP -u vivek stop the user
skill -CONT -u vivek resume the halted user
  1. How to set numbers in vim esc: se nu
  2. Broadcast ip address – last address of the class
  3. How to add nfs wherever needed – nfs soft mount to be used
  4. Packages/modules for ldap – open ldap
  5. Mac address how many bit – 48 bits
  6. What is UTC – Universal co-ordinate time
  7. Vmstat syntax - vmstat [options] [delay [count]]
  8. iostat once 5 times - iostat 5
  9. Routing table – route –n, netstat –rn, ip route list
  10. Features of NAS
NAS operates at file system level -- usually either NFS or CIFS -- and serves whole files to users over the shared medium of the local-area network (LAN), while storage-area networks (SANs) deliver data at the block level (via Fibre Channel or iSCSI protocols) and are well suited to transactional storage such as database access.
  1. Iscsi protocol? – internet protocol, SAN protocol

How to: Compile Linux kernel 2.6

Step # 1 Get Latest Linux kernel code

Visit http://kernel.org/ and download the latest source code. File name would be linux-x.y.z.tar.bz2, where x.y.z is actual version number. For example file inux-2.6.25.tar.bz2 represents 2.6.25 kernel version. Use wget command to download kernel source code:
$ cd /tmp
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2

Note: Replace x.y.z with actual version number.

Step # 2 Extract tar (.tar.bz3) file

Type the following command:
# tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src
# cd /usr/src

Step # 3 Configure kernel

Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system. If gcc compiler and tools are not installed then use apt-get command under Debian Linux to install development tools.
# apt-get install gcc

Now you can start kernel configuration by typing any one of the command:

$ make menuconfig - Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
$ make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop
$ make gconfig - X windows (Gtk) based configuration tool, works best under Gnome Dekstop.
For example make menuconfig command launches following screen:
$ make menuconfig

You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.

Step # 4 Compile kernel

Start compiling to create a compressed kernel image, enter:
$ make
Start compiling to kernel modules:
$ make modules

Install kernel modules (become a root user, use su command):
$ su -
# make modules_install

Step # 5 Install kernel

So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
# make install

It will install three files into /boot directory as well as modification to your kernel grub configuration file:

System.map-2.6.25
config-2.6.25
vmlinuz-2.6.25
Step # 6: Create an initrd image

Type the following command at a shell prompt:
# cd /boot
# mkinitrd -o initrd.img-2.6.25 2.6.25

initrd images contains device driver which needed to load rest of the operating system later on. Not all computer requires initrd, but it is safe to create one.

Step # 7 Modify Grub configuration file - /boot/grub/menu.lst

Open file using vi:
# vi /boot/grub/menu.lst

title Debian GNU/Linux, kernel 2.6.25 Default
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hdb1 ro
initrd /boot/initrd.img-2.6.25
savedefault
boot
Remember to setup correct root=/dev/hdXX device. Save and close the file. If you think editing and writing all lines by hand is too much for you, try out update-grub command to update the lines for each kernel in /boot/grub/menu.lst file. Just type the command:
# update-grub
Neat. Huh?

Step # 8 : Reboot computer and boot into your new kernel

Just issue reboot command:

# reboot

Ksplice: Upgrade / Patch Your Linux Kernel Without Reboots

How Do I Install Ksplice?

First, you need to register with Ksplice. Type the following command to install rpm repo under RHEL 5:
# rpm -ivh https://www.ksplice.com/yum/uptrack/centos/ksplice-uptrack-release.noarch.rpm
To install Ksplice, enter:
# yum install uptrack
Edit /etc/uptrack/uptrack.conf, enter:
# vi /etc/uptrack/uptrack.conf
Update it as follows (input your access key):

[Auth]
accesskey = ADD-YOUR-ACCESS-KEY-HERE
[Network]
# Proxy to use when accessing the Uptrack server, of the form
# [protocol://][:port]
# The proxy must support making HTTPS connections. If this is unset,
# Uptrack will look for the https_proxy, HTTPS_PROXY, and http_proxy
# environment variables in that order, and then finally look for a
# proxy setting in the system-wide GConf database, if available.
https_proxy =
[Settings]
# Automatically install updates at boot time. If this is set, on
# reboot into the same kernel, Uptrack will re-install the same set of
# updates that were present before the reboot.
install_on_reboot = yes
# Options configuring the Uptrack cron job.
#
# GUI users will get all notices via the GUI and likely want to set
# the following cron options to "no".
# Cron job will install updates automatically
autoinstall = no
# Cron job will print a message when new updates are installed.
# This option is only relevant if autoinstall = yes
cron_output_install = no
# Cron job will print a message when new updates are available
cron_output_available = no
# Cron job will print a message when it encounters errors
cron_output_error = no
Save and close the file.

How Do I Apply Rebootless Kernel Updates?

You need to first download and apply updates via RHN:
# yum -y update
OR
# yum update kernel kernel-headers kernel-devel
Don't reboot the box, simply type the following command to apply hotfix:
# uptrack-upgrade
To see a list of updates that are currently installed, enter:
# uptrack-show -y

Sample Email Notification

You will get an email as follows when updates are available:

Fig.01: Ksplice Update Notification
Fig.01: Ksplice Update Notification


The web interface also provides information about your server and installed kernel updates:
Fig.02: Uptrack Web Interface
Fig.02: Uptrack Web Interface

Conclusion

The pricing is as follows:

Monthly price per system First 20 servers : $3.95
Beyond 20 servers: $2.95
Currently it is free for all Ubuntu users.
Ksplice is a pretty good and stable software. This is useful for Linux admin or business who can not accept downtime for patching. A few business comes in my mind:

Small shop, say 8-12 Linux based servers.
Pro-blogging or webmaster servers (a typical setup included one web server and one db server). Avoiding downtime means more ad revenue for webmasters.
Hosting companies - again avoiding downtime means good customer satisfactions and less work for sys admins. If you run VM based hosting (OpenVZ or XEN based vps) you can avoid downtime too.
Small cluster of Linux system, say 6 system - If cluster is using 80% of capacity and if one of node rebooted for kernel upgrade, load will up for rest of 5 systems. In such case, this service can help to keep load under control without rebooting the box. However, this is NOT very useful for very large Linux based cluster redundant load-balanced servers, routers, switches, firewalls etc. Since your cluster is so large that 4-5 servers failing makes no difference to the remaining nodes. In some cases it is possible to do geo load balancing too.
But I've HA Failover Solution In Place...

100% uptime depends upon lots of factors and and HA solution handles hardware or other failures very well. However, Ksplice service is not all about 100% uptime, it is about not rebooting your server for a Linux kernel upgrade. You can easily combine Ksplice with HA solution (such as keepalived+nginx reverse proxy) and try to get perfect five 9s. I highly recommend this service for small to medium size business or professional webmasters.

How do I upgrade my Linux kernel?

I would like to upgrade kernel without compiling from source code i.e. binary upgrade. How do I perform the actual upgrade of the kernel in Linux?

You need to compile kernel only if:
=> You need custom made kernel for specific task such as embedded kernel.

=> Apply third party security patches.

=> You need to apply specific patch to Linux

Upgrade of the kernel in Red Hat enterprise Linux version <= 4.x

If your system is registered with Red Hat Network (RHN), then you can use the up2date command as follows:
# up2date -f kernel

For SMP kernel (multi core or multiple CPU) use command:
# up2date -f kernel-smp

Upgrade of the kernel in Fedora Linux / CentOS / RHEL 5

Use yum command to upgrade kernel:
# yum update kernel

If you have downloaded RPM file use rpm command:
# rpm -ivh kernel*

Upgrade of the kernel in Debian or Ubuntu Linux

Use apt-get command. First find your kernel version:
$ uname -r

Next find available kernel images:
$ apt-cache search linux-image

Now install kernel by explicitly specifying version number:
# apt-get install linux-image-x.x.x-xx

OR

$ sudo apt-get install linux-image-x.x.x-xx

20 Practical Examples of RPM Commands in Linux

RPM (Red Hat Package Manager) is an default open source and most popular package management utility for Red Hat based systems like (RHEL, CentOS and Fedora). The tool allows system administrators and users to install, update, uninstall, query, verify and manage system software packages in Unix/Linux operating systems. The RPM formerly known as .rpm file, that includes compiled software programs and libraries needed by the packages. This utility only works with packages that built on .rpm format.

RPM Command Examples

20 Most Useful RPM Command Examples

This article provides some useful 20 RPM command examples that might be helpful to you. With the help of these rpm command you can managed to install, update, remove packages in your Linux systems.

Some Facts about RPM (RedHat Package Manager)

RPM is free and released under GPL (General Public License).
RPM keeps the information of all the installed packages under /var/lib/rpm database.
RPM is the only way to install packages under Linux systems, if you’ve installed packages using source code, then rpm won’t manage it.
RPM deals with .rpm files, which contains the actual information about the packages such as: what it is, from where it comes, dependencies info, version info etc.
There are five basic modes for RPM command

Install : It is used to install any RPM package.
Remove : It is used to erase, remove or un-install any RPM package.
Upgrade : It is used to update the existing RPM package.
Verify : It is used to query about different RPM packages.
Query : It is used for the verification of any RPM package.
Where to find RPM packages

Below is the list of rpm sites, where you can find and download all RPM packages.

http://rpmfind.net
http://www.redhat.com
http://freshrpms.net/
http://rpm.pbone.net/
Read Also :

20 YUM Command Examples in Linux
10 Wget Command Examples in Linux
30 Most Useful Linux Commands for System Administrators
Please remember you must be root user when installing packages in Linux, with the root privileges you can manage rpm commands with their appropriate options.

1. How to Check an RPM Signature Package

Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is OK. Use the following command with –checksig (check signature) option to check the signature of a package called pidgin.

[root@tecmint]# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm

pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK
2. How to Install an RPM Package

For installing an rpm software package, use the following command with -i option. For example, to install an rpm package called pidgin-2.7.9-5.el6.2.i686.rpm.

[root@tecmint]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm

Preparing... ########################################### [100%]
1:pidgin ########################################### [100%]
RPM command and options

-i : install a package
-v : verbose for a nicer display
-h: print hash marks as the package archive is unpacked.
3. How to check dependencies of RPM Package before Installing

Let’s say you would like to do a dependency check before installing or upgrading a package. For example, use the following command to check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package. It will display the list of dependencies of package.

[root@tecmint]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm

/usr/bin/python2.4
python >= 2.3
python(abi) = 2.4
python-crypto >= 2.0
python-psyco
python-twisted >= 2.0
python-zopeinterface
rpmlib(CompressedFileNames) = 2.6
RPM command and options

-q : Query a package
-p : List capabilities this package provides.
-R: List capabilities on which this package depends..
4. How to Install a RPM Package Without Dependencies

If you know that all needed packages are already installed and RPM is just being stupid, you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.

[root@tecmint]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm

Preparing... ########################################### [100%]
1:BitTorrent ########################################### [100%]
The above command forcefully install rpm package by ignoring dependencies errors, but if those dependency files are missing, then the program will not work at all, until you install them.

5. How to check an Installed RPM Package

Using -q option with package name, will show whether an rpm installed or not.

[root@tecmint]# rpm -q BitTorrent

BitTorrent-5.2.2-1.noarch
6. How to List all files of an installed RPM package

To view all the files of an installed rpm packages, use the -ql (query list) with rpm command.

[root@tecmint]# rpm -ql BitTorrent

/usr/bin/bittorrent
/usr/bin/bittorrent-console
/usr/bin/bittorrent-curses
/usr/bin/bittorrent-tracker
/usr/bin/changetracker-console
/usr/bin/launchmany-console
/usr/bin/launchmany-curses
/usr/bin/maketorrent
/usr/bin/maketorrent-console
/usr/bin/torrentinfo-console
7. How to List Recently Installed RPM Packages

Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.

[root@tecmint]# rpm -qa --last

BitTorrent-5.2.2-1.noarch Tue 04 Dec 2012 05:14:06 PM BDT
pidgin-2.7.9-5.el6.2.i686 Tue 04 Dec 2012 05:13:51 PM BDT
cyrus-sasl-devel-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:06 PM BDT
cyrus-sasl-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:05 PM BDT
cyrus-sasl-md5-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:04 PM BDT
cyrus-sasl-plain-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:03 PM BDT
8. How to List All Installed RPM Packages

Type the following command to print the all the names of installed packages on your Linux system.

[root@tecmint]# rpm -qa

initscripts-9.03.31-2.el6.centos.i686
polkit-desktop-policy-0.96-2.el6_0.1.noarch
thunderbird-17.0-1.el6.remi.i686
9. How to Upgrade a RPM Package

If we want to upgrade any RPM package “–U” (upgrade) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.

[root@tecmint]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
Preparing... ########################################### [100%]
1:nx ########################################### [100%]
10. How to Remove a RPM Package

To un-install an RPM package, for example we use the package name nx, not the original package name nx-3.5.0-2.el6.centos.i686.rpm. The -e (erase) option is used to remove package.

[root@tecmint]# rpm -evv nx
11. How to Remove an RPM Package Without Dependencies

The –nodeps (Do not check dependencies) option forcefully remove the rpm package from the system. But keep in mind removing particular package may break other working applications.

[root@tecmint]# rpm -ev --nodeps vsftpd
12. How to Query a file that belongs which RPM Package

Let’s say, you have list of files and you would like to find out which package belongs to these files. For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.

[root@tecmint]# rpm -qf /usr/bin/htpasswd

httpd-tools-2.2.15-15.el6.centos.1.i686
13. How to Query a Information of Installed RPM Package

Let’s say you have installed an rpm package and want to know the information about the package. The following -qi (query info) option will print the available information of the installed package.

[root@tecmint]# rpm -qi vsftpd

Name : vsftpd Relocations: (not relocatable)
Version : 2.2.2 Vendor: CentOS
Release : 11.el6 Build Date: Fri 22 Jun 2012 01:54:24 PM BDT
Install Date: Mon 17 Sep 2012 07:55:28 PM BDT Build Host: c6b8.bsys.dev.centos.org
Group : System Environment/Daemons Source RPM: vsftpd-2.2.2-11.el6.src.rpm
Size : 351932 License: GPLv2 with exceptions
Signature : RSA/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://vsftpd.beasts.org/
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
14. Get the Information of RPM Package Before Installing

You have download a package from the internet and want to know the information of a package before installing. For example, the following option -qip (query info package) will print the information of a package sqlbuddy.

[root@tecmint]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm

Name : sqlbuddy Relocations: (not relocatable)
Version : 1.3.3 Vendor: (none)
Release : 1 Build Date: Wed 02 Nov 2011 11:01:21 PM BDT
Install Date: (not installed) Build Host: rpm.bar.baz
Group : Applications/Internet Source RPM: sqlbuddy-1.3.3-1.src.rpm
Size : 1155804 License: MIT
Signature : (none)
Packager : Erik M Jacobs
URL : http://www.sqlbuddy.com/
Summary : SQL Buddy â Web based MySQL administration
Description :
SQLBuddy is a PHP script that allows for web-based MySQL administration.
15. How to Query documentation of Installed RPM Package

To get the list of available documentation of an installed package, use the following command with option -qdf (query document file) will display the manual pages related to vmstat package.

[root@tecmint]# rpm -qdf /usr/bin/vmstat

/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
/usr/share/doc/procps-3.2.8/TODO
16. How to Verify a RPM Package

Verifying a package compares information of installed files of the package against the rpm database. The -Vp (verify package) is used to verify a package.

[root@tecmint downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm

S.5....T. c /etc/httpd/conf.d/sqlbuddy.conf
17. How to Verify all RPM Packages

Type the following command to verify all the installed rpm packages.

[root@tecmint]# rpm -Va

S.5....T. c /etc/rc.d/rc.local
.......T. c /etc/dnsmasq.conf
.......T. /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf
S.5....T. c /etc/yum.conf
S.5....T. c /etc/yum.repos.d/epel.repo
18. How to Import an RPM GPG key

To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key.

[root@tecmint]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
19. How to List all Imported RPM GPG keys

To print all the imported GPG keys in your system, use the following command.

[root@tecmint]# rpm -qa gpg-pubkey*

gpg-pubkey-0608b895-4bd22942
gpg-pubkey-7fac5991-4615767f
gpg-pubkey-0f2672c8-4cd950ee
gpg-pubkey-c105b9de-4e0fd3a3
gpg-pubkey-00f97f56-467e318a
gpg-pubkey-6b8d79e6-3f49313d
gpg-pubkey-849c449f-4cb9df30
20. How To rebuild Corrupted RPM Database

Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at the time we need to rebuild the rpm database and restore it with the help of following command.

[root@tecmint]# cd /var/lib
[root@tecmint]# rm __db*
[root@tecmint]# rpm --rebuilddb

[root@tecmint]# rpmdb_verify Packages