49
EX.NO :1 What is a kernel? In computing, the kernel is the main component of most computer operating systems; it is a bridge between applications and the actual data processing done at the hardware level. The kernel's responsibilities include managing the system's resources (the communication between hardware and software components). Usually as a basic component of an operating system, a kernel can provide the lowest-level abstraction layer for the resources (especially processors and I/O devices) that application software must control to perform its function. It typically makes these facilities available to application processes through inter-process communication mechanisms and system calls. what is the latest kernel used in fedora ? --2.6. Linux / Unix Command: make NAME make - GNU make utility to maintain groups of programs SYNOPSIS make [ -f makefile ] [ option ] ... target ... WARNING

CS2406 OpenSource Lab Viva Michael

Embed Size (px)

DESCRIPTION

CS2406 OpenSource Lab Viva

Citation preview

Page 1: CS2406 OpenSource Lab Viva Michael

EX.NO:1

What is a kernel?

In computing, the kernel is the main component of most computer operating systems; it is a bridge between applications and the actual data processing done at the hardware level. The kernel's responsibilities include managing the system's resources (the communication between hardware and software components). Usually as a basic component of an operating system, a kernel can provide the lowest-level abstraction layer for the resources (especially processors and I/O devices) that application software must control to perform its function. It typically makes these facilities available to application processes through inter-process communication mechanisms and system calls.

what is the latest kernel used in fedora ? --2.6.

Linux / Unix Command: make

NAME

make - GNU make utility to maintain groups of programs

SYNOPSIS

make [ -f makefile ] [ option ] ... target ...

WARNING

This man page is an extract of the documentation of GNU make . It is updated only occasionally, because the GNU project does not use nroff. For complete, current documentation, refer to the Info file make.info which is made from the Texinfo source file make.texinfo.

DESCRIPTION

Page 2: CS2406 OpenSource Lab Viva Michael

The purpose of the make utility is to determine automatically which pieces of a large program need to be recompiled, and issue the commands to recompile them. The manual describes the GNU implementation of make, which was written by Richard Stallman and Roland McGrath. Our examples show C programs, since they are most common, but you can use make with any programming language whose compiler can be run with a shell command. In fact, make is not limited to programs. You can use it to describe any task where some files must be updated automatically from others whenever the others change.

To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program, and the states the commands for updating each file. In a program, typically the executable file is updated from object files, which are in turn made by compiling source files.

Once a suitable makefile exists, each time you change some source files, this simple shell command:

make

suffices to perform all necessary recompilations. The make program uses the makefile data base and the last-modification times of the files to decide which of the files need to be updated. For each of those files, it issues the commands recorded in the data base.

make executes commands in the makefile to update one or more target names, where name is typically a program. If no -f option is present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.

Normally you should call your makefile either makefile or Makefile. (We recommend Makefile because it appears prominently near the beginning of a directory listing, right near other important files such as README.) The first name checked, GNUmakefile, is not recommended for most makefiles. You should use this name if you have a makefile that is specific to GNU make, and will not be understood by other versions of make. If makefile is`-', the standard input is read.

make updates a target if it depends on prerequisite files that have been modified since the target was last modified, or if the target does not exist.

OPTIONS

-mThese options are ignored for compatibility with other versions of make.

-C dirChange to directory dir before reading the makefiles or doing anything else. If multiple -C options are specified, each is interpreted relative to the previous one: -C

Page 3: CS2406 OpenSource Lab Viva Michael

/ -C etc is equivalent to -C /etc. This is typically used with recursive invocations ofmake.

-dPrint debugging information in addition to normal processing. The debugging information says which files are being considered for remaking, which file-times are being compared and with what results, which files actually need to be remade, whichimplicit rules are considered and which are applied---everything interesting about how make decides what to do.

-eGive variables taken from the environment precedence over variables from makefiles.

-f fileUse file as a makefile.

-iIgnore all errors in commands executed to remake files.

-I dirSpecifies a directory dir to search for included makefiles. If several -I options are used to specify several directories, the directories are searched in the order specified. Unlike the arguments to other flags of make, directories given with -I flags may come directly after the flag: -Idir is allowed, as well as -I dir. This syntax is allowed for compatibility with the C preprocessor's -I flag.

-j jobsSpecifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.

-kContinue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can beprocessed all the same.

-l-l load

Specifies that no new jobs (commands) should be started if there are others jobs running and the load average is at least load (a floating-point number). With no argument, removes a previous load limit.

-nPrint the commands that would be executed, but do not execute them.

Page 4: CS2406 OpenSource Lab Viva Michael

-o fileDo not remake the file file even if it is older than its dependencies, and do not remake anything on account of changes in file. Essentially the file is treated as very old and its rules are ignored.

-pPrint the data base (rules and variable values) that results from reading the makefiles; then execute as usual or as otherwise specified. This also prints theversion information given by the -v switch (see below). To print the data basewithout trying to remake any files, use make -p -f/dev/null.

``Question mode''. Do not run any commands, or print anything; just return an exit status that is zero if the specified targets are already up to date, nonzero otherwise.

Eliminate use of the built-in implicit rules. Also clear out the default list of suffixes for suffix rules.

Silent operation; do not print the commands as they are executed.

-S

Cancel the effect of the -k option. This is never necessary except in a recursive make where -k might be inherited from the top-level make via MAKEFLAGS or if you set -k in MAKEFLAGS in your environment.

-t

Touch files (mark them up to date without really changing them) instead of running their commands. This is used to pretend that the commands were done, in order to fool future invocations of make.

-v

Print the version of the make program plus a copyright, a list of authors and a notice that there is no warranty.

Page 5: CS2406 OpenSource Lab Viva Michael

-w

Print a message containing the working directory before and after other processing. This may be useful for tracking down errors from complicated nests of recursive make commands.

-W file

Pretend that the target file has just been modified. When used with the -n flag, this shows you what would happen if you were to modify that file. Without -n, it is almost the same as running a touch command on the given file before running make, except that the modification time is changed only in the imagination of make.

In i t r d com m a n d

In computing, initrd (initial ramdisk) is a scheme for loading a temporary file system into memory in the boot process of the Linux kernel. initrd and initramfs refer to slightly different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.

EX:2

What is virtualization?

Virtualization, in computing, is the creation of a virtual (rather than actual) version of something, such as a hardware platform, operating system, a storage device or network resources.

Virtualization can be viewed as part of an overall trend in enterprise IT that includes autonomic computing, a scenario in which the IT environment will be able to manage itself based on perceived activity, and utility computing, in which computer processing power is seen as a utility that clients can pay for only as needed. The usual goal of virtualization is to centralize administrative tasks while improving scalability and workloads.

Page 6: CS2406 OpenSource Lab Viva Michael

What is QEMU?

QEMU is a processor emulator that relies on dynamic binary translation to achieve a reasonable speed while being easy to port on new host CPU architectures.

In conjunction with CPU emulation, it also provides a set of device models, allowing it to run a variety of unmodified guest operating systems; it can thus be viewed as a hosted virtual machine monitor. It also provides an accelerated mode for supporting a mixture of binary translation (for kernel code) and native execution (for user code), in the same fashion as VMware Workstation and Virtual Box. QEMU can also be used purely for CPU emulation for user level processes, allowing applications compiled for one architecture to be run on another.

Page 7: CS2406 OpenSource Lab Viva Michael

EX:6 SAMBA

Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients." Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.

Samba is software that can be run on a platform other than Microsoft Windows, for example, UNIX, Linux, IBM System 390, OpenVMS, and other operating systems. Samba uses the TCP/IP protocol that is installed on the host server. When correctly configured, it allows that host to interact with a Microsoft Windows client or server as if it is a Windows file and print server.

EX NO 6B: CUPS

CUPS provides a portable printing layer for UNIX®-based operating systems. It has been developed by Easy Software Products to promote a standard printing solution for all UNIX vendors and users. CUPS provides the System V and Berkeley command-line interfaces.

CUPS uses the Internet Printing Protocol ("IPP") as the basis for managing print jobs and queues. The Line Printer Daemon ("LPD") Server Message Block ("SMB"), and AppSocket (a.k.a. JetDirect) protocols are also supported with reduced functionality. CUPS adds network printer browsing and PostScript Printer Description ("PPD") based printing options to support real-world printing under UNIX.

EX NO 7 GUI PROGRAMMING

QApplication Class Reference

The QApplication class manages the GUI application's control flow and main settings.

Page 8: CS2406 OpenSource Lab Viva Michael

Version Control:

A version control sys t em ( also known as a Revision Control System) is a repository of files, often the files for the source code of computer programs, with monitored access. Every change m ade to the source is tracked, along with who made the change, why they made it, and references to problems fixed, or enhancements introduced, by the change.

Version control systems are essential for any f orm o f distributed, collaborative development. Whether it is the history of a wiki page or large software development project, the ability to track each change as it was made, and to reverse changes when necessary can make all the difference between a well managed and controlled process and an uncontrolled 'first come, first served' system. It can also serve as a mechanism for due diligence for software projects.

ExamplesVersion control has been closely studied and understood in the software engineering community for a long time. The solutions are stable, robust and well-supported. There are various systems suitable for small local teams and for large distributed teams, making them ideal for coordinating software development, and for mitigating differences in culture and timezone.Version control is provided at sites such as SourceForge and Google Code. These sites typically build a suite of services around version control: archiving, release downloads, mailing lists, bug trackers, web hosting and build farms. This range of functionality makes them particularly attractive for those projects that do not have the resources to maintain their own server for version control.CVS used to be the most wdely used open source version control system but these days Subversion has overtaken it and is very commonly used in open source projects. However, some newer open source version control systems such as Arch and Git have made significant inroads. The basiccapabilities of these systems are very similar, but they offer different security, networking andabstraction functionality, and different licences. There are also many proprietary solutions available from a range of suppliers.

What is SVN (Subversion)?

Subversion is a free/open-source version control system. Subversion manages files and directories, and the

changes made to them, over time. This allows you to recover older versions of your data, or examine the history of

how your

data changed. In this regard, many people think of a version control system as a sort of “time machine”.

FUSE

Filesystem in Userspace (FUSE) is a l o a d a b l e k ernel m o d u l e f or Un i x - li k e c o m p u ter o p era t i ng

s y s t e m s th at lets non-privileged users create their own f il e s y s te m s w ithout editing k ernel c ode. This is

achieved by running file s y s tem c ode in u s er s p a c e wh ile the FUSE module provides only a "bridge" to

the actual kernel interfaces.

Page 9: CS2406 OpenSource Lab Viva Michael

Released u n d er the terms of the G NU G e n eral P u b li c L i c e n s e a nd the G NU L e ss er G e n er a l

P u b l i c L i c e n s e , F USE is f r ee s o f t war e . T he FUSE system was originally part of A V i r t u al F i l e s y s tem

( AVFS), but has since split off into its own project on S o u rc eFo r ge .n e t .

FUSE is available for L i n u x , F r e e B S D , Ne t BS D ( as p u ff s ) , O p e n S o l a r i s , a nd O S X [1

] . It was officially

merged into the mainstream L i n u x k erne l tree in kernel version 2.6.14

Virtual file system

FUSE is particularly useful for writing v i r tu a l f il e s y s te m s . Un like traditional file systems that

essentially save data to and retrieve data from disk, virtual filesystems do not actually store data

themselves. They

act as a view or translation of an existing file system or storage device.

In principle, any resource available to a FUSE implementation can be exported as a file system.

How does it work?The following figure shows the path of a filesystem call (e.g. stat) in the above hello world example:

Page 10: CS2406 OpenSource Lab Viva Michael

The FUSE kernel module and the FUSE library communicate via a special file descriptor which is obtained by opening /dev/fuse. This file can be opened multiple times, and the obtained file descriptor is passed to the mount syscall, to match up the descriptor with the mounted filesystem.

GUI PROGRAMMING USING QT

Definition: qt: Qt is a GUI software toolkit which simplifies the task of writing and maintaining GUI (Graphical User Interface) applications for the X Window System. Qt is written in C++ and is fully object-oriented. This package contains the shared library needed to run qt applications, as well as the README files for qt.

Page 11: CS2406 OpenSource Lab Viva Michael

Simple example

We start with a very simple example.

#include <QApplication>#include <QWidget>

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

QApplication app(argc, argv);

QWidget window;

window.resize(250, 150); window.setWindowTitle("Simple example"); window.show();

return app.exec();}

We will show a basic window on the screen.#include <QApplication>#include <QWidget>

We include necessary header files.QApplication app(argc, argv);

This is the application object. Each application programmed in Qt4 must

have this object. Except for console applications.QWidget window;

This is our main widget. window.resize(250, 150); window.setWindowTitle("Simple example"); window.show();

Here we resize the widget. Set a title for our main window. In this case,

the QWidgetis our main window. And finally show the widget on the screen.return app.exec();

We start the main loop of the application.

Page 12: CS2406 OpenSource Lab Viva Michael

Figure: Simple example

Centering the window

If we do not position the window ourselves, the window manager will

position it for us. In the n e xt e xample, we will center the window.

#include <QApplication>#include <QDesktopWidget>#include <QWidget>

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

int WIDTH = 250;int HEIGHT = 150;

int screenWidth;int screenHeight;

int x, y;

QApplication app(argc, argv);

QWidget window;

QDesktopWidget *desktop = QApplication::desktop();

screenWidth = desktop->width();screenHeight = desktop->height();

x = (screenWidth - WIDTH) / 2;y = (screenHeight - HEIGHT) / 2;

window.resize(WIDTH, HEIGHT);window.move ( x, y );

Page 13: CS2406 OpenSource Lab Viva Michael

window.setWindowTitle("Center");window.show();

return app.exec();}

There are plenty of monitor sizes and resolution types. In order to center a

window, we must de t e rm in e t he desktop width and height. For this, we use

the QDesktopWidgetclass.QDesktopWidget *desktop = QApplication::desktop();

screenWidth = desktop->width();screenHeight = desktop->height();

Here we determine the screen width and height.x = (screenWidth - WIDTH) / 2;y = (screenHeight - HEIGHT) / 2;

Here we compute the upper left point of our centered window.window.resize(WIDTH, HEIGHT);window.move( x, y );

We resize the widget and move it to the computed position. Note, that we

must first resize the widget. We move it afterwards.

A tooltip

A tooltip is a specific hint about a tool in an application. The following

example will demonstrate, how we can create a tooltip in Qt4 programming

library.

#include <QApplication>#include <QWidget>

int main(int argc, char *argv[]){QApplication app(argc, argv);

QWidget window;

window.resize(250, 150); window.move(300, 300); window.setWindowTitle("ToolTip"); window.setToolTip("QWidget"); window.show();

Page 14: CS2406 OpenSource Lab Viva Michael

return app.exec();}

Creating a tooltip is easy. All we do is call the setToolTip() method.window.setWindowTitle("ToolTip");

We set a tooltip for the QWidget widget.

Figure: A tooltip

The application icon

In the next example, we show the application icon. Most window managers

display the icon in the left corner of the titlebar and also on the taskbar.

#include <QApplication>#include <QWidget>#include <QIcon>

int main(int argc, char *argv[]){QApplication app(argc, argv);

QWidget window;

window.resize(250, 150); window.move(300, 300); window.setWindowTitle("icon"); window.setWindowIcon(QIcon("web.png")); window.show();

return app.exec();}

An icon is shown in the upper left corner of the window.

Page 15: CS2406 OpenSource Lab Viva Michael

window.setWindowIcon(QIcon("web.png"));

To display an icon, we use the setWindowIcon() method and a QIcon class. The

icon is a small PNG file located in the current working directory.

Figure: Icon

Cursors

A cursor is a small icon that indicates the position of the mouse pointer. In

the next example will show various cursors that we can use in our programs.

#include <QApplication>#include <QWidget>#include <QFrame>#include <QGridLayout>

class Cursors : public QWidget{public:

Cursors(QWidget *parent = 0);};

Cursors::Cursors(QWidget *parent): QWidget(parent)

{QFrame *frame1 = new QFrame(this);frame1->setFrameStyle(QFrame::Box);frame1->setCursor(Qt::SizeAllCursor);

QFrame *frame2 = new QFrame(this); frame2->setFrameStyle(QFrame::Box); frame2->setCursor(Qt::WaitCursor);

Page 16: CS2406 OpenSource Lab Viva Michael

QFrame *frame3 = new QFrame(this);frame3->setFrameStyle(QFrame::Box);frame3->setCursor(Qt::PointingHandCursor);

QGridLayout *grid = new QGridLayout(this);grid->addWidget(frame1, 0, 0); grid->addWidget(frame2, 0, 1); grid->addWidget(frame3, 0, 2);

setLayout(grid);}

int main(int argc, char *argv[]){QApplication app(argc, argv);

Cursors window;

window.resize(350, 150); window.move(300, 300); window.setWindowTitle("cursors"); window.show();

return app.exec();}

In this example, we will use three QFrames. Each of the frames will have a

different cursor defined.QFrame *frame1 = new QFrame(this); frame1->setFrameStyle(QFrame::Box); frame1->setCursor(Qt::SizeAllCursor);

This will create a frame widget. We set a specific frame style and a cursor

type.QGridLayout *grid = new QGridLayout(this);grid->addWidget(frame1, 0, 0); grid->addWidget(frame2, 0, 1); grid->addWidget(frame3, 0, 2); setLayout(grid);

This will group all the frames. We will talk more about this in the layout

management section.

Page 17: CS2406 OpenSource Lab Viva Michael

A button

In the next code example, we display a push button on the window. By

clicking on the button we close the application.

#include <QApplication>#include <QWidget>#include <QPushButton>

class MyButton : public QWidget{public:

MyButton(QWidget *parent = 0);};

MyButton::MyButton(QWidget *parent): QWidget(parent)

{QPushButton *quit = new QPushButton("Quit", this);quit->setGeometry(50, 40, 75, 30);

connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));}

int main(int argc, char *argv[]){QApplication app(argc, argv);

MyButton window;

window.resize(250, 150); window.move(300, 300); window.setWindowTitle("button"); window.show();

return app.exec();}

In this code example, we use the concept of the signals & slots for the first

time.QPushButton *quit = new QPushButton("Quit", this);quit->setGeometry(50, 40, 75, 30);

We create a new QPushButton. We manually place it to the x:50px, y:40px

position and resize it to width:75px, height:30px.connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));

Page 18: CS2406 OpenSource Lab Viva Michael

When we click on the button, a clicked() signal is generated. The slot is the

method, which will react to the signal. In our case it is the quit() slot of the

main application object. The qApp is a global pointer to the application object.

It is defined in the QApplication header file.

Figure: A button

Communicate

We will finish this section showing, how widgets can communicate together.

We will split the code into three files. So far we have used only one file. This

is possible only in small examples. Now we will have three source files.

communicate.h

#ifndef COMMUNICATE_H#define COMMUNICATE_H

#include <QWidget>#include <QApplication>#include <QPushButton>#include <QLabel>

class Communicate : public QWidget{Q_OBJECT

public:Communicate(QWidget *parent = 0);

private slots:void OnPlus();

Page 19: CS2406 OpenSource Lab Viva Michael

void OnMinus();

private:QLabel *label;

};

#endif

This is the header file of the example. In this file, we define two slots and a

label widget.

communicate.cpp

#include "communicate.h"

Communicate::Communicate(QWidget *parent): QWidget(parent)

{QPushButton *plus = new QPushButton("+", this);plus->setGeometry(50, 40, 75, 30);

QPushButton *minus = new QPushButton("-", this);minus->setGeometry(50, 100, 75, 30);

label = new QLabel("0", this);label->setGeometry(190, 80, 20, 30);

connect(plus, SIGNAL(clicked()), this, SLOT(OnPlus()));connect(minus, SIGNAL(clicked()), this, SLOT(OnMinus()));

}

void Communicate::OnPlus(){int val = label->text().toInt();val++;label->setText(QString::number(val));

}

void Communicate::OnMinus(){int val = label->text().toInt();val--;label->setText(QString::number(val));

}

We have two push buttons and a label widget. We increase/decrease the

number displayed by the label with the buttons.

Page 20: CS2406 OpenSource Lab Viva Michael

connect(plus, SIGNAL(clicked()), this, SLOT(OnPlus()));connect(minus, SIGNAL(clicked()), this, SLOT(OnMinus()));

Here we connect the clicked() signals to the slots.void Communicate::OnPlus(){int val = label->text().toInt();val++;label->setText(QString::number(val));

}

In the OnPlus() method, we determine the current value of the label. The

label widget displays a string value, so we must convert it to the integer. We

increase the number and set a new text for the label. We convert a number

to the string value.

main.cpp

#include "communicate.h"

int main(int argc, char *argv[]){QApplication app(argc, argv);

Communicate window;

window.setWindowTitle("Communicate");window.show();

return app.exec();}

This is the main file of the code example.

Figure: Communicate

Page 21: CS2406 OpenSource Lab Viva Michael

V I RTUA L IZATION

Virtualization is the creation of a vi r tu al ( rather than actual) version of something, such as an o p er a t i n g s y s t e m , a s erve r , a storage device or network resources.

You probably know a little about virtualization if you have ever divided your h a rd d rive i nto different partitions. A p a r t i t i o n is the logical division of a hard disk drive to create, in effect, two separate hard drives.

Operating system virtualization is the use of software to allow a piece of hardware to run multiple operating system images at the same time. The technology got its start on mainframes decades ago, allowing administrators to avoid wasting expensive processing power.

In 2005, virtualization software was adopted faster than anyone imagined, including the experts. There are three areas of IT where virtualization is making headroads, n e t w o r k vir tu al i z a t i o n , s t ora g e vi r tu al i z a t i on a nd server vi r tu al i z a t i o n :

Network virtualization is a method of combining the available resources in a network by splitting up the available b a nd w i d t h i nto c h a n n e l s, each of which is independent from the others, and each of which can be assigned (or reassigned) to a particular server or device in r e al t im e . The idea is that virtualization disguises the true complexity of the network by separating it into manageable parts, much like your partitioned hard drive makes it easier to manage your files.

Storage virtualization is the pooling of physical storage from multiple network storage devices into what appears to be a single storage device that is managed from a central console. Storage virtualization is commonly used in storage area networks (SA N s ).

Server virtualization is the masking of server resources (including the number and identity of individual physical servers, processors, and operating systems) from server users. The intention is to spare the user from having to understand and manage complicated details of server resources while increasing resource sharing and utilization and maintaining the capacity to expand later.

Virtualization can be viewed as part of an overall trend in enterprise IT that includesau ton omicc om pu t i ng , a scenario in which the IT environment will be able to manage itself based on

Page 22: CS2406 OpenSource Lab Viva Michael

perceived activity, and ut il i t y c om p ut i n g , in which computer processing power is seen as a utility that clients can pay for only as needed. The usual goal of virtualization is to centralize administrative tasks while improving s c al a b ili t y a nd work loads.

Page 23: CS2406 OpenSource Lab Viva Michael

10 MOST USED NETWORKING COMMANDS IN FEDORA

Linux is most powerful operating system which often needs to use c o mm an d s t o explore it effectively.Some of the commands are restricted to normal user groups as they are powerful and has more functionality involved in it.Here we summarized most interesting and useful networking commands which every linux user are supposed to be familiar with it.

1.Arp manipulates the kernel’s ARP cache in various ways. The primary options are clearing an address mapping entry and manually setting up one. For debugging purposes, the arp program also allows a complete dump of the ARP cache.ARP displays the IP address assigned to particular ETH card and mac address

[ f a s il @ s m a s h t ech ]# arAddress HWtype HWaddress Flags Mask Ifac59.36.13.1 ether C eth0

2.Ifconfig is used to configure the network interfaces. Normally we use this command to

check the IP address assigned to the system.It is used at boot time to set up interfaces asnecessary. After that, it is usually only needed when debugging or when system tuning is needed.

[ f a s il @ s m a s h t ech ~]# /sbin/ifconfigeth0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:126341 errors:0 dropped:0 overruns:0 frame:0TX packets:44441 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000

3. Netstat prints information about the networking subsystem. The type of information

which is usually printed by netstat are Print network connections, routing tables, interface statistics, masquerade connections, and multicast.

[ f a s il @ s m a s h t ech ~]# netstatActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 0 0 .230.87:https ESTABLISHEDActive UNIX domain sockets (w/o servers)Proto RefCnt Flags Type State I-Node Path unix 10 [ ] DGRAM 4970 /dev/logunix 2 [ ] DGRAM 6625 @/var/run/hal/hotplug_socket

Page 24: CS2406 OpenSource Lab Viva Michael

unix 2 [ ] DGRAM 2952 @ ude v d unix 2 [ ] DGRAM 100564unix 3 [ ] STREAM CONNECTED 62438 /tmp/.X11-unix/X0unix 3 [ ] STREAM CONNECTED 62437unix 3 [ ] STREAM CONNECTED 10271 @/tmp/fam-root-unix 3 [ ] STREAM CONNECTED 10270unix 3 [ ] STREAM CONNECTED 9276unix 3 [ ] STREAM CONNECTED 9275

4.ping command is used to check the connectivity of a system to a network.Whenever there

is problem in network connectivity we use ping to ensure the system is connected to network.

[r oo t@ s m ash t e ch ~]# ping google.comPING google.com (74.125.45.100) 56(84) bytes of data.64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=0 ttl=241 time=295 ms64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=1 ttl=241 time=277 ms64 bytes from yx-in-f100.google.com (74.125.45.100): icmp_seq=2 ttl=241 time=277 ms

--- google.com ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 6332msrtt min/avg/max/mdev = 277.041/283.387/295.903/8.860 ms, pipe 2

5.Nslookup is a program to query Internet domain name servers. Nslookup has two

modes: interactive and non-interactive. Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactivemode is used to print just the name and requested information for a host or domain.

[ f a s il @ s m a s h t ech ~]# nslookup google.comServer: server ipAddress: gateway ip 3

Non-authoritative answer: Name: google.com Address: 209.85.171.100Name: google.comAddress: 74.125.45.100Name: google.comAddress: 74.125.67.100

Page 25: CS2406 OpenSource Lab Viva Michael

6. dig (domain information groper) is a flexible tool for interrogating DNS name servers. It

performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. Other lookup tools tend to have less functionality thandig.

[f asil @smashtech ~]# dig google.com

; <<>> DiG 9.2.4 <<>> google.com;; global options: printcmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4716;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:;google.com. IN A

;; ANSWER SECTION:google.com. 122 IN A 74.125.45.100 google.com. 122 IN A 74.125.67.100 google.com. 122 IN A 209.85.171.100

;; AUTHORITY SECTION:google.com. 326567 IN NS ns3.google.com. google.com. 326567 IN NS ns4.google.com. google.com. 326567 IN NS ns1.google.com. google.com. 326567 IN NS ns2.google.com.

;; ADDITIONAL SECTION:ns1.google.com. 152216 IN A 216.239.32.10 ns2.google.com. 152216 IN A 216.239.34.10 ns3.google.com. 152216 IN A 216.239.36.10 ns4.google.com. 152216 IN A 216.239.38.10

;; Query time: 92 msec;; SERVER: 172.29.36.1#53(172.29.36.1);; WHEN: Thu Mar 5 14:38:45 2009;; MSG SIZE rcvd: 212

7.Route manipulates the IP routing tables. Its primary use is to set up static routes to specific

Page 26: CS2406 OpenSource Lab Viva Michael

hosts or networks via an interface after it has been configured with the ifconfig program.When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.

[ f a s il @ s m a s h t ech ~]# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface54.192.56.321 * 255.255.255.0 U 0 0 0 eth0

* 255.255.0.0 U 0 0 0 eth0 default 0.0.0.0 UG 0 0 0 eth0

8.Traceroute : Internet is a large and complex aggregation of network hardware,

connected together by gateways. Tracking the route one’s packets follow (or finding the miscreantgateway that’s discarding your packets) can be difficult.

Traceroute utilizes the IP protocol ‘time to live’ field and attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to some host. The only mandatory parameter is the destination host name or IP number. The default probe datagram length is 40 bytes, but this may be increased by specifying a packet length (in bytes) after the destination host name.

[ f a s il @ s m a s h t ech ~]# traceroute google.comtraceroute: Warning: google.com has multiple addresses; using 209.85.171.100 traceroute to google.com (209.85.171.100), 30 hops max, 38 byte packets1 * * *

9.W-displays information about the users currently on the machine, and their processes. The

header shows, in this order, the current time, how long the system has been running, how manyusers are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

[ f a s il @ s m a s h t ec h l ~]# w15:18:22 up 4:38, 3 users, load average: 0.89, 0.34, 0.19USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot :0 - 10:41 ?xdm? 24:53 1.35s /usr/bin/gnome-session root pts/1 :0.0 10:58 1.00s 0.34s 0.00s wroot pts/2 :0.0 12:10 23:32 0.03s 0.03s bash

10. Nmap is designed to allow system administrators and curious individuals to scan large

networks to determine which hosts are up and what services they are offering. nmap supports a

Page 27: CS2406 OpenSource Lab Viva Michael

large number of scanning techniques such as:UDP, TCP connect(), TCP SYN (half open), ftp proxy (bounce attack), ICMP (ping sweep), FIN, ACK sweep, Xmas Tree,SYN sweep, IP Protocol, and Null scan. See the Scan Types section for more details. nmap also offers a number of advanced features such as remote OS detection via TCP/IP fingerprinting, stealth scanning, dynamic delay and retransmission calculations, parallel scanning, detection of down hosts via parallel pings, decoy scanning, port filtering detection, direct (non-portmapper) RPC scanning, fragmentation scanning, and flexible target and port specification.

Significant effort has been put into decent nmap performance for non-root users. Unfortunately, many critical kernel interfaces (such as raw sockets) require root privileges. nmap should be run as root whenever possible (not setuid root, of course).

The result of running nmap is usually a list of interesting ports on the machine(s) being scanned (if any). Nmap always gives the port’s "well known" service name (if any), number, state, and protocol. The state is either"open", "filtered", or "unfiltered". Open means that the target machine will accept() connections on that port.Filtered means that a firewall, filter, or other network obstacle is covering the port and preventing nmap from determining whether the port is open. Unfiltered means that the port is known by nmap to be closed and no fire-wall/filter seems to be interfering with nmap’s attempts to determine this. Unfiltered ports are the common case and are only shown when most of the scanned ports are in the filtered state.

Depending on options used, nmap may also report the following characteristics of the remote host: OS in use, TCP sequentiality, usernames running the programs which have bound to each port, the DNS name, whether the host is a smurf address, and a few other--Network exploration tooland security scanners.

[f asil @smashtech ~]# nmap 52.194.69.152

Starting nmap 3.70 ( h tt p : / /www. i nsecure . org / n m ap/ ) at 2009-03-05 15:21 IST Interesting ports on 52.194.69.152(The 1658 ports scanned but not shown below are in state: closed) PORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind