View Antoni Milton's profile on LinkedIn

Thursday, October 14, 2010

In Linux anything is equivalent to windows registry?

I saw the questions in many Linux forums

The RPM package information stored in the below location

[root@hostrpm]# ls
Basenames     __db.000  __db.002  Dirnames  Group       Name      Providename     Pubkeys      Requireversion  Sigmd5
Conflictname  __db.001  __db.003  Filemd5s  Installtid  Packages  Provideversion  Requirename  Sha1header      Triggername

It uses Berkeley DB as its back-end. It consists of a single database (Packages) containing all of the meta information of the installed rpms.
The RPM database is used to keep track of all files that are changed and created when a user installs a package. If the database gets corrupted, the index databases can be recreated with the rpm --rebuilddb command.

If you issues the rpm- qa ( query ) command then, it will read from the DB and list out the package names.

If you delete the installation directory directly, it won’t delete the record from the RPM DB. For that you need to execute the rpm –ivh (uninstall ) command , otherwise you can’t install the same package.

Thursday, July 8, 2010

How to check CPU and memory Hardware detials in RHEL system?

Using the bellow command, we can see the Memory and CPU related hardware details

#cat  /proc/meminfo

#cat  /proc/cpuinfo

Wednesday, June 9, 2010

How to write / setup SCTP client server program in RHEL system?


Before run any SCTP application, we need to install SCTP libs from

Using the below command, register the SCTP module into kernel.

#modprobe sctp

SCTP Application writing:-

SCTP client and server system call follow same as TCP. ( like socket,bind,listen and accept )

Creating SCTP socket


Before listen, we need to set the value for the no.of stream for the socket using setsockopt system call.

struct sctp_initmsg startupsctp;

startupsctp.sinit_num_ostreams = 3;

startupsctp.sinit_max_instreams = 3;

startupsctp.sinit_max_attempts = 4;

ret = setsockopt( listen_Socket, IPPROTO_SCTP, SCTP_INITMSG, & startupsctp, sizeof(startupsctp) );

Using sctp_sendmsg() and sctp_recvmsg() system calls , we can send/receive data over the SCTP socket.

Example code:-

Please refer :

Tuesday, May 25, 2010

How to decompress the tar.bz2 format file?

#tar -xvjf xxxx.tar.bz2


* x - extract
* c - create to create
* v - verbose
* z - gzip
* j - bzip2 ( .bz2 )
* f - file name ( after the “f” indicate the input/output file name )

Monday, April 5, 2010

How to prepare ISO image and test it?

An ISO image is an archive file/disc image of an optical disc in a format defined by the International Organization for Standardization (ISO). ISO image files typically have a file extension of .iso

Create folder name with "


copy your application/package/rpm/script file into the folder
#cp /root/test/ .

run the below command for creating the iso image with the name of add.iso

#cd ..

#mkisofs -l -r -N -d -D -J -o add.iso -V "Add-1.0" -A "Add program for ISO image test" cd

Warning: creating filesystem that does not conform to ISO-9660.
Total translation table size: 0
Total rockridge attributes bytes: 247
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used c000
182 extents written (0 MB)

cd add.iso

Monday, March 29, 2010

How to find the particular package installed or not?

Using “rpm –qa ” command, we can find whether the package installed or not.

Below shell script use the command for determine the given string/name package rpm installed or not installed.



rpm -qa "*$1*" > r1
line_no=$( wc -l < r1 )
echo "$line_no"
if [ $line_no == 0 ]
echo "rpm not installed "
echo "rpm installed "


[root@home linux]# ./ milton
rpm not installed
[root@home linux]# ./ boost
rpm installed

How to find which rpm (package) install the particular file?

Using “rpm –qf” command, we can find the rpm package name for the lib file.


[root@home linux]# rpm -qf /usr/lib/

[root@home linux]# rpm -qf /usr/include/boost/blank.hpp

Sunday, March 14, 2010

How to check the given string is valid IPAddress or Domain Name?

Using inet_pton function we can determine, whether given string is a valid IPv4/v6 Address or Domain name.

In below example,

first check the given string is a valid Ipv4 address not then check valid Ipv6 address and check the input string as a valid domain name.

int CheckIPAddress( const char* pszHostName)
int iResult =0; // 1 - Ipv4,2-Ipv6, 3- domain name, 0-invalid ip

struct sockaddr_in sockAddr;
struct in_addr addr;
struct in6_addr aadrv6;
struct hostent *host;
int iTemp = inet_pton(AF_INET, pszHostName, &(sockAddr.sin_addr));
if( iTemp == 1 ) // vaild IPv4 Address
iResult = 1;
else if( inet_pton(AF_INET6,pszHostName,&aadrv6 ) == 1)
iResult = 2;
else // may be a domain name. try convert in to Ipv4 Address
if (( host = gethostbyname( pszHostName )) != NULL )
addr.s_addr = *(u_long *) host->h_addr_list[0];
printf("IPAddress: %s\n", inet_ntoa( addr) );
iResult = 3;
return iResult;

Thursday, March 11, 2010

How to convert domain name to IPAddress in C++?

Using the gethostbyname() system call we can get the IPAddress from domain name. Below given example program , convert the domain name to IPAddress and print the IPAddress in "." format ( )

#include "stdio.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "netdb.h"
#include "netinet/in.h"
#include "arpa/inet.h"

int main(int argc,char * argv[])

struct hostent *host;
struct in_addr addr;
if( argc != 2 )
printf("usage: ./a.out "domainname" ");
return 0;

if ((host = gethostbyname(argv[1])) == NULL) {
printf("error resolving hostname..\n");
return -1;

addr.s_addr = *(u_long *) host->h_addr_list[0];
printf("IP: %s\n", inet_ntoa( addr ) );
return 0;

Tuesday, March 9, 2010

Track your expense in online – simple personal accounting online software

How to pass arguments for make file?

we can pass the arguments to makefile like below,

make -f Makefile HOST_OS="Linux"

in Makefile,we can use HOST_OS macro as usual.


in main_folder make file,


cd Sub_folder && make -f Makefile HOST_OS=$(HOST_OS)

in Sub_folder make file,

ifeq ($(HOST_OS),Linux)
[ tab] g++ main.cpp
[tab] cc main.cpp

Friday, February 26, 2010

How to check the directory exists or not from Makefile??

If the directory exists means, no need to untar the file.


if test -d DIR_NAME ; then echo NO NEED TO UNTAR ; else tar -xvf FILE.tar ; fi

Thursday, February 4, 2010

Singleton Design Pattern with example C++ code

The Singleton design pattern ensures only one instance of a class in an application. For example, Interfaces object need by both GUI and Back-end class. But only one interface object enough for the whole application (GUI + interface + Back-end)

Here need to develop the interface class as a Singleton class.

static CInterface *s_ptrInterface = 0;

class CInterface
~ CInterface();
static CInterface* getInterface()
 lock(); // for thread safe.
if( 0 != s_ptrInterface )
s_ptrInterface = new CInterface();

return s_ptrInterface ;
Need to create the object for CInterface like below,
CInterface:: getInterface() // it’s always return the same object

Wednesday, February 3, 2010

Photograph Puzzle Maker

try this site,

Tuesday, February 2, 2010

Object slicing example in C++

class Pet


string pname;


Pet(const string& name) : pname(name) {}

virtual string name() const { return pname; }

virtual string description() const { return "This is " + pname; }


class Dog : public Pet


string favoriteActivity;


Dog( const string& name, const string& activity): Pet(name), favoriteActivity(activity) {}

string description() const { return Pet::name() + " likes to " + favoriteActivity; }


void describe(Pet p)

{ // Slices the object

cout << p.description() << endl;


int main()


Pet p("Alfred");

Dog d("Fluffy", "sleep");