Setting JAVA_HOME and ANT_HOME on Ubuntu / Linux Mint

This might be helpful for the newbies who are starting their career in software development with  Java lang. And of course its not like in old school when it comes to the industry, we use application build tools for proper deployment of enterprise applications. Such commonly used build tool is ‘ apache – ant ‘. Before starting any big work with java and ant, you have to define ‘Java home’ and ‘Ant home’ to make use of them. Follow the following steps by adding few lines to your ‘.bashrc’ file,

Step 01: Locating .bashrc file.
If your on ubuntu, bashrc can be found on home directory as ‘.bashrc’ . If its Linux Mint go to /etc and open ‘bash.bashrc’ as super user mode to edit via a teminal.

sodu gedit bash.bashrc

sodu gedit bash.bashrc

Step 02: Setting ANT_HOME
Include the following block of text at the bottom of your ‘bash.bashrc’ file (if ubuntu, then .bash).

ANT_HOME

ANT_HOME

I have stored my apache-ant folder in ‘/usr/local/’. Change the path according to your apache-ant folder location.

Step 03: Setting JAVA_HOME
Same as you did for ANT_HOME, include the following block of text at the bottom of bash.bashrc file. Include the correct path of java jvm.

JAVA_HOME

JAVA_HOME

You are good to go!

 BTW I’m listening to Pretty Girl (The Way)” by sugarcult. Its really cool 😛

Setting up a LAMP Server

This post is to help the people who is willing to try out web technologies using LAMP. I think it will be more helpful to do a brief on ‘what is LAMP?’

LAMP represents the open source web platform. Its a portion of 4 resources
L – Linux (any distribution of gnu/linux).
A – Apache ( web server).
M – MySQL (relational database management system).
P – either Perl,Python or PHP (OO scripting language).
In this tutorial I’m using Linux Mint 7 Gloria, Apache2, MySQL and PHP5.

Step 01 → update your system’s package repository. So you can get the latest versions of available resources.

apt-get update

Step 02 → download and install Apache web server

apt-get install apache2

To check what the web server is running without any problems type ‘http://localhost‘ on your browser. If no problems, then it will give a test output as follows,

Step 03 → get PHP and its dependencies.

apt-get install php5 libapache2-mod-php5

after installing php you have to restart apache web server as follows,

/etc/init.d/apache2 restart

Step 04 → Now you need to make sure that PHP and Apache is working fine together. To do that use the following test php scrip and save it as phpinfo.php in server root(/var/www/).

phpinfo.php

phpinfo.php

Then call the script through the web browser. The URL should be like this, http://localhost/phpinfo.php . Then it should show all PHP configuration settings in a coloured table.

Step 05 →  get MySQL

apt-get install mysql-server

During the installation you will get a package configuration screen. Set root password for MySQl carefully. If you didn’t get that screen set password for MySQl manually,

mysql -u root
mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘user_pass_word’);

Step 06 → PhpMyAdmin installation

PhpMyAdmin is a web based free graphical database management and MySQL administration tool. This tool  makes all the MySQL database operations easy. Such as creating tables, creating databases inserting values, deleting values and lot more.

apt-get install phpmyadmin

during its installation it will ask what server to use. Apache or apache2 ? Select apache2 . Then it will prompt you to set a password for phpmyadmin. Done! To use Phpmyadmin type http://localhost/phpmyadmin on your browser.

PhpMyAdmin

PhpMyAdmin

Congrats! Your LAMP system is ready to do extraordinary things for you. 😀

Note: all the command line actions above are held as ‘root’.

Compressing and Archiving

‘.tar’, ‘.gz’, ‘.tar.gz’, ‘.bz2’, ‘tar.bz2’, ‘.zip’. What are these strange extensions? Mostly you ll think these are all compressed files. But its better to understand exactly what these are. And why do we need them.

According to above extensions some are for compressed and some tells that they are archived.

Compressing

In linux/unix environment there are 2 main compression algorithms. They are ‘gzip’ and ‘bzip’. The difference of ‘bzip’ from ‘gzip’ is that ‘bzip’ is more capable of making smaller files than ‘gzip’. But ‘bzip’ consumes much more memory and takes time.

Howto bzip:

as usual open up your favorite terminal/konsole 😀 . Then follow the commands. I m having 4 files inside /home/dushi/test directory.

ls

ls

now im gona compress file1.txt using bzip2.

bzip2

bzip2

Thats all. Now ‘file1.txt’ is replaced by ‘file1.txt.bz2’ 😀

Lets decompress that newly compressed file back to ‘file1.txt’.

bzip2 -d

bzip2 -d

it will decompress the ‘.bz2’ file into its originals.

Howto gzip:

gzip

gzip

same as above its really simple. I’m gona compress ‘file2.txt’ using ‘gzip’. it gives ‘file2.txt.gz’.

gzip -d

gzip -d

use -d to decompress.

Archiving

The ‘.tar’ format is the most common archive format in linux/unix environment. They are mostly called as tarballs. Archives are not compressed files. It combines one or more files into a single file. The idea is to achieve easier storage and transportation. Specially in web.

Howto archive:

lets go back into my /home/dushi/test/ directory again.

ls

ls

There are 4 files. Two compressed files and two normal text files. Lets archive them all into ‘MyArchive.tar’ .

tar -cf

tar -cf

from about cmd makes a tarball as ‘MyArchive.tar’ 😀 . To extract files from it ,

tar -xf

tar -xf

Thats all u should know 🙂  for more options refer,

$man tar

$man gzip

adios

Command Line Package Management [Debian Based]

you can use ‘apt-get’ tool to manage packages via the CLI instead of using the GUI. ‘apt-get’ can be used to install and uninstall packages as we needed. For your convenience Im going to introduce another CLI tool , ‘dpkg’. Most of you may already have useded it.

Installing a program:

apt-get install

apt-get install

system will check the repositories and install it into the pc from a desired place. By default it will connect your PC to a FTP server and download the required package and its dependencies, then install. This method is highly effective for a good installation.

If you want to install a package which is already saved in your pc,

dpkg -i

dpkg -i

At times you have to download the package source code/binaries and compile it then install. To do that go in to that folder and follow the following steps,

#./configure
#make
#make install

Uninstalling a program:

same tools again!

dpkg --list

dpkg --list

using the above code you can get a list of installed programs.You can use ‘apt-get’ as shown bellow to remove programs,

apt-get remove

apt-get remove

when after performing an ‘apt-get install’, by experience you ll understand that its installing  also other packages as dependencies. We can also remove a program with all its dependencies.

apt-get --purge

apt-get --purge

these are the basics of Linux file management via CLI. Feel free to experiment the commands and rediscover the CLI.
……………..enjoy…………….

Configuring+Understanding ‘/etc/fstab’

             If there are any Linux users who still have difficulties in accessing and mounting their hard drives and other storage media, hope this post will help them. fstab contains some of configuration info about your hard drives and partitions such as file system types and mount points. Sometimes because of its mis-configuration it gives headaches to user. So in a moment like that you should have to know to configure by our own. Before editing any of your configuration files remember to backup them as a habit. You can edit this file using any of your text editors but you need to have root privileges. Here I’m opening ‘fstab’ config file using nano.

nano /etc/fstab

nano /etc/fstab

This is what I got….. yep it seems like a shuffled puzzle for the first time!

 

My fstab looks shit!

My fstab looks shit!

 

 Let’s take a hand written example to make it clear. Then follow its explanation.

#etc/fstab: static file system information

#

#<file system> <mount point> <type> <options> <dump> <pass>

proc                  /proc                proc      defaults    0                0           #line1

/dev/hdb4         /                       ext3      defaults     1                1           #line2

/dev/hdb2         swap                swap     defaults    0                0            #line3

/dev/hdb3         /home              ext3      defaults     1                1            #line4

/dev/hdb1        /media/hdb1     ext3       auto          0                0           #line5

/dev/hda1        /media/hda1     ntfs        defaults     0               0           #line6

/dev/scd0        /media/cdrom0 auto       ro,noauto,user,exec 0 0          #line7

/dev/fd0          /media/flopp0   auto      ro,noauto,user,sync 0 0          #line8

 

::::::::::::: Explanation ::::::::::::

1st and 2nd columns :: Its easy 1st explains the device and 2nd explains the mount point.

 

3rd column :: exlapins the ‘file system.’

                   As mentioned about it can be ext3, swap, ext2, reiserfx, vfat, ntfs or any other file system. Did you notice line two? Its something different. “proc” file system is a special file system used by the kernel to store hardware information. Some programs retrieve hardware info from this system. Most of the time proc file system will be a small space in your root partition.

                        auto” option is also used. Its not a file system. It simply means that the file system type is detected automatically. Media devices which vary its file system like cdroms and floppies can have this “auto” option.

4th column :: list all the mount options for the device or partition.

            Options should explain in detail. User can define more than one option using “,” to separate them. Here I m considering about only the most common options,

 

user and nouser “user” option allows normal users to mount the device. If you use “nouser” you should have to be root to mount it.

***Most of new Linux users tell that they can’t mount their windows partitions and other media types. The reason for that is “nouser” come in default. So new users, if you  have mounting problems feel free to open fstab and change the “nouser” option to “user”.

 

auto and noauto “auto” option allows the device to mount automatically at the bootup. “noauto” option stops mounting the devices at the startup. But allows, mounting it manually after logged in.

***If you are new to Linux mint5 Elyssa, you would be facing to this problem. Some of your media devices are not mounted at the startup and if you want them to be, check your fstab file. Most of the times you want find any record/entries for this troublesome drives. So you should have to write them manually. And remember to set its mount option as “auto”.

 

ro mount the file system read-only

rw mount the file system read-write

***”ro” and “rw” can also give probs to new users because some times they cant writ into windows partitions and some times even into Linux partitions. So now you can understand how to solve that problem.

 

sync and async defines how the input and output to the file system should be done. If it is “sync” it is done synchronously. If its “async” inputs and outputs are done asynchronously.

            Think about a file operation like coping some data into a floppy. If its set to “sync” the physical changes are made to the floppy at the same time. But if its “async” the physical changes are done after some time when copping commands are executed. Maybe changes will occur when you’re trying to unmount the floppy.

 

 

 defaults uses all the default options.

exec and noexec exec” allows the user to execute binaries which contains in that partition. “noexec” stops it.

 

5th column :: It is for back utility (dump). If its set to ‘0’ dump will ignore the file system. If ‘1’  backup the file system.

6th column :: This is for fsck (file system check utility). if it is ‘1’ fsck checks the file system. If not dont check( fsck is explained very shortly. I ll put a new post about ‘fsck’ in future).

Finally remember to place your root partition’s record/entry at top of the fstab. Do what ever modifications after the root partition’s entry. So it want change its level. Because the order which they are arranged is important. Before every thing, system should find the root partition and mount it. Then others will be mounted inside the root.

            If your still have questions, doughs or problems with fstab+ mounting feel free to leave them as comments.

My Linux is in My Pen Drive [PuppyLinux4.1].

Yes, by all it means now it is also inside my pen drive. But what’s so special?

Answer: mm… its only 94MB of capacity, it allows persistent data and it has all the features of a normal distro . So what else I need? 😉

PyppyLinux4.1
PyppyLinux4.1

Haha ..  Let me explain. I heard about a very small Linux distro by a friend of mine. So I looked forward to find out more. It was ‘Puppy Linux4.1.2’. You can also download it from www.puppylinux.com. First I thought ‘oh its only 94 mega bytes… What the hell it should be some kind of useless crap’. But at the end it really pissed me about my under estimation! As I mentioned now its in my pen drive. its clean, stable and very user-friendly.  I spend only about 8 minutes to install, maybe less. It only gets seconds to boot into the RAM. Then you are good to go. This distro is specially designed for hot plugs.  You can plug it to any machine which has minimum of 48MB of RAM and 8MB of Shared Video. But you want be loosing your default settings and other saved data. That’s what I meant by ‘persistent data’. Puppy asks you to save all your settings into the drive you are currently using. Mostly it’ll be a small file with some allocated mega bytes in your pen. Not like other Linux distros, you need not have to make special partitions or file systems in your pen drive or other device. If its default file system is FAT, You can install Linux on FAT. That’s because the installed location only contains compressed files and at the bootstrap it uncompress them to the RAM.

Puppy 4.1.2 has two graphical servers. ‘X.org’ and ‘Xvesa’ (I use Xvesa). Its default desktop mostly looks like KDE. It gives ‘abiword 2.6.3’ as a word processor. I felt it like Open Office while I’m using it. It has ‘SeaMonky1.1.11’ for browsing (something like Firefox). It has a handy Personal Organizer call ‘OSMO’. Like the other organizers it allows you to maintain your contacts, tasks and calendar. Like that ‘Calc’ for spread sheets, ‘InkscapeLIte’ and ‘mtpait3.21’ a simple GTK paining program for art work, ‘Geany 0.12’ the fast & light weight IDE, The puppy PDF converter (this is the first time I got a PDF converter as a default of the OS) and it also provide CD ripping tools like ‘Ripoff CD song ripper’  and also a number of CD/DVD burning software.

A special thing I saw about Puppy Linux is it covers all the main requirements of a normal user.  Finally have to say something about its ‘Gxin 0.5.9 media player’. It runs almost all types of media formats (I personally experienced good results by running following media formats: – .avi,.mp4,.mp3,.3gp,.DAT,.mpg,.divx,.wmv,) .

You really have to try out ‘Puppy Linux’ in your machine. And feel free to comment your thoughts.

Editing the GRUB ~ HowTo

This is about customizing the grub menu which appears at the bootup. The things in this menu contains in a file called ‘menu.lst’ and its located in ‘/boot/grub’ dir. Its not difficult to edit this but bit risky if you don’t do it correctly. So for your safe its better to backup this ‘menu.lst’ file first. Then fire up your terminal/konsole, get root privileges and type,

nano

nano

 

Now you see ‘menu.lst’ through the terminal/konsole in edit mode. It looks very complex at the very first moment. But if you take a further look, you ll notice that most of the things are just comments. This HowTo explains only 4 useful edits.

 

  1. Changing The Default Timeout

Fined out the following phrase, then all you have to do is to assign the time for your choice in seconds. At the moment its default value is 10 seconds

 

Changing The Default Timeout

Changing The Default Timeout

 2.Changing The Titles

This means you can change the titles which appear at the startup. To do this scroll down the menu until you fined “##End Default Options##”,

Changing The Titles

Changing The Titles

Here you can find all the titles/names of Linux and non-Linux operating systems. You can just edit them! Mm.. Well.. I have edit “windows XP as windows sucksp”. Sorry windows folks..  My bad!

Sorry

Sorry

 

    3. Removing Items

There are things that are not useful for some users. Things like ‘recovery mode, memtest and windows divider (if you have windows)’. Erase the titles and their belongings with no fear. But its better if you can leave them by only commenting.

Removing Items

Removing Items

 

4. Setting up the default OS

This option is at the very top of the file,

 Setting up the default OS

Setting up the default OS

In menu.lst, each ‘title/entry’ has a number starting from 0. So count down the titles from 0 utile you fined the OS which you want to set as the default. Then give the relevant value. Please note that if you have changed any titles into comments, leave them without counting.

            If you are done with editing, finally press Ctrl+x to exit. Then it ll ask to save any changes you made. Reboot the system to check. Then if something goes wrong remember to replace the menu.lst with the file you backup early. You can use a live CD for that. Feel free to experiment further. Happy computing!

%d bloggers like this: