Saturday, July 27, 2013

Learning RPM Commands



RPM (Red Hat Package Manager) is a 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.

Some Facts about RPM (RedHat Package Manager)
  1. RPM is free and released under GPL (General Public License).
  2. RPM keeps the information of all the installed packages under /var/lib/rpm database.
  3. RPM is the only way to install packages under Linux systems, if you have installed packages using source code, then rpm won’t manage it.
  4. 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
  1. Install : It is used to install any RPM package.
  2. Remove : It is used to erase, remove or un-install any RPM package.
  3. Upgrade : It is used to update the existing RPM package.
  4. Verify : It is used to query about different RPM packages.
  5. Query : It is used for the verification of any RPM package.
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@vikasserver]# 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@vikasserver]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm

Preparing...                ########################################### [100%]
   1:pidgin                 ########################################### [100%]
RPM command and options
  1. -i : install a package
  2. -v : verbose for a nicer display
  3. -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@vikasserver]# 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
  1. -q : Query a package
  2. -p : List capabilities this package provides.
  3. -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@vikasserver]# 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@vikasserver]# 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@vikasserver]# 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 All Installed RPM Packages
Type the following command to print the all the names of installed packages on your Linux system.
[root@vikasserver]# 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@vikasserver]# 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@vikasserver]# 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@vikasserver]# 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@vikasserver]# rpm -qf /usr/bin/htpasswd

httpd-tools-2.2.15-15.el6.centos.1.i686
13. 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@vikasserver]# 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
14. 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@vikasserver]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm

S.5....T.  c /etc/httpd/conf.d/sqlbuddy.conf
15. 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@vikasserver]# cd /var/lib
[root@vikasserver]# rm __db*
[root@vikasserver]# rpm --rebuilddb
[root@vikasserver]# rpmdb_verify Packages

Saturday, June 29, 2013

SQL: Delete, Truncate and Drop

DELETE

The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire.
SQL> SELECT COUNT(*) FROM emp;

  COUNT(*)
----------
        14

SQL> DELETE FROM emp WHERE job = 'Lead Engineer';

4 rows deleted.

SQL> COMMIT;

Commit complete.

SQL> SELECT COUNT(*) FROM emp;

  COUNT(*)
----------
        10

TRUNCATE

TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUNCATE is faster and doesn't use as much undo space as a DELETE.
SQL> TRUNCATE TABLE emp;

Table truncated.

SQL> SELECT COUNT(*) FROM emp;

  COUNT(*)
----------
         0

DROP

The DROP command removes a table from the database. All the tables' rows, indexes and privileges will also be removed. No DML triggers will be fired. The operation cannot be rolled back.
SQL> DROP TABLE emp;

Table dropped.

SQL> SELECT * FROM emp;
SELECT * FROM emp
              *
ERROR at line 1:
ORA-00942: table or view does not exist

DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.

Note: We can not recover the table before Oracle 10g. But Oracle 10g provide the command to recover it by using the command (FLASHBACK)

Thursday, December 27, 2012

Learning GREP

GREP command is one of the most frequently used UNIX command stands for "Global Regular Expression Print” .GREP command in Unix operating system e.g. Linux, Solaris, BSD, Ubuntu or IBM AIX is used to search files with matching patterns, by using grep command in Unix you can search a file which contains a particular word or particular pattern.
 
Example 1
Finding relevant word and exclusion of irrelevant word is the most feature of grep command. Most of the time I look for Exception and Errors in log files and some time I know certain Exception I can ignore so I use grep -v option to exclude those Exceptions.
 
grep Exception logfile.txt | grep –v ERROR

This grep command example will search for word "Exception" in logfile.txt and print them but since we have piped out of first grep command to second grep command which will exclude all lines which match world "ERROR". To make this grep example more concrete let's see another example, here we have a file which contains three lines as shown below:
$ cat example.txt
UNIX operating system
UNIX and Linux operating system
Linux operating system

Now we want to search all lines in file example.txt which contains word UNIX but same time doesn't contain world Linux.
$ grep UNIX example.txt
UNIX operating system
UNIX and Linux operating system

Now to exclude all lines which contains Linux we will apply another grep command in this output with option -v to exclude matching word as shown in below grep command.
$ grep UNIX example.txt | grep -v Linux
UNIX operating system
Example 2

If you want to count of a particular word in log file you can use grep -c option to count the word. Below example of command will print how many times word "Error" has appeared in logfile.txt.
 
grep -c "Error" logfile.txt

If we apply this grep command on our example file to find how many lines contains word e.g. UNIX has occurred in the file :
$ grep -c UNIX example.txt
2
 
Example 3
 
Sometime we are not just interested on matching line but also on lines around matching lines particularly useful to see what happens before any Error or Exception. grep --context option allows us to print lines around matching pattern. Below example of grep command in UNIX will print 6 lines around matching line of word "successful" in logfile.txt
 
grep --context=6 successful logfile.txt
Show additional six lines after matching very useful to see what is around and to print whole message if it splits around multiple lines. You can also use command line option "C" instead of "--context" for example
 
grep -C 2 'hello'
Prints two lines of context around each matching line.
 
Example 4
 
egrep stands for extended grep and it is more powerful than grep command in Unix and allows more regular exception like you can use "|" option to search for either Error or Exception by executing just one command.
 
egrep 'Error|Exception' logfile.txt
 
Example 5
 
If you want to do case insensitive search than use -i option from grep command in UNIX. Grep -i will find occurrence of both Error, error and ERROR and quite useful to display any sort of Error from log file.
 
grep -i Error logfile
 
Example 6
 
Use grep -w command in UNIX if you find whole word instead of just pattern.
grep -w ERROR logfile
 Above grep command in UNIX searches only for instances of 'ERROR' that are entire words; it does not match `SysERROR'.
 For more control, use `\<' and `\>' to match the start and end of words. For example:
 grep 'ERROR>' *
 Searches only for words ending in 'ERROR', so it matches the word `SysERROR'.
 
Example 7
 
Another useful grep command line option is "grep -l" which display only the file names which matches the given pattern. Below command will only display file names which have ERROR?
 
grep -l ERROR *.log
grep -l 'main' *.java will list the names of all Java files in the current directory whose contents mention `main'.
 
Example 8
 
 If you want to see line number of matching lines you can use option "grep -n" below command will show on which lines Error has appeared.
grep -n ERROR log file.
 

Tuesday, December 25, 2012

Learning Agile

People often think the goal of testing should be to simply find all the bugs. Well, that’s not entirely realistic. Actually, it’s impossible.  Despite the title of “quality assurance” testers can never truly assure quality, nor can they be expected to find every bug. The real goal of testing should be to improve the software. This is a widely held view of testing in the Agile world. Agile is totally based on well known Agile Manifesto. Here is the summary of the fundamental principle of Agile Manifesto:

                                        Individuals and interactions over processes and tools
                             Working software over comprehensive documentation
                             Customer collaboration over contract negotiation
                             Responding to change over following a scheduled plan
 
In Agile functionality are released in smaller cycles, and work is performed in highly collaborative manner by self organizing teams that embrace and adapt changes to ensure that customers need are truely met. The Agile team adapt to the dynamic changing conditions by breaking a release into smaller short cycles of 1-6 weeks,each cycle is known as iteration or Sprint and is like a miniature software project. Agile methodology emphasizes real time communication preferably face to face. The most broadly acceptable techniques introduced by the agile process is to express product requirements in the form of user stories. Each user story has various fields including an actor, a goal or task they need to perform, an explanation of why it is needed and associated value and corresponding priority.
 
Let us define SCRUM, it is a project management methodology to facilitate agile software development and enable the creation of self organizing agile teams. A Scrum Master is like a traditional project manager in the sense in the sense that he/she oversees the centralization of team communication, requirement, schedules and projects. Unlike the traditional Project Manager ScrumMaster does not direct the team, because the Agile team is based on the philosophy of team member is commited to other team member and not the management authority.
Phases of Agile Project using SCRUM:
 
1. KickOff Meeting:  Everybody in the team  should review the product backlog (master list of requirements that the individual product owner has drafted in the form of user stories). The KickOff Meeting is more of an story writing workshop in which stories are selected and then decomposed into programmable task along with the time estimates for its completion.
 
2. SPRINT/Iteration Planning: Team collectively decides sprint goal and sprint backlog. The ScrumMaster role is to maintain the backlog list based on the team feedback and consensus and building personal commitment among the team members.
 
3. Scrum Meetings: The scrum meetings last usually less than 30 mins and the main objective of the meeting is to answer three questions: what have I accomplished since the last meeting,what am I working on and what are the future road blocks.
 
4. Final Acceptance Meeting: Presenting a demo to the customer/client what the team has accomplished.
 
5. Sprint Retero Meeting: Similar to the postmortem meeting of the traditional projects so that team gets together to what works well and what are the improvement area for the future projects.

Tuesday, December 18, 2012

Severity vs Priority


Severity

·         Severity refers to the Bug and how it affects the User’s interaction with the Application.

·         This is assigned by the Test Engineer

·         Severity is usually a static.

Types of Severity:

·         Critical-> (System Crash)

·         Major-> Impacts the main feature of the product

·         Medium-> Impact some feature of the product

·         Minor-> Minor mistake like spelling mistake

High Severity & Low Priority:  Suppose there is an application which generates some banking related reports weekly, monthly, quarterly & yearly by doing some calculations. In this application, there is a fault while calculating yearly report. This is a high severity fault but low priority because this fault can be fixed in the next release as a change request.

Priority

1.      Priority refers with respect to the project and how urgent it is to solve the Bug in the context of the work been done.
2.      Priority should be dynamic, to be revised and updated as the project progresses.
3.      The Priority of a bug should be set and modified in agreement by the project stakeholders based on the strategic and tactical decisions of the project. In most cases, this is done during a regular (daily, weekly, etc) meeting where they review and evaluate the open bugs in the system.

Types of Priority:
·         High
·         Medium
·         Low

High Priority & High Severity: A show stopper error which occurs on the basic functionality of the application(Eg. A site maintaining the student details, on saving record if it, doesn't allow to save the record then this is high priority and high severity bug)
High priority and Low Severity

·         Example 1

Suppose in a banking application there is one module ATM Facility. In that ATM facility when ever we are depositing/withdrawing money it is not showing any conformation message but actually at the back end it is happening properly with out any mistake, hence it is missing of an error message. In this case as it is happening properly so there is nothing wrong with the application but as end user is not getting any conformation message so he/she will be confused. So we can consider this issue as HIGH Priority but LOW Severity defects

·         Example 2:

The spell mistakes that happens on the cover page or heading or title of an application. 
 
Low Priority and Low Severity:

·         Any cosmetic or spell issues which is in a paragraph or in the report (Not on cover page, heading, title)