Sabtu, 06 September 2008

Installing Software in GNU/Linux

Introduction
For the benifit of people new to Linux, I have written a generic explaination of howto install software in Linux. Note that some software may have specific installation proceedures, this HOWTO is not a substitute for reading the offical installation documentation

This HOWTO covers the following topics:

* Compiling and Installing software from source
* Installing RPM's using the Redhat Package Manager
* Installing using Debian's apt-get
* Installing mandrake things
* Installing with fedora / yum
* Installing slackware packages
* Installing software using Gentoo EMerge


If you have just installed GNU/Linux and would like to know how to install software on your new OS, I would recommend you read the "Compiling and installing software from source" section, as well as the section specifically for your GNU/Linux Distribution. Do not worry if you dont understand or remember everything written here straight away, book mark this page and use it as a reference page later on.



Compiling and Installing software from source
Some software is distributed in "Source form". This means you download a file containing all the source code for the application you want to install, unpack it, and compile it on your system. Compiling is the process of turning the source code into an executable binary. The common myth and newbie assumption is that this is very hard todo, or it is only for programmers. Wrong. It is a fairly straight forward process, and you will find that a lot of software you install will need to be built from source.

Typically applications you must compile from source will come as a ".tar.gz", ".tar.bz2", or ".zip" file.

For organisational purposes, I like to save my source zip file to /usr/local/src/, but this is totally up to you. For the rest of this section we will assume you have downloaded your zip file to /usr/local/src/. If you do not have a /usr/local/src directory, you can create it with the following "mkdir" (make directory) command:

Code:

mkdir /usr/local/src/

So, we have our source package in /usr/local/src/.

Change to the /usr/local/src/ directory with the "cd" (change directory) command like so:

Code:

cd /usr/local/src/

Use the "ls" (list directory contents) command, to see the file is present:

Code:

ls


We now need to unzip the zipped file, this is done differently depending on the file extension.

for files ending in .tar.gz, use:
Code:

tar -zxvf

(replacing with the name of the file).

for files ending in .tar.bz2, use:
Code:

bunzip2

for files ending in .zip, use:
Code:

unzip

You should now have a new directory, containing all of the source files. To confirm it exists, and to get its name, use the "ls" command again.
Code:

ls

we now need to go into the new directory, so use the cd command:
Code:

cd




This is where things will differ. Some packages will have an INSTALL or README file which will contain installation instructions. use "ls" to see if the software has an install or readme file. If it does have one, you can use the "more" command to read it, like so:
Code:

more INSTALL

Generally, the final 3 stages are as follows:
- Configure the installation
- Compile the software
- Install the binaries

The pre-installation configuration is done by executing ./configure:
Code:

./configure

This will perform some requirements testing on your system, and create a "Makefile" which will explain to the "make" utility how the software should be compiled. If you receive any error messages during this stage, you may wish to search the forums to see if they have been found and resolved by someone else already, if not, feel free to post a question on the forums - Please include all of the output including any error messages, and some details about your system - what distro you are using, what are you trying to install etc etc


The next stage is to compile the software, this is done using "make". When you run "make" it will read the instructions in the Makefile and build the application binaries.
Code:

make


The final stage is to install these binaries, ie, copy them to a more perminent location. Typically only the "root" user can do this, so you will need to swich to the root user with the "su" command:
Code:

su

Once you are root, install the binaries using the "make" command, followed by "install", like so:
Code:

make install

That is it!. Check the user documentation of the software you installed for details of how to run the application.

Remember that if you have any problems, please post in the most relevant section of the forums. - When posting, remember to include as much info as possible, including all output and error messages.





Installing RPM's using the Redhat Package Manager
Redhat RPM's offer a flexable and easy method to install new software. Software installed from an RPM package differs from compiling from source in a few ways, but the most important one of all is the software is already compiled for you. Essentially all you are doing is extracting the pre-built binaries and copying them to their pre-selected destination. RPM's are files that have a ".rpm" extenstion. The good point about RPM's is installation of new software, and maintaining the software currently installed is much easier than doing so for individual packages compiled from source. The downside to RPM's is that you dont have as much choice about where software is installed on your system, how it is compiled, and how it is configured.

Using the RPM system is fairly straight forward. To install a package, you can use the following command:
Code:

rpm -i

When using rpm, you must be logged in as the root user. The "-i" flag in the above command means "install".

Un installing a package is just as easy:
Code:

rpm -e

The "-e" switch used here means "erase" (un install).
Note that is different from used when installing.


For example, if you are installing an application called "mysoftware", you may use a command like "rpm -i mysoftware-1.0.2-i386.rpm" to install "mysoftware", when removing we dont follow the filename for installation, but rather the name of the software itself.

For further uses of RPM, please use "rpm --help" and "man rpm". Also see this page, which has some fairly useful information.


If you need to find & download the RPM file for a piece of software, I recommend using
RPM Find and RPM Pbone Search Note that not all applications are available as RPM's, in these cases you will need to compile the software from source. (see above).



Installing using Debian apt-get
Apt-Get is a wonderful package management system for Debian GNU/Linux. Apt-Get, like RPM make installing and managing installed software easy, and once again has the same disadvantages that binaries are pre-built and cannot really be fine tuned to your system very well. I really like Apt-Get becuase of its automatic software download and upgrade mechanisms, and unlike Redhat doesnt keep trying to sell you something, and doesnt try to limit your use of the system.

The most powerful feature of apt-get surely is that you dont manually have to find & download the software you want to install, apt-get will do this for you, and also resolve any software dependencies. Before you can use apt-get for the first time, you must do a small bit of configuration.

You need to edit your /etc/apt/sources.list file, to specify the locations of Debian packages. You will proberly want your default sources.list file to look something like this:
Code:

deb http://http.us.debian.org/debian stable main contrib non-free
deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
deb http://security.debian.org stable/updates main contrib non-free

If you would like to use more upto date software on your machine, you will proberly want your sources file like this:
Code:

deb http://ftp.debian.org/debian/ sid main contrib
deb http://non-us.debian.org/debian-non-US sid/non-US contrib
deb http://security.debian.org/ stable/updates main

The first sources.list file uses the stable branch of debian packages. Software installed when using the stable version has undergone more testing, and in theory has less bugs. However, the software on the stable branch is usually much older versions, so you may be missing out on new features etc. The second example sources.list uses the UnStable branch. This means you will get newer versions of software, but you may occaisionally run into bugs which have not yet been fixed. I myself use and recommend using the unstable branch, the software on the stable branch is 2 or 3 years behind the unstable.

Once you have confirmed your sources.list file, we need to update our local list of packages that are available for installation. To do this, use the following command after logging in as the root user:

Code:

apt-get update

After updating the list, you can install applications like so:
Code:

apt-get install

To see a list of available programs that you can install, or to find a particular program, we can use apt-cache, like so:
Code:

apt-cache search

Replace with a application name or word. Eg, to find an irc client to install, you could execute
Code:

apt-cache search irc

.

To uninstall software is fairly straight forward also.
Code:

apt-get remove

replace with the name of the program you want to remove.

A word of caution: If you try to remove a piece of software that other pieces of software depend on, apt-get will also want to un-install those other pieces of software as well. Becareful you dont end up uninstalling your entire system!. apt-get will prompt you before removing any additional packages so watch carefully!



Installing software on Mandrake with urpm
urpm is a nifty was to install software on any 7.x or greater Mandrake system. Some of the advantages of Mandrake's urpm utilities are:

* It automatically solves package dependencies issues by installing or uninstalling dependent packages.

* It installs packages and dependencies directly from the internet.
* It allows globbing of package names
* It will automatically update your system.
* It will install all those "not allowed to distribute" programs that you really want to have (DVD support, MP3 enoders, etc...)

How do I install urpm?
urpm should be installed by default on any modern Mandrake distobution. If it's not, you can install it using the Mandrake Control Center (MCC).
urpm Commands
urpmi

The most commonly used command is urpmi. This command allows you to install packages from your configured sources (see below). urpmi will try to install all package dependencies. It will also take partitial names and give you a list of available packages. For exmaple, if you wanted to install one of the kdemoreartwork styles, but didn't know the exact name, you simple type

Code:

[root@cayanne ~/]#urpmi kdemoreartwork

and it should return a list of packages not already installed on your system. This also means it will install the most up to date package for your system, you don't have to know which version you're looking for. As an exmaple, you may wish to add DVD Play back support to your computer. This can be done by installing any video player, such as Xine or MPlayer, along with the package libdvdcss. Rather then having to type in urpmi libdvdcss-1.2.1-1.i386.rpm, you can simply type in

Code:

[root@cayanne ~/]#urpmi libdvdcss


urpme
The urpme command deletes, or erases, currently installed packages and all packages depandant on that it.

urpmq
The urpmq command searches for, or queries, for packages that you list.

urpmf
The urpmf command does an advanced search for a filename in all known packages. For example if we are trying to compile a program and the configure script is complaining about not finding ncurses.h, we can do a urpmf ncurses.h to find that it is part of the libncurses5-develpackage.

Code:

[root@cayanne ~/]#urpmf ncurses.h
libncurses5-devel:/usr/include/ncurses.h
libncurses5-devel:/usr/include/ncurses/ncurses.h
php-devel:/usr/src/php-devel/extensions/ncurses/php_ncurses.h


urpmi.addmedia
urpmi.addmedia does exactly that, makes an rpm reposatory available for urpm to utalize. Typically, you have your installation cd's available as a default media, these are called main. In addition, you also have three other media - updates,contrib and PLF. Updates is the updates, and contrib is user contributed rpm's and PLF is all those not available for distribution for so-called legel reasons rpm's. The sysntax for urpmi.addmedia is

urpmi.addmedia [media-name] [ftp-address with] ../base/hdlist.cz
Note that the hdlist.cz is required. For example, to add medium 'contrib', we use the following command

Code:

[root@cayanne ~/]#urpmi.addmedia contrib ftp://ftp.sunet.se/pub/Linux/distributions/mandrake/updates/8.2/RPMS with ../base/hdlist.cz
added medium contrib
retrieving description file of "contrib"...
...retrieving done
retrieving source hdlist (or synthesis) of "contrib"...
...retrieving done
examining whole urpmi database


urpmi.removemedia
This command removes specified media. Need I say more?

urpmi.update
The urpmi.update command goes through all of your media sources and updates your installed packages if necessary.

How do I set up urpm?
urpm can be set up using MCC, but I've personally found the instructions at the web-site http://easyurpmi.zarb.org to be a little easier. Either way, you can use the site along with MCC or the console to add media. Simple follow the step-by-step instructions, and enter the command it prints out in the grey box into any terminal window, as root of course. You can even copy and paste the command, there's no need to type it all in.

Now that you're up and running with urpmi, try to install a few packages! Have fun!

Where can I get more info?
Here's couple of places to get more info (these are the places where I got my references):

Mandrake FAQ
Mini How-To

Some site in Texas



Installing with fedora / yum


Installing slackware packages
Slackware packages are usually .tgz files containing pre-built binaries. To install software in slackware you will need to find and download the .tgz package manually beforehand. If you are looking for a slackware package for a piece of software and have not found it yet, search Linux Packages for it.

Ok, once we have our package, lets install it. To install slackware packages, ensure you are the root user using the command:
Code:

su

Now run the following command to install the package:
Code:

installpkg

Uninstalling a package is also quite simple:
Code:

removepkg

Also worth noting about slackware packages, is a utility called pkgtool which will allow you to install, remove and list packages on your system. To use pkgtool, run:
Code:

pkgtool

and follow onscreen prompts.

Anyone who likes the debian apt-get system but is currently using Slackware may be interested to hear about a utility called slapt-get, the Slackware answer to apt-get. Slapt-get is avaible from Here. There is also a nifty Gnome/GTK front end for slapt-get in development, you can preview it at the same url.

Lastly, if you are having trouble locating a slackware package, but have been able to find a equivilent RPM, you can "convert" that RPM to a slackware package which you can use with the installpkg and removepkg commands. To convert your RPM to .tgz, use the command:
Code:

rpm2tgz .rpm



Installing software using Gentoo EMerge


Further reading

* Offical Debian Apt-Get HOWTO
* Slackware Package guide
* Official RPM HOWTO
* Maximum RPM (power users guide to RPM)
* Guide to Gentoo Emerge



Copyright, Re-Printing, and comments
This document is copyright Jason Lambert, 2004.
The mandrake section is contributed by jeremy1701 and is copyright jeremy1701 2004.

You may not re-produce or reprint this document in part or in full without my prior written permission..

If you would like to request permission to re-print any part of this document, please send me a private message on the forums.

The mandrake section may not be reprinted without written permission of jeremy1701

All trademarks remain the property of their owners etc.

If you have a comment about this howto, please Email Me. Please do NOT email me or send me a private message asking for technical assistance. If you need help please post on the forums!


-- EOF --
taken from: http://www.linuxforums.org/forum/linux-tutorials-howtos-reference-material/9358-howto-install-software-readme.html

Tidak ada komentar: