Sunday, 21 November 2004

RPM Package Manager

RPM is a recursive acronym for RPM Package Manager (Formerly known as Redhat Package Manager). It is the default package manager in RedHat as well as RedHat based Linux distributions like Mandrake, OpenSuSE, PCLinuxOS and so on [Read about these Linux distributions here ]. It is very powerful and can be used to install, remove, update software, as well as a whole lot of other things in Linux. Basically, RPM can be divided into 3 main areas of functionality.
  1. Packages - Files that are compressed and contain applications, data and other files.
  2. Database - A list of installed packages in a system.
  3. Compilation - Bundling a bunch of files into a package suitable for installation on other systems.
Here are a couple of important RPM commands that are frequently used by Linux users though now a days, they use other tools (such as Yum) which provide automatic dependency checking to achieve the same.

Querying - Know more about a package
You can query the RPM database to know more details about a particular package that is installed in your system. To see if a particular program (say gedit, a text editor) is installed or not, use -q to activate the query mode in RPM.
# rpm -q gedit
RPM usually responds with the name, version and release of the package installed or, more likely reports that it is not present. To see all the files that are installed for gedit and their full path, use the -l sub parameter with the query mode.
# rpm -q -l gedit
Here -q is the mode and -l is the submode. Usually you can bundle the mode and sub-mode parameters together as follows:
# rpm -ql gedit
You can also try...
# rpm -qlv gedit
... for a more verbose output.

To find, in which package the file /bin/sh is located, try :
# rpm -qf /bin/sh
bash-2.05b-38

...which tells that the file /bin/sh is situated in the package bash-2.05b-38.
Now to get more details about the bash package execute the following command:
# rpm -qi bash
...which will give a whole lot of details about the bash package installed in your system.

Installing and removing packages

Suppose you want to install a package (say gedit):
# rpm -ivh gedit-2.6.0-4.rpm

To update gedit to a newer version:
# rpm -Uvh gedit-2.8.0-6.rpm
The -U mode means, if this package is not installed, install it; if an older version of this package is installed, upgrade it.

There is a third installation mode, called freshening, represented by -F. This is similar to -U in that it upgrades a package that is installed, but it adds one restriction - it ignores any packages that are not of the same name as a package that is already installed on your system. So if you have a directory containing a bundle of rpms - say security patches - then you can move into that directory containing the security patches in RPM format and execute the command:

# rpm -Fvh *.rpm

... which will install only those security patches which are related to the packages that are already installed in your system and will ignore the rest.

To remove an already installed package say gedit, just type:
# rpm -e gedit

Drawbacks of RPM

RPM has one difficulty, ie it will not install a package if that package depends on another program that is not already installed on your system. This is known as a dependency issue. RedHat provides two utilities called rpmdb-redhat for RedHat enterprise linux and rpmdb-fedora for Fedora Core. Once you install one of these on your system, RPM will automatically begin suggesting dependency resolutions.

Of course, you can force RPM to install a package even without resolving a dependency problem by using the --force and --nodeps parameters to both the installation related modes and the remove mode. They ignore conflicts and dependencies respectively.

Suppose you do not want to install an RPM package but get one or more files in it. You can use a utility called rpm2cpio to convert your RPM package into a cpio package (which is more or less similar to a tarball) then use the command cpio to extract all the files into a directory as follows:
# rpm2cpio PackageName | cpio -id

This will extract all the files from the RPM package into the current directory. This is only a small subset of the power of RPM. To know more about it try:

# man rpm

Wednesday, 17 November 2004

Installing RedHat linux directly from the iso's saved in your hard disk

I came across an article which described how to install RedHat linux directly from the ISO's saved in your hard drive skipping the need to burn them on to a CD. The advantage of this method of installation is that, it is blazingly fast and the installation can be finished in a fraction of what it takes normally to install by booting from a CD or DVD.

But there is a catch though - this method works only if the filesystem on your hard disk is eaither of the following - FAT, ext2, ext3. If you have a file system other than those three, like resierfs, then you are out of luck. Also this method is specific to RedHat linux distribution.

You can also find a different method explained at LinuxQuestions.org.



Sunday, 7 November 2004

Connecting to BSNL dial-up Internet Server using wvdial

Bharat Sanchar Nigam Limited (BSNL) is India's largest telecom company. It is owned by the Govt. of India. BSNL provides Internet dial-up access packages (Sancharnet) which are the best deal when compared to those provided by other ISPs in the country. Here I will explain how to dial in to the BSNL server in linux using wvdial utility. It is assumed that you already have a BSNL dial-up internet account. If not then get one and come back to this page :) .

If this is the first time you are connecting to the internet, then you have to 'su' to root and execute the command :

$ su -

# wvdialconf
wvdialconf script, builds a configuration file for wvdial. It detects your modem, its maximum baud rate, and a good initialization string and generates or updates the wvdial configuration file based on this information.Now if you check the /etc/wvdial.conf file, you will see that wvdialconf has written the necessary data regarding your modem there. Now you have to open the /etc/wvdial.conf file and enter the BSNL dial-up access phone number, your username and password as follows:

; /etc/wvdial.conf file

Phone = 172222

Username = "your login name"

Password = "your password"
Also make sure that the line -

New PPPD = yes
exists in the /etc/wvdial.conf file in the [Dialer Defaults] section. If it is not there, then include that too.

Next you have to modify your /etc/resolv.conf file and enter the primary and secondary DNS servers of BSNL for name resolution. If you do not do this then, you will be able to login to the BSNL server, but will not be able to browse the web. My /etc/resolv.conf file is as follows:

nameserver 61.1.96.65 #Primary BSNL DNS Server

nameserver 61.1.128.5 #Secondary BSNL DNS server

nameserver 61.0.0.5 # Tertiary BSNL DNS server
Now to connect to the internet, just run wvdial command in the console as follows:

# wvdial
By default only root can run wvdial. To let other users execute wvdial utility, I did the following:

First I created a group called 'modem'.

# groupadd -g 503 modem
I Made sure that the group id 503 is not used by any other group; If not then you could use any other unique number greater than 500.Then I included all users who are allowed to connect to the internet to this newly created group.

# usermod -G modem ravi

# usermod -G modem sada
Then I permitted the modem group to connect to the internet by editing the sudo configuration file /etc/sudoers as follows:

# visudo
//Now you are in /etc/sudoers file

%modem localhost=/usr/bin/wvdial
From here onwards, those who are in the modem group can execute the following command to connect to the internet.

$ sudo wvdial

password: ******
My complete /etc/wvdial.conf file is as follows:

[Dialer Defaults]

New PPPD = yes ;Don't forget to include this line

Modem = /dev/modem

Baud = 14000 ;I use the linuxant driver so speed is less

Init1 = ATZ

Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

ISDN = 0

Modem Type = Analog Modem



;BSNL phone no:,username and password settings

Phone = 172222

Username = "My login name"

Password = "My Password"