January 9, 2007

Accessing Windows share from Linux command prompt

Three forms of invocation do not actually mount anything:

mount –h prints a help message;

mount –V prints a version string; and just

mount [-l] [-t type] lists all mounted file systems (of type type).

The option -l adds the (ext2, ext3 and XFS) labels in this listing. See below. Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else.

mount --bind olddir newdir After this call the same contents is accessible in two places.

This call attaches only (part of) a single filesystem, not possible submounts. The entire file hierarchy including submounts is attached a second place using

mount --rbind olddir newdir

Since Linux 2.5.1 it is possible to atomically move a subtree to another place. The call is

mount --move olddir newdir

How do I Access Windows share from Linux command prompt? I would like to be able to access shared folders on Windows machines from my Linux system.

There are two ways. Use command line tool called smbclient or you can mount windows shares the mount command. Another option is use GUI tools. Please refer previous articles about access windows share from Linux:

( a ) Mount Windows share using mount command

This is simple way to share data between windows and linux system. You would like to access MS-Windows share called //windowsserver/sharename by mounting to /mnt/win directory under Linux system. Type the following command (replace username, windows server name, share name and password with actual values):

For most types all the mount program has to do is issue a simple mount(2) system call, and no detailed knowledge of the filesystem type is required. For a few types however (like nfs, smbfs, ncpfs) ad hoc code is necessary. The nfs ad hoc code is built in, but smbfs and ncpfs have a separate mount program. In order to make it possible to treat all types in a uniform way, mount will execute the program /sbin/mount.TYPE (if that exists) when called with type TYPE. Since various versions of the smbmount program have different calling conventions, /sbin/mount.smb may have to be a shell script that sets up the desired call.

# mkdir -p /mnt/win

# mount -t smbfs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win

# cd /mnt/win

# ls –l

For the share //windowsserver/sharename to be automatically mounted at every system start (after reboot), insert an option in the file /etc/fstab:

# vi /etc/fstab

Append following line (written in a single line)

//windowserver/share /mnt/win smbfs auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15, credentials=/etc/sambapasswords 0 0

Next create the password file /etc/sambapasswords:
# vi /etc/sambapasswords
Now add following content:
username = winntuser
password = mypassword

Save and close the file. Make sure only root can access your file:
# chown 0.0 /etc/sambapasswords
# chmod 600 /etc/sambapasswords

January 8, 2007

Installing and Configuring Apache Tomcat web server

Step 1: download Java from Sun Java’ site and install Java and set the JAVA_HOME and PATH Variables properly by opening a DOS window and typing "java -version" and "javac -help". You should see a real result both times, not an error message about an unknown command.
  1. Select My Computer Icon on your Desktop, do right click and select the properties option.
  2. Select Advanced Tab and select Environment Variables, In the System Variables > Click New Button and Enter your JAVA_HOME=Path of the installed java on your machine Ex: c:\jdk 1.5 and Save it.
  3. Go to PATH in the System Variables, edit it and add PATH Variable PATH=*;C:\Jdk 1.5\bin;
  4. Open the Dos Prompt and type java –version [Enter], you will see the following output

O/P: java version "1.5.0_01"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)

Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
&
Javac

O/P: Usage: javac

where possible options include:

-g Generate all debugging info

-g:none Generate no debugging info

-g:{lines,vars,source} Generate only some debugging info

-nowarn Generate no warnings

-verbose Output messages about what the compiler is doing

-deprecation Output source locations where deprecated APIs are used

-classpath Specify where to find user class files

-cp Specify where to find user class files

-sourcepath Specify where to find input source files

-bootclasspath Override location of bootstrap class files

-extdirs Override location of installed extensions

-endorseddirs Override location of endorsed standards path

-d Specify where to place generated class files

-encoding Specify character encoding used by source files

-source Provide source compatibility with specified release

-target Generate class files for specific VM version

-version Version information

-help Print a synopsis of standard options

-X Print a synopsis of nonstandard options

-J Pass directly to the runtime system

Step 2:

  1. Go to http://jakarta.apache.org/builds and download and unpack the zip file for the latest version (4.1.24 or 5.0 as of last revision of this page).
  2. Start the Startup.bat from the tomcat installed or unzipped directory.

Jan 9, 2007 2:59:10 AM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on http-8080

Jan 9, 2007 2:59:10 AM org.apache.catalina.startup.Catalina load

INFO: Initialization processed in 2140 ms

Jan 9, 2007 2:59:10 AM org.apache.catalina.core.StandardService start

INFO: Starting service Catalina

Jan 9, 2007 2:59:10 AM org.apache.catalina.core.StandardEngine start

INFO: Starting Servlet Engine: Apache Tomcat/5.0.30

Jan 9, 2007 2:59:10 AM org.apache.catalina.core.StandardHost start

INFO: XML validation disabled

Jan 9, 2007 2:59:10 AM org.apache.catalina.core.StandardHost getDeployer

INFO: Create Host deployer for direct deployment ( non-jmx )

Jan 9, 2007 2:59:10 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:C:\Program Files\Apache Sof

tware Foundation\Tomcat 5.0\conf\Catalina\localhost\admin.xml

Jan 9, 2007 2:59:14 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:C:\Program Files\Apache Sof

tware Foundation\Tomcat 5.0\conf\Catalina\localhost\balancer.xml

Jan 9, 2007 2:59:15 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:C:\Program Files\Apache Sof

tware Foundation\Tomcat 5.0\conf\Catalina\localhost\manager.xml

Jan 9, 2007 2:59:16 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path /jsp-examples from URL file:C:\

Program Files\Apache Software Foundation\Tomcat 5.0\webapps\jsp-examples

Jan 9, 2007 2:59:17 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path from URL file:C:\Program Files

\Apache Software Foundation\Tomcat 5.0\webapps\ROOT

Jan 9, 2007 2:59:17 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path /servlets-examples from URL fil

e:C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\servlets-exampl

es

Jan 9, 2007 2:59:17 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path /tomcat-docs from URL file:C:\P

rogram Files\Apache Software Foundation\Tomcat 5.0\webapps\tomcat-docs

Jan 9, 2007 2:59:17 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path /webdav from URL file:C:\Progra

m Files\Apache Software Foundation\Tomcat 5.0\webapps\webdav

Jan 9, 2007 2:59:17 AM org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on http-8080

Jan 9, 2007 2:59:17 AM org.apache.jk.common.ChannelSocket init

INFO: JK2: ajp13 listening on /0.0.0.0:8009

Jan 9, 2007 2:59:17 AM org.apache.jk.server.JkMain start

INFO: Jk running ID=0 time=15/31 config=C:\Program Files\Apache Software Founda

tion\Tomcat 5.0\conf\jk2.properties

Jan 9, 2007 2:59:17 AM org.apache.catalina.startup.Catalina start

INFO: Server startup in 7672 ms

  1. Change the DOS memory settings. If you get an "Out of Environment Space" error message when you start the server, right-click on install_dir/bin/startup.bat, select Properties, select Memory, and change the Initial Environment entry from Auto to at least 2816. Repeat the process for install_dir/bin/shutdown.bat.
  2. Set the CATALINA_HOME variable. Optionally, set CATALINA_HOME to refer to the top-level Tomcat installation directory.

Set the CATALINA_HOME environment variable to refer to the top-level directory of the Apache Tomcat installation (e.g., C:\tomcat 5.0). This variable identifies the Tomcat installation directory to the server.

If you want to change the Port from 80 to 8080 just add the following steps

To change the port, edit install_dir/conf/server.xml and change the port attribute of the Connector element from 8080 to 80, yielding the result below. (Note that the exact class name of the Connector varies in different Tomcat versions. It was called HttpConnector in earlier versions of Tomcat 4.)

Connector

className="org.apache.coyote.tomcat4.CoyoteConnector"

port="80" ...

Enter the Following URL http://localhost:8080(port)/index.jsp in your web browser, Tomcat home page will be displayed.

January 3, 2007

What is the difference between an application server and a Web server?

Taking a big step back, a Web server serves pages for viewing in a Web browser, while an application server provides methods that client applications can call. A little more precisely, you can say that:

A Web server exclusively handles HTTP requests, whereas an application server serves business logic to application programs through any number of protocols.

Let's examine each in more detail.

The Web server
A Web server handles the HTTP protocol. When the Web server receives an HTTP request, it responds with an HTTP response, such as sending back an HTML page. To process a request, a Web server may respond with a static HTML page or image, send a redirect, or delegate the dynamic response generation to some other program such as CGI scripts, JSPs (JavaServer Pages), servlets, ASPs (Active Server Pages), server-side JavaScripts, or some other server-side technology. Whatever their purpose, such server-side programs generate a response, most often in HTML, for viewing in a Web browser.

Understand that a Web server's delegation model is fairly simple. When a request comes into the Web server, the Web server simply passes the request to the program best able to handle it. The Web server doesn't provide any functionality beyond simply providing an environment in which the server-side program can execute and pass back the generated responses. The server-side program usually provides for itself such functions as transaction processing, database connectivity, and messaging.

While a Web server may not itself support transactions or database connection pooling, it may employ various strategies for fault tolerance and scalability such as load balancing, caching, and clustering—features oftentimes erroneously assigned as features reserved only for application servers.

The application server
As for the application server, according to our definition, an application server exposes business logic to client applications through various protocols, possibly including HTTP. While a Web server mainly deals with sending HTML for display in a Web browser, an application server provides access to business logic for use by client application programs. The application program can use this logic just as it would call a method on an object (or a function in the procedural world).

Such application server clients can include GUIs (graphical user interface) running on a PC, a Web server, or even other application servers. The information traveling back and forth between an application server and its client is not restricted to simple display markup. Instead, the information is program logic. Since the logic takes the form of data and method calls and not static HTML, the client can employ the exposed business logic however it wants.

In most cases, the server exposes this business logic through a component API, such as the EJB (Enterprise JavaBean) component model found on J2EE (Java 2 Platform, Enterprise Edition) application servers. Moreover, the application server manages its own resources. Such gate-keeping duties include security, transaction processing, resource pooling, and messaging. Like a Web server, an application server may also employ various scalability and fault-tolerance techniques.

An example
As an example, consider an online store that provides real-time pricing and availability information. Most likely, the site will provide a form with which you can choose a product. When you submit your query, the site performs a lookup and returns the results embedded within an HTML page. The site may implement this functionality in numerous ways. I'll show you one scenario that doesn't use an application server and another that does. Seeing how these scenarios differ will help you to see the application server's function.

Scenario 1: Web server without an application server
In the first scenario, a Web server alone provides the online store's functionality. The Web server takes your request, then passes it to a server-side program able to handle the request. The server-side program looks up the pricing information from a database or a flat file. Once retrieved, the server-side program uses the information to formulate the HTML response, then the Web server sends it back to your Web browser.

To summarize, a Web server simply processes HTTP requests by responding with HTML pages.

Scenario 2: Web server with an application server
Scenario 2 resembles Scenario 1 in that the Web server still delegates the response generation to a script. However, you can now put the business logic for the pricing lookup onto an application server. With that change, instead of the script knowing how to look up the data and formulate a response, the script can simply call the application server's lookup service. The script can then use the service's result when the script generates its HTML response.

In this scenario, the application server serves the business logic for looking up a product's pricing information. That functionality doesn't say anything about display or how the client must use the information. Instead, the client and application server send data back and forth. When a client calls the application server's lookup service, the service simply looks up the information and returns it to the client.

By separating the pricing logic from the HTML response-generating code, the pricing logic becomes far more reusable between applications. A second client, such as a cash register, could also call the same service as a clerk checks out a customer. In contrast, in Scenario 1 the pricing lookup service is not reusable because the information is embedded within the HTML page.

To summarize, in Scenario 2's model, the Web server handles HTTP requests by replying with an HTML page while the application server serves application logic by processing pricing and availability requests.

Caveats
Recently, XML Web services have blurred the line between application servers and Web servers. By passing an XML payload to a Web server, the Web server can now process the data and respond much as application servers have in the past.

Additionally, most application servers also contain a Web server, meaning you can consider a Web server a subset of an application server. While application servers contain Web server functionality, developers rarely deploy application servers in that capacity. Instead, when needed, they often deploy standalone Web servers in tandem with application servers. Such a separation of functionality aids performance (simple Web requests won't impact application server performance), deployment configuration (dedicated Web servers, clustering, and so on), and allows for best-of-breed product selection.

January 2, 2007

Managing Files in Linux

File management tools include those for splitting, comparing, and compressing files, making backup archives, and tracking file revisions. Other management tools exist for determining the contents of a file, and for changing its timestamp.

Determining File Type and Format

When we speak of a file's type, we are referring to the kind of data it contains, which may include text, executable commands, or some other data; this data is organized in a particular way in the file, and this organization is called its format. For example, an image file might contain data in the JPEG image format, or a text file might contain unformatted text in the English language or text formatted in the TeX markup language.

The file tool analyzes files and indicates their type and -- if known -- the format of the data they contain. Supply the name of a file as an argument to file and it outputs the name of the file, followed by a description of its format and type.

$ file /usr/doc/HOWTO/example.gz [Enter]

/usr/doc/HOWTO/example.gz: gzip compressed data, deflated, original

Filename last modified: Sun Apr 26 02:51:48 1998, os: UNIX

Changing File Modification Time

Use touch to change a file's timestamp without modifying its contents. Give the name of the file to be changed as an argument. The default action is to change the timestamp to the current time.

To change the timestamp of file `example' to the current date and time, type:

$ touch example [ENTER]

To specify a timestamp other than the current system time, use the `-d' option, followed by the date and time that should be used enclosed in quote characters. You can specify just the date, just the time, or both.

To change the timestamp of file `example' to `17 May 1999 14:16', type:

$ touch -d '17 May 1999 14:16' example [ENTER]

To change the timestamp of file `example' to `14 May', type:

$ touch -d '14 May' example [ENTER]

To change the timestamp of file `example' to `14:16', type:

$ touch -d '14:16' example [ENTER]

Splitting a File into Smaller Ones

It's sometimes necessary to split one file into a number of smaller ones. For example, suppose you have a very large sound file in the near-CD-quality MPEG2, level 3 ("MP3") format. Your file, `example.mp3', is 4,394,422 bytes in size, and you want to transfer it from your desktop to your laptop, but your laptop and desktop are not connected on a network -- the only way to transfer files between them is by floppy disk. Because this file is much too example to fit on one floppy, you use split.

The split tool copies a file, chopping up the copy into separate files of a specified size. It takes as optional arguments the name of the input file (using standard input if none is given) and the file name prefix to use when writing the output files (using `x' if none is given). The output files' names will consist of the file prefix followed by a group of letters: `aa', `ab', `ac', and so on -- the default output file names would be `xaa', `xab', and so on.

Specify the number of lines to put in each output file with the `-l' option, or use the `-b' option to specify the number of bytes to put in each output file. To specify the output files' sizes in kilobytes or megabytes, use the `-b' option and append `k' or `m', respectively, to the value you supply. If neither `-l' nor `-b' is used, split defaults to using 1,000 lines per output file.

To split `example.mp3' into separate files of one megabyte each, whose names begin with `example.mp3.',

$ split -b1m example.mp3 example.mp3 [Enter]

This command creates five new files whose names begin with `example.mp3.'. The first four files are one megabyte in size, while the last file is 200,118 bytes -- the remaining portion of the original file. No alteration is made to `example.mp3'.

You could then copy these five files onto four floppies (the last file fits on a floppy with one of the larger files), copy them all to your laptop, and then reconstruct the original file with cat (see Concatenating Text).

To reconstruct the original file from the split files, type:

$ cat example.mp3.* > example.mp3 [Enter]

In this example, the rm tool is used to delete all of the split files after the original file has been reconstructed.

$ rm example.mp3.* [Enter]

Comparing Files

There are a number of tools for comparing the contents of files in different ways; these recipes show how to use some of them. These tools are especially useful for comparing passages of text in files, but that's not the only way you can use them.

  1. Cmp: Comparing two files to see if they differ.
  2. Diff: Showing the differences between files.
  3. Patch: Applying a difference report to a file.

Determining Whether Two Files Differ

Use cmp to determine whether or not two text files differ. It takes the names of two files as arguments, and if the files contain the same data, cmp outputs nothing. If, however, the files differ, cmp outputs the byte position and line number in the files where the first difference occurs.

To determine whether the files `test’ and `example' differ, type:

$ cmp test example [ENTER]

Finding the Differences between Files

Use diff to compare two files and output a difference report (sometimes called a "diff") containing the text that differs between two files. The difference report is formatted so that other tools (namely, patch---see Patching a File with a Difference Report) can use it to make a file identical to the one it was compared with.

To compare two files and output a difference report, give their names as arguments to diff.

To compare the files `exscript.old' and `exscript.new', type:

$ diff exscript.old exscript.new [ENTER]

The difference report is output to standard output; to save it to a file, redirect the output to the file to save to:

$ diff exscript.old exscript.new > exscript.diff [ENTER]

In the preceding example, the difference report is saved to a file called `exscript.diff'.

The difference report is meant to be used with commands such as patch, in order to apply the differences to a file. See Info file `diff.info', node `Top', for more information on diff and the format of its output.

To better see the difference between two files, use sdiff instead of diff; instead of giving a difference report, it outputs the files in two columns, side by side, separated by spaces. Lines that differ in the files are separated by `|'; lines that appear only in the first file end with a `<', and lines that appear only in the second file are preceded with a `>'.

To peruse the files `test' and `example1' side by side on the screen, with any differences indicated between columns, type:

$ sdiff test example1 | dev [ENTER]

Patching a File with a Difference Report

To apply the differences in a difference report to the original file compared in the report, use patch. It takes as arguments the name of the file to be patched and the name of the difference report file (or "patchfile"). It then applies the changes specified in the patchfile to the original file. This is especially useful for distributing different versions of a file -- small patchfiles may be sent across networks easier than large source files.

To update the original file `exscript.new' with the patchfile `exscript.diff', type:

$ patch exscript.new exscript.diff [ENTER]

Compressed Files

File compression is useful for storing or transferring large files. When you compress a file, you shrink it and save disk space. File compression uses an algorithm to change the data in the file; to use the data in a compressed file, you must first uncompress it to restore the original data (and original file size).

The following recipes explain how to compress and uncompress files.

Compressing Files: Making files smaller.
Expanding Files: Making files bigger.

Compressing a File

Use the gzip ("GNU zip") tool to compress files. It takes as an argument the name of the file or files to be compressed; it writes a compressed version of the specified files, appends a `.gz' extension to their file names, and then deletes the original files.

To compress the file `test', type:

$ gzip test[ENTER]

This command compresses the file `test, putting it in a new file named `test.gz'; gzip then deletes the original file, `test.

Decompressing a File

To access the contents of a compressed file, use gunzip to decompress (or "uncompress") it.

Like gzip, gunzip takes as an argument the name of the file or files to work on. It expands the specified files, writing the output to new files without the `.gz' extensions, and then deletes the compressed files.

To expand the file `test.gz', type:

$ gunzip test.gz [ENTER]

This command expands the file `test.gz' and puts it in a new file called `test; gunzip then deletes the compressed file, `test.gz'.

File Archives

An archive is a single file that contains a collection of other files, and often directories. Archives are usually used to transfer or make a backup copy of a collection of files and directories -- this way, you can work with only one file instead of many. This single file can be easily compressed as explained in the previous section, and the files in the archive retain the structure and permissions of the original files.

Use the tar tool to create, list, and extract files from archives. Archives made with tar are sometimes called "tar files," "tar archives," or -- because all the archived files are rolled into one---"tarballs."

Two common options used with all three of these operations are `-f' and `-v': to specify the name of the archive file, use `-f' followed by the file name; use the `-v' ("verbose") option to have tar output the names of files as they are processed. While the `-v' option is not necessary, it lets you observe the progress of your tar operation.

NOTE: The name of this tool comes from "tape archive," because it was originally made to write the archives directly to a magnetic tape device. It is still used for this purpose, but today, archives are almost always saved to a file on disk.

Creating Archives: Creating an archive of files.
Listing Archives: Listing the contents of an archive.
Extracting Archives: Extracting the files from an archive.

Creating a File Archive

To create an archive with tar, use the `-c' ("create") option, and specify the name of the archive file to create with the `-f' option. It's common practice to use a name with a `.tar' extension, such as `example.tar'.

Give as arguments the names of the files to be archived; to create an archive of a directory and all of the files and subdirectories it contains, give the directory's name as an argument.

To create an archive called `example.tar' from the contents of the `example’ directory, type:

$ tar -cvf example.tar example [Enter]

This command creates an archive file called `example.tar' containing the `example' directory and all of its contents. The original `example' directory remains unchanged.

Use the `-z' option to compress the archive as it is being written. This yields the same output as creating an uncompressed archive and then using gzip to compress it, but it eliminates the extra step.

To create a compressed archive called `example.tar.gz' from the contents of the `example' directory, type:

$ tar -zcvf example.tar.gz example [Enter]

This command creates a compressed archive file, `example.tar.gz', containing the `example' directory and all of its contents. The original `example' directory remains unchanged.

NOTE: When you use the `-z' option, you should specify the archive name with a `.tar.gz' extension and not a `.tar' extension, so the file name shows that the archive is compressed. This is not a requirement, but it serves as a reminder and is the standard practice.

Listing the Contents of an Archive

To list the contents of a tar archive without extracting them, use tar with the `-t' option.
To list the contents of an archive called
`example.tar', type:

$ tar -tvf example.tar [Enter]

This command lists the contents of the `example.tar' archive. Using the `-v' option along with the `-t' option causes tar to output the permissions and modification time of each file, along with its file name -- the same format used by the ls command with the `-l' option (see Listing File Attributes).

Include the `-z' option to list the contents of a compressed archive. To list the contents of a compressed archive called `example.tar.gz', type:

$ tar -ztvf example.tar [Enter]

Extracting Files from an Archive

To extract (or unpack) the contents of a tar archive, use tar with the `-x' ("extract") option. To extract the contents of an archive called `example.tar', type:

$ tar -xvf example.tar [Enter]

This command extracts the contents of the
`example.tar' archive into the current directory. If an archive is compressed, which usually means it will have a `.tar.gz' or `.tgz' extension, include the `-z' option.

To extract the contents of a compressed archive called `example.tar.gz', type:

$ tar -zxvf example.tar.gz [Enter]

NOTE: If there are files or subdirectories in the current directory with the same name as any of those in the archive, those files will be overwritten when the archive is extracted. If you don't know what files are included in an archive, consider listing the contents of the archive first.

Another reason to list the contents of an archive before extracting them is to determine whether the files in the archive are contained in a directory. If not, and the current directory contains many unrelated files, you might confuse them with the files extracted from the archive.

To extract the files into a directory of their own, make a new directory, move the archive to that directory, and change to that directory, where you can then extract the files from the archive.

Reference: Linux Cookbook

RPM Installation Options

RPM Package Manager

RPM is the RPM Package Manager. It is an open packaging system available for anyone to use. It allows users to take source code for new software and package it into source and binary form such that binaries can be easily installed and tracked and source can be rebuilt easily. It also maintains a database of all packages and their files that can be used for verifying packages and querying for information about files and/or packages.

Red Hat, Inc. encourages other distribution vendors to take the time to look at RPM and use it for their own distributions. RPM is quite flexible and easy to use, though it provides the base for a very extensive system. It is also completely open and available, though we would appreciate bug reports and fixes. Permission is granted to use and distribute RPM royalty free under the GPL.

More complete documentation is available on RPM in the book by Ed Bailey, Maximum RPM. That book is available for download or purchase at www.redhat.com

RPM Requirements

To build RPMs from source, you also need everything normally required to build a package, like gcc, make, etc.

Let's say you delete some files by accident, but you aren't sure what you deleted. If you want to verify your entire system and see what might be missing, you would do:

rpm -Va

Let's say you run across a file that you don't recognize. To find out which package owns it, you would do:

rpm -qf /usr/X11R6/bin/xjewel   

O/P: xjewel-1.6-1

RPM Installation options
  • rpm -i *.rpm -Installs rpm pacakge
  • rpm -iv *.rpm - installs rpm pacakge and shows the output in verbose mode
  • rpm -ivh *.rpm -installs rpm package and shows the output and also the # mark ...
  • rpm -iv --replacefiles *.rpm installs rpm package and replaces the existing rpm files
  • rpm -iv --nodeps *.rpm --nodeps: Do Not Check Dependencies before Installing Package
  • rpm -iv --force *.rpm Adding --force to an install command is a way of saying "Install it anyway!"
  • rpm -vv *.rpm --Getting debugging information .

The rpm -e command (--erase is equivalent) removes, or erases, one or more packages from the system. RPM performs a series of steps whenever it erases a package:

Getting More Information With -vv

rpm -evv eject

rpm -U — What Does it Do?

If there was one RPM command that could win over friends, it would be RPM's upgrade command. After all, anyone who has ever tried to install a newer version of any software knows what a traumatic experience it can be. With RPM, though, this process is reduced to a single command: rpm -U. The rpm -U command (--upgrade is equivalent) performs two distinct operations:

1. Installs the desired package.

2. Erases all older versions of the package, if any exist.

rpm -q — What does it do?

One of the nice things about using RPM is that the packages you manage don't end up going into some kind of black hole. Nothing would be worse than to install, upgrade, and erase several different packages and not have a clue as to what's on your system. In fact, RPM's query function can help you get out of sticky situations like:

* You're poking around your system, and you come across a file that you just can't identify. Where did it come from?

* Your friend sends you a package file, and you have no idea what the package does, what it installs, or where it originally came from.

* You know that you installed XFree86 a couple months ago, but you don't know what version, and you can't find any documentation on it.

The list could go on, but you get the idea. The rpm -q command is what you need. If you're the kind of person that doesn't like to have more options than you know what to do with, rpm -q might look imposing. But fear not. Once you have a handle on the basic structure of an RPM query, it'll be a piece of cake.