Wednesday, February 9, 2011

Installing Packages in Linux

Here's one of my oldest articles. I'm glad I found a few of them. This one was written on 12th Jan'05, when I was pursuing my engg degree.
:-)

So, you installed Linux , at last.
Good for you !!

you might have got all the important and different softwares packaged with the Linux OS
itself,
so, its all you got , right ??
No !!

Thats where the wonders of Open-Source softwares begin,
Open-Source softwares are licensed from GPL ,
for more info , visit

http://www.gnu.org/copyleft/gpl.html            -> for GPL license
http://www.gnu.org/                                        -> for package-list

There are so many other sites, with a whole lot of packages,
juz dig-in the internet.

Open-Source softwares are “open” because, they provide the source-code along with
the package, strange ??
there's more to come,
you can modify the code , rebuild it and distribute it with your own name,
isn't that great ??
You have the power to debug the code, if you find any.
Thats the most any software could give you.

So, we have a vast ocean of open-source softwares, which you need to dig- in ,
download, install and configure.

There are also some packages in .rpm format (red hat package manager).
ALL you need to do is double-click on it, and provide root-password.
OR
# rpm -ivh package-name.rpm
from console.


But, most packages are in    package-name.tar.gz or  package-name.tar.bz2 format.
Download it. And save it preferably in  /usr/local or /opt directory  or anywhere else except
mounted windows partitions, because then , it won't be able to create symlinks(imp. shortcuts to executables to be placed in /  subdirectories)

so, you got it on your hard disk.

-> your package name

Open the console.
'cd'  to the directory where you just downloaded the source-code.
“su” to root-user, if you're a normal user.
Note -> installing as normal user could result in failed-installtion, coz you
might not have write permissions to every sub-directories.

Step 1. Uncompress and untar(un-archive) the package.
For *.tar.gz
# gunzip *.tar.gz
# tar -xvf *.tar

For *.tar.bz2
# bunzip2 *.tar.bz2
# tar -xvf *.tar

Step 2.   'cd' to the package directory.
Now, you must be having “Readme” file. Read it carefully.
Also, you might want to check INSTALL and configure file.

Step 3. The most common steps are -
Job of configure file -> configure the package, check all the requirements incl . gcc n various libs n enviroment etc.

# ./configure                           

It will take some time.
Now, if all goes right, you won't get an error message.It might prompt you to run “make” now.
If an error occurs, it stops at the 1st encounter of an error,  so, it might happen, when you fix it and configure it again, you would get another error.
For errors, read the log file, and fix the errors.
If you can't, you might want to read several online forums, or just post your problem there.
Or you can ask me.

Step 4. Now, we're ready to build the package.
To build -> compiling the source code into executable binaries , that you would be running.
Note -> almost all the win-packages are binaries, already compiled and there are hardly any conflicts. (needless to say, they are also not open source)
But, in Linux or unix-based OS, packages are source-codes(mostly),
and its better to compile it for your specific platform. ITS RECOMMENDED.

Run,
# make

for non-linux systems you , might try,
# gmake

Now, you might like to have some coffee, go and make it for yourself.
Coz, “make” does take time, from 5-50 mins.
Smaller the package , smaller the time, i.e. Mplayer, GTK-Gnutella.
Larger the package, larger the time , i.e. gcc ,  re-compiling the kernel.

Now, if you get errors,  watch it carefully, read the log file why “make” failed.
Solution –  same as above in Step 3.

Step 5. Now, if you are through, voila !!
your binaries are ready to do it all for ya !!

Sometimes, you would like to create important symlinks for your application,
(its not necesasary to run your application, its already been built)
so, run,
# make install

if its instructed in the readme file.

Symlinks are created in /usr/local/bin or /usr/local/sbin or /$HOME/user/Desktop,
so, you can run your application from anywhere.


Now, just run your application.
# application-name
or
# ./application-name
from the package-directory

If it says “cann't execute” , change the attribute of the executable to 0555,
# chmod 0555 package-name

If it says , “command not found”, symlinks are not properly created,
create it yourself,
remember everything in Linux is “case-sensitive”,

# ln -s  source-executable-path/exec-name  dest-path/exec-name
dest. dir can be -> /usr/local/bin, /usr/local/sbin/

The problems you might face here are,
1.    slow cpu
2.    low memory
3.    need to configure your application's “config” file
4.    access-rights

For 1,2  , u can hardly do much, except increase your virtual memory.
Or get a faster cpu, or upgrade your RAM.

For  3. read the application's config file, docs, manuals and search the internet.

For 4, contact your root admin.

Happy Open-Source !!

No comments:

Post a Comment