Tuesday, September 25, 2007

Finding fastest mirror/site

Say if you are to download something from a mirror and have not been suggested the best mirror for you, how will you decide which one to download from?
Perhaps, speed and efficiency will be the factor for you. But, how to know which one will be the fastest and efficient mirror?

The answer to this question is netselect. This package chooses the fastest server automatically. On providing space separated list of sites, it chooses the fastest server. The calculation involves various factors like ping time, number of hops required to reach the target, the percentage of ping requests that got through successfully.

For example, say you want to download apache from its official site. You will be provided with a list of mirrors (you will be provided with a suggestion for best mirror-site but lets ignore that for the moment). I chose to find the fastest one out of 3 mirrors: http://apache.mirrors.hoobly.com/ http://apache.hoxt.com/ http://veritris.com/mirrors/apache/ .

So, I typed
$ sudo netselect http://apache.mirrors.hoobly.com/ http://apache.hoxt.com/ http://veritris.com/mirrors/apache/
which gave me output
2175 http://apache.mirrors.hoobly.com/
Hence the fastest one out of 3 was found.

Actually, netselect gives score to each mentioned server on the basis of various factors. The lower the score is, better is the server response. Now, to know the score of each server, run netselect in very verbose mode with -vv option. For more information on netselect, refer to netselect manual.

Also try netselect to check fastest search engine at your location by supplying a list of search engines with the netselect command.

Netselect will definitely make your life easier especially if you are using slow dial-up connections.

N.B.: I tried this command on Debian based Distro, Ubuntu. This command works on Debian based systems but I am not sure about rpm based systems.

Monday, September 17, 2007

Listing the dependencies

I have come across many people who don't have access to internet connection and are worst hit by dependency problems while installing a package. Some time back, I myself was suffering from such problems. While borrowing from your friend, how to ensure that you have got all the files required to install a package? One such method is using:
apt-cache depends packages
where package is the name of the package of which dependencies are to be listed. For example,

$ apt-cache depends adduser
adduser
Depends: perl-base
Depends: passwd
|Depends: debconf
Depends:
cdebconf
debconf
Suggests: liblocale-gettext-perl
Suggests: perl-modules
Replaces: manpages-pl
Replaces: manpages-it

Shown above is the output of the command for package "adduser". The output lists out the packages on which the specified package depends along with the sub-dependencies.

Now, you are ready to use the above command to list the files on which your desired package depend, copy .deb files and install them using dpkg or other package managers. Rock your Linux box and enjoy!!!

Wednesday, September 12, 2007

File type description

You must have used ls -l and recieved output something like this one.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r-- 1 jitendra jitendra 0 2007-07-28 19:19 mysqlaccess.log
drwxr-xr-x 11 jitendra jitendra 4096 2007-05-17 03:51 netbeans-5.5
-rw-r--r-- 1 root root 806 2007-05-04 13:49 python-defaults_2.5.1-0ubuntu3.dsc
-rw-r--r-- 1 jitendra jitendra 102447 2007-05-10 17:03 showthread.html
-rw-r--r-- 1 jitendra jitendra 29976 2007-09-06 18:02 ubuntu-files
-rw-r--r-- 1 jitendra jitendra 123 2007-08-26 21:11 version.h
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Do you know what does the first characeter in the line denote? Basically, it denotes the file type. In the above output, you find '-' and 'd' as first characters but these are not the only ones. Let me tell you about the possible options and their meanings.
d         The entry is a directory.
As is clear, the entry denotes a directory.

D The entry is a door (Solaris).
The concept of door is derived from Solaris.

l The entry is a symbolic link.
Symbolic links are like shortcuts (M$-Windows naming convention).
l denotes
symbolic links. Use ln command to create symbolic links.

b The entry is a block special file.
As you may be aware that Linux treats every device as a file.
b denotes file
corresponding to block devices like disk partition,
RAM, etc.


c The entry is a character special file.
This is for another type of device called character devices. These
are not
hardware device. The entries falling under this category are
console, tty, etc.


p The entry is a FIFO (or "named pipe") special file.
Unlike normal files, "named pipe" do not contain any user information and
facilitate communication between two processes by reading/writing from/to
this
file.

s The entry is an AF_UNIX address family socket.
As is clear, this file is for socket connection.The connection is internal
and
can't be invoked from outside.

- The entry is an ordinary file.
The files we create are generally of this type.
The text files, graphics and
all other are candidate of this type of file.

If you have never come across these symbols, use 'ls -l' in /dev directory. You will find most of them. However, if you are an end-user, you will never need to create files of type except '-', 'd' and 'l'.

What type of file types did you locate?

Saturday, September 8, 2007

Linux knows your fortune

Yup, that's true. Linux knows your fortune. Do you want to know yours?
Go to console and type
$ fortune fortunes.

For me it was
You are taking yourself far too seriously.
Ha ha!! What fortune Linux predicted for you?

Type the same command again and again to see more predictions.

Basically, fortune maintains text files from which it selects a random epigram. In the above command fortune is the name of command and fortunes is the category. You can choose from a lot many categories. To see the categories available to you, type
$ fortune -f

And say you want something on love, type
$ fortune love

The output that appeared on my monitor was
People think love is an emotion. Love is good sense.
-- Ken Kesey

You can simply type fortune to see output from a random category.
The best output I found was
C:\> WIN
Bad command or filename

C:\> LOSE
Loading Microsoft Windows ...

But if you are the one who easily gets offended, please please don't install the package fortunes-off. Don't install it rather than being offended. And go through the manual for more options.
$ man fortune

May Linux have good fortunes in store for you.

Was that wonderful? Please, share.

Friday, September 7, 2007

Displaying uncommented and non-blank lines

If your file is too long with lot of blank and commented lines, this might be the thing you have been looking for: Displaying uncommented and non-blank lines.
Let me explain this with an example of a file that contains a few typical lines from xorg.conf. I call this file neat_file and in my case it looks like this.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
#InputDevice "stylus" "SendCoreEvents"
#InputDevice "cursor" "SendCoreEvents"
#InputDevice "eraser" "SendCoreEvents"
EndSection

Section "DRI"
Mode 0666
EndSection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let me dissect this problem in portions to ensure that you understand this properly.

$ grep -v '^$' neat_file
^ denotes the beginning of the line and $ denotes the end of the line. So, '^$' denotes blank lines. -v option inverts the selection. Hence, what we get is the non-blank lines. With this half the task is done.

$ grep -v '^#' neat_file
This command is similar to one above except the fact that it looks for lines starting with #. Alas! it doesn't work. It is because in our case the commented lines begin with blank space not #. So, what is the solution?

$ grep -v ^' *#' neat_file
* represents zero or more occurrences. Since, * is preceded by blank space and followed by a #, it will look for zero or more occurrences of blank space followed by a #. And, as usual -v will invert the selection and give those lines which do not match this pattern that is uncommented lines.

Now, how to combine these commands to get desired result?

$ grep -v '^$' neat_file |grep -v ^' *#'
| combines different commands.

Was that useful? Do, comment.

Monday, September 3, 2007

Review of B3 web-browser

Have you ever heard of B3 (browser-based-browser)? It is a product by AOL. If you are still trying to figure out what is browser-based-browser, let me tell you it is a web-browser that runs inside another web-browser. I am writing a short review of my experiences with this browser. I have tried B3 with firefox, konqueror and elinks. But the results seem to be similar for other browsers as well.
I came across this web-browser while I was searching for something else. A web-browser by AOL, it sounded great to me. So, I thought to find out what it was. I came to know it can run in inside your web-browser on different platforms and according to them it can run on Internet Explorer, Firefox, Safari, Opera and many other browsers. I couldn't understand what could be the use of a browser that needs the support of other browser. Anyways i thought why not give it a try? Guess what, no need to download packages. Just click this link users.aol.com/stevejrice/b3browser/browser.html
and your browser may look like this if you are using firefox.


When I chose OK, the alert message was displayed which said "Most excellent choice!". But you will run into trouble with the alert boxes popping out regularly which say "Gotcha! April Fools! hee hee..." in case you choose Cancel.
Anyways, I typed in the navigation bar provided by AOL www.google.com and as expected google search page was there. I tried it out for yahoo and many others. It worked. But to much dismay, the excitement ended here. When you click on a hyperlink, the navigation bar's URL doesn't change on AOL. While on your original browser (firefox or any other), the URL displayed is the URL of B3 and not the page you are currently visiting. So, it is very difficult to figure out the page URL you have currently opened. It was really getting difficult for me to bear with this so called browser and understand why AOL designed it.
The biggest shock came to me when I tried to test the browser's support for plugins. I opened same page in B3 (firefox) as well as B3 (konqueror) which required JRE (Java Runtime Environment) enabled. JRE is enabled in my Firefox but not in konqueror. The page in firefox opened while not in Konqueror. That was a shock!!!
I thought if I had carried on with it that much, why not try it in elinks too. The browser opens but URLs typed can't be opened.
The AOL claims its browser is for consistency and gaming. Though the product is still in alpha phase according to the link I found, I simply disagree with the idea of a browser inside another browser which is doing absolutely fine.
What I can understand is that B3 is merely a ad on top of your page in the browser displayed for free (atleast adsense pays you for the ads on the page) that forwards the URL typed in its input box to your original browser. Otherwise, why different results in case of Jave enabled page. I may be wrong but it was my experience.
Try out and post your experience in the comments.

Saturday, September 1, 2007

BVS, First Private School to opt for Linux!!!

It may sound astonishing to many that in Nepal school computer lab runs on Linux. But it's true.
LTSP (Linux Terminal Server Projects) has already been running in 4 schools in Nepal (in Dang, Bhaktapur, Phulchowki, Myagdi). Several projects are still under planning. These projects were funded by HeNN (Help-Nepal) and MPP (Madan Puraskar Pustakalaya). Luckily, I was a part of the project in Bhaktapur funded by Help-Nepal.
But today (September 1, 2007) is a special moment in the FOSS (Free and Open Source Software) history of Nepal because today Brihaspati Vidya Sadan (BVS), Naxal, a reputed school in the capital got Linux installed in the PCs in its computer Lab. I was lucky this time too. I was part of this historic moment as well.
Around a month ago, we were in Brihaspati Vidya Sadan for the FOSS awareness program. We get presentation on what is FOSS, why use FOSS and blahh blahh. Mr. Pravin Joshi, the computer teacher had already been using Linux in his PC at home. He was so impressed and positive that he asked Shishir Dai (our senior and motivator) to help setup Linux in computer lab in the school. This must be the first in Nepalese history that school administration has approached for getting FOSS implemented in its lab. I must say even the students were really sharp and keen to try things. And, so we were there today to install Linux.
The computers didn't have cdrom so the installation method preferred was Net-Boot. Shishir dai configured his laptop for DHCP (Dynamic Host Communication Protocol) and TFTP (Trivial File Transfer Protocol).
And made the Ubuntu available on his apache server. While, Ujjwal helped debug the errors that occured, we (me and my classmates along with a junior Kulchandra) looked at the installation in the PCs. The computers, hence, were ready to install Ubuntu from Network. And now Linux co-exist on the PCs with MS-Windows. Though, some additional packages still need to be installed which will soon be done, the greatest achievement is at least students have something to start with and know that much exist beyond Windows.
For the qbasic programming (that is a part of the curriculum for computers), we will we installing dosbox and wine. Besides, we will have bluefish editor, gcompris suite and other stuffs.
Hats off to Pravin Dai, BVS, Shishir dai who have reached a milestone with this step and have set example for other schools. I wish this step helps government consider for a syllabus based on Free and open source rather than propritory.

Cheers