nav-left cat-right
cat-right

DNS root nameservers...

A root name server is a name server for the Domain Name System’s root zone. It directly answers requests for records in the root zone and answers other requests returning a list of the designated authoritative name servers for the appropriate top-level domain (TLD). The root name servers are a critical part of the Internet because they are the first step in translating (resolving) human readable host names into IP addresses that are used in communication between Internet hosts.

When a computer on the Internet needs to resolve a domain name, it uses resolver software to perform the lookup. A resolver breaks the name up into its labels from right to left. The first component (TLD) is re-queried using a root server to obtain the responsible authoritative server. Queries for each label return more specific name servers until a name server returns the answer of the original query.

There are currently 13 root name servers specified, with names in the form letter.root-servers.net, where letter ranges from A to M. This does not mean there are 13 physical servers; each operator uses redundant computer equipment to provide reliable service even if failure of hardware or software occur. Additionally, nine of the servers operate in multiple geographical locations using a routing technique called anycast, providing increased performance and even more fault tolerance.

The choice of 13 nameservers was made because of limitations in the original DNS specification, which specifies a maximum packet size of 512 bytes when using the User Datagram Protocol (UDP). The addition of IPv6 addresses for the root nameservers requires more than 512 bytes, which is facilitated by the EDNS0 extension to the DNS standard. While only 13 names are used for the root nameservers, there are many more physical servers; C, F, I, J, K, L and M servers now exist in multiple locations on different continents, using anycast address announcements to provide decentralized service. As a result most of the physical root servers are now outside the United States, allowing for high performance worldwide.

Reference: http://en.wikipedia.org/wiki/Root_nameserver

~mohammed

GEC Palakkad: The main building Inauguration Postp...

What we feared has happened, the inaugural function has been postponed due to the inconvenience of CM of Kerala. So the drama continues and we still have to wait……

Official mail from Principal says:
———————
We are sorry to inform you all that the college main building inauguration scheduled to be held on 16 February 2010, is postponed due to a sudden change in schedule of our chief guest, Mr. V.S Achuthanandan – C M of Kerala. The new date will be announced soon and all of you will be informed through the same channel.
———————

The students always strike to break something up… why don’t they utilize this chance to change that image. Just force officials to make use of the new building. Let the Politicians come and inaugurate when they get time :-D . What do you say?

~mohammed

Bash script to generate cPanel user files...

Don’t have your domains listed in WHM/cPanel. The cPanel takes information from cPanel user files under /var/cpanel/users/. The accounts won’t be listed in WHM if corresponding files are missing. This script will help you to generate cPanel user files.

This script may fail if you have cPanel user files existing under /var/cpanel/users/. So I would request you to backup users directory and then remove all user files.

[cc lang="bash"]mv /var/cpanel/users /var/cpanel/users.bkp
mkdir /var/cpanel/users[/cc]

You must run /scripts/updateuserdomains after generating cPanel user files to rebuild the system caches.

[cc lang="bash"]#!/bin/bash

#################################################################################################
# #
# Bash script to generate cPanel user files. #
# #
# Don’t have your domains listed in WHM/cPanel. The cPanel takes information from #
# cPanel user files under /var/cpanel/users/. The accounts won’t be listed in WHM #
# if corresponding files are missing. This script will help you to generate cPanel user files. #
# #
# You must run /scripts/updateuserdomains afterwards to rebuild the system caches. #
# #
# Written By: Mohammed Abdurahiman #
# Date: Feb-5-2010 #
# #
#################################################################################################

# create a temporary directory and copy required files to it.

mkdir /root/tmpdir
cd /root/tmpdir/
cp /etc/userdomains /root/tmpdir/

# Edit the line below to correct username
cp /var/cpanel/users/user1 /root/tmpdir/template

if [ ! -f /root/tmpdir/template ]; then

cat << EOL

/root/tmpdir/template file missing.
/root/tmpdir/template is a cPanel user file for reference.
If you have any file exists under /var/cpanel/users/, edit line 21 and run this script again.
If you don’t have, you can create a test domain through cPanel which will generate one.
I will be posting an example file in my blog .

EOL
fi

# remove the extra space before usernames
sed -i ’s/ //’ /root/tmpdir/userdomains

# remove last entry from userdomains *:nobody
sed -n -i $d /root/tmpdir/userdomains

# number of domains
numb=`wc -l /root/tmpdir/userdomains`

# select domain:user pair from /root/tmpdir/userdomains and then extract them.
for i in `seq 1 $numb`; do
dom_usr=`sed -n ${i}p /root/tmpdir/userdomains`
dom=`echo $dom_usr |awk -F: ‘{print $1}’`
usr=`echo $dom_usr |awk -F: ‘{print $2}’`
cp /root/tmpdir/template /var/cpanel/users/$usr

# change DNS entry
sed -i ‘/DNS/c\
DNS=’$dom’
‘ /var/cpanel/users/$usr

# change IP entry
ip=`dig +short $dom`
sed -i ‘/IP/c\
IP=’$ip’
‘ /var/cpanel/users/$usr

# change USER entry
sed -i ‘/USER/c\
USER=’$usr’
‘ /var/cpanel/users/$usr

# change MXCHECK entry
sed -i ‘/MXCHECK/c\
MXCHECK-’$dom’=0
‘ /var/cpanel/users/$usr

# change group to username
chgrp $usr /var/cpanel/users/$usr

echo Created cPanel user file for $usr

done
echo
echo Run /scripts/updateuserdomains to rebuild the system caches.
echo
[/cc]

cPanel user file template :

[cc lang="bash"]BWLIMIT=unlimited
CONTACTEMAIL=contact@yourdomain.com
CONTACTEMAIL2=
DEMO=0
DNS=domainname.com
FEATURELIST=default
HASCGI=1
IP=192.168.1.100
LOCALE=en
MAXADDON=0
MAXFTP=unlimited
MAXLST=unlimited
MAXPARK=0
MAXPOP=unlimited
MAXSQL=unlimited
MAXSUB=unlimited
MTIME=1265375424
MXCHECK-domainname.com=0
OWNER=root
PLAN=default
RS=x3
STARTDATE=1265375423
USER=username
[/cc]

~mohammed

Linux Time and Clocks...

There are two clocks in your computer. The hardware (CMOS) clock runs even when the computer is turned off, and is used when the system starts up and by DOS (if you use DOS). The ordinary system time, shown and set by date, is maintained by the kernel while Linux is running.

You can display the CMOS clock time, or set either clock from the other,
with /sbin/clock (or hwclock).

There are various other programs that can correct either or both clocks for system drift or transfer time across the network. Some of them may already be installed on your system. Try looking for adjtimex (display or set the kernel time variables), Network Time Protocol clients like netdate, getdate, and xntp, or NTP client-server suite like chrony

Setting UTC or local time
**************************
When Linux boots, one of the initialization scripts will run the /sbin/hwclock program to copy the current hardware clock time to the system clock. hwclock will assume the hardware clock is set to local time unless it is run with the –utc switch. Rather than editing the startup script, under Red Hat Linux you should edit the /etc/sysconfig/clock file and change the “UTC” line to either “UTC=true” or “UTC=false” as appropriate.

Setting the hardware clock
**************************
To set the hardware clock, set the system clock first, and then set the hardware clock to the current system clock by typing “/sbin/hwclock –systohc” (or “/sbin/hwclock –systohc –utc” if you are keeping the hardware clock in UTC). To see what the hardware clock is currently set to, run hwclock with no arguments. If the hardware clock is in UTC and you want to see the local equivalent, type “/sbin/hwclock –utc”.

Setting the system clock
**************************
To set the system clock under Linux, use the date command. Type date on command line and follow the same format to modify time and/or date.
[cc lang="bash"]
$ date
Sun Mar 13 02:32:18 IST 2008

$ date -s “Mar 13 02:32:18 2008″
[/cc]

sets the date to the above one. Here you can omit the Day of Week (which the system knows how to calculate from date) and timezone which is configured independently.

~mohammed

Linux: How to change time zone information?...

The date command can be used to reset system time, but it can’t be used used to change timezone. However, timezone reconfiguration is pretty easier.

[cc lang="bash"]# date
Sun Feb 7 21:45:53 PST 2010
# rm -f /etc/localtime
# cp /usr/share/zoneinfo/EST /etc/localtime
# date
Mon Feb 8 00:46:34 EST 2010[/cc]

The ‘timeconfig’ command can also be used to reset time/timezone information on RedHat based machines.

~mohammed

Bash puzzle: Unset last element of an array...

Here is a puzzle for bash lovers. This is taken from shell scripting community at Orkut.

Question: How to reset last element of an array even if it’s a discontinuous array.

Answer:
[cc lang="bash"]$ array=([0]=a [9]=d [2]=i [6]=k); echo “${array[@]}”
a i k d
$ : ${!array[@]}
$ unset array[_]
$ echo “${array[@]}”
a i k[/cc]

If you are not familiar with bash, you might find it difficult to understand. You can go through “man bash” for more details. See the details about : command and _ parameter from man page.

You can find these details under SHELL BUILTIN COMMANDS.

: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.

You can find these details under Special Parameters.

_ At shell startup, set to the absolute pathname used to invoke the shell or shell script being executed as passed in the environment or argument list. Subsequently, expands to the last argument to the previous command, after expansion. Also set to the full pathname used to invoke each command executed and placed in the environment exported to that command. When checking mail, this parameter holds the name of the mail file currently being checked.

~mohammed

C Programming: sizeof variable types...

As you know C programming language has different variable types and each of them use different byte size. Do you wonder how to find size of each variable type in C? Look at the program below.

Program:[cc lang="c"]
int main()
{
printf(”sizeof(char) == %d\n”, sizeof(char));
printf(”sizeof(short) == %d\n”, sizeof(short));
printf(”sizeof(int) == %d\n”, sizeof(int));
printf(”sizeof(long) == %d\n”, sizeof(long));
printf(”sizeof(long long) == %d\n”, sizeof(long long));

return 0;
}[/cc]

Output:
[cc lang="c"]sizeof(char) == 1
sizeof(short) == 2
sizeof(int) == 4
sizeof(long) == 4
sizeof(long long) == 8[/cc]

~mohammed

GEC Palakkad: The main building inauguration by Ho...

Is it true? Yes, it’s. The roars of students have pierced into the deaf ears of Kerala Govt at last and the dream is becoming true on February 16th, 2010. The latest news from college is that the main building will be inaugurated by Honorable Chief Minister of Kerala, Sri. V. S. Achuthanandan on Feb 16th.

Invitation:
invitation

gec-palakkad

The above picture was taken a few months back. Unfortunately, I don’t have the latest pictures yet, but I’ll try to add them by next week. You can find some old picture here.

I’m hereby adding the invitation email received from the Principal:
[cc lang="bash"]
Prof. Susan Abe 4th February 2010
Principal

Greetings!

We are glad to inform you that the inauguration of the main building of Govt. Engineering College, Sreekrishnapuram is scheduled to be held on 16 February 2010. The Principal, Staff, Students and the PTA of GEC Sreekrishnapuram cordially invite you to attend the function and make it a grand success

In this context, we are also placing before you an earnest request for lending a helping hand in realizing our long-cherished dream of establishing a full fledged Central Computing Facility(CCF). The equipments and accessories can be procured using the Government funds, but furnishing the hall cannot be done as desired, in a time bound manner. The estimate for furnishing the CCF is Rs. 14.54 Lakhs.

The strength of our Alumni is about 1260 and many are well placed. It might not be too difficult to raise the fund. As the proposal envisages, a central facility that will be very useful for the generations to come, it will be appropriate if the Alumni Association can sponsor the plan implementation. It may be kept in mind that GEC Sreekrishnapuram is in the 11th year of functioning, and if the Alumni takes up this task, it will be remembered forever

May I, therefore request you to rise to the occasion and help us realize this dream

Your generous contributions may please be sent to the SB Account of the Alumni Association, (A/C No: 57047348655) maintained with SBT Sreekrishnapuram branch

With warm regards,

Principal
Staff
Students, and
The PTA

[/cc]

~mohammed

apropos: search the whatis database for strings or...

Did you ever sweat as you couldn’t find which commands deal with particular keywords?

All linux users know they can get complete details about a command/system call from man pages. But, what if you don’t know the command? Yes, you can use apropos in such a situation :-) .

apropos searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output.

The man command also has search feature incorporated.

man -k  : Equivalent to apropos.
man -K  : Search for the specified string in *all* man pages. Warning: this is probably very slow! It helps to specify a section.

~mohammed

Linux: fork() system call with an example...

fork() creates a child process that differs from the parent process only in its PID and PPID, and in the fact that resource utilizations are set to 0. File locks and pending signals are not inherited.

Under Linux, fork() is implemented using copy-on-write pages, so the only penalty that it incurs is the time and memory required to duplicate the parent’s page tables, and to create a unique task structure for the child.

RETURN VALUE:
On success, the PID of the child process is returned in the parent’s thread of execution, and a 0 is returned in the child’s thread of execution. On failure, a -1 will be returned in the parent’s context, no child process will be created, and errno will be set appropriately.

$ cat fork.c
[cc lang="bash"]
#include

void main() {
int ret_fork;
printf(”My Process ID is %d \n”, getpid());
ret_fork = fork();

if( ret_fork < 0 ){
printf(”Fork failed to create child process. Exiting…\n”);
exit(-1);
}

// this will be executed by both parent and child processes
printf(”Fork was successful\n”);

// fork returns PID of child to parent process
if( ret_fork > 0 ){
// parent process
printf(”I’m the parent of child %d \n”, ret_fork);
printf(”Parent: My Process ID is %d \n”, getpid());
}

// fork returns 0 to child process
else{
// child process
printf(”I’m the child process\n”);
printf(”Child: My Process ID is %d \n”, getpid());
}
}[/cc]

[cc lang="bash"]
$ gcc fork.c
$ ./a.out
My Process ID is 5858
Fork was successful
I’m the child process
Child: My Process ID is 5859
Fork was successful
I’m the parent of child 5859
Parent: My Process ID is 5858[/cc]

~mohammed

« Previous Entries