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.