You are on page 1of 48




Department of Computer Science and Engineering (B.E Computer Science and Engineering)


Prepared by Amudha.G Kumar.M


INTRODUCTION TO OPEN SOURCE SOFTWARE Open-source software (OSS) is computer software that is available in source code form for which the source code and certain other rights normally reserved for copyright holders are provided under a software license that permits users to study, change, and improve the software. Open source licenses meet the requirements of the Open Source Definition. Some open source software is available within the public domain. Open source software is very often developed in a public, collaborative manner. Open-source software is the most prominent example of open-source development and often compared to (technically defined) user-generated content or (legally defined) open content movements. The term open-source software originated as part of a marketing campaign for free software. Popular distributions: Well-known Linux distributions include: CentOS, a distribution derived from the same sources used by Red Hat, maintained by a dedicated volunteer community of developers with both 100% Red Hat-compatible versions and an upgraded version that is not always 100% upstream compatible Debian, a non-commercial distribution maintained by a volunteer developer community with a strong commitment to free software principles d by Red Hat Ports-like automated system for compiling applications from source code media without installation to a hard disk, derived from Debian

maintained by the French company of the same name.


Linux, maintained and commercially supported by Oracle. TÜBİTAK/UEKAE.

a community-spawned desktop distribution.

commercially supported by Red Hat. first Linux distributions, founded in 1993, and since then actively maintained by Patrick J. Volkerding.

commercially supported by Novell. ived from Debian, maintained by Canonical Ltd..

Commonly used by Linux users that wish to have the function of a bigger distro such as Ubuntu or openSuse with the speed of a smaller distro. DistroWatch attempts to include every known distribution of Linux, whether currently active or not; it also maintains a ranking of distributions based on page views, as a measure of relative popularity. STANDARD INSTALLATION OF FEDORA 14 Fedora is an RPM-based, general purpose collection of software including an operating system based on the Linux kernel, developed by the communitysupported Fedora Project and sponsored by Red Hat. The Fedora Project's mission is to lead the advancement of free and open source software and content as a collaborative community. One of Fedora's main objectives is not only to contain software distributed under a free and open source license, but also to be on the leading edge of such technologies. Fedora developers prefer to make upstream changes instead of applying fixes specifically for Fedora—this ensures that their updates are available to all Linux distributions. In 2008, Linus Torvalds, author of

the Linux kernel, started that he used Fedora because it had fairly good support for the PowerPC processor architecture which he favored at the time. Fedora Features There are some really neat, new features in Fedora that do work well. they're going to be more exiting for system administrators and developers than they are someone just running Fedora at home. Easily the most important of these is the arrival of of Simple Protocol for Independent Computing Environment (SPICE). This is a desktop presentation service protocol, like Microsoft's RDP (Remote Desktop Protocol) and Citrix's ICA (Independent Computing Architecture), that you use to run thin-client desktops.SPICE will let you support remote desktops from a Fedora server, and eventually a Red Hat Enterprise Linux (RHEL) server. Each remote desktop will run as a Kernel Virtual Machine (KVM). SPICE is being very useful in schools or anywhere that needs centralized control or inexpensive desktops. It may prove a new and interesting way to get users on a Linux "desktop."Fedora also includes a new interface: MeeGo. This is the interface for the MeeGo operating system, which is meant for netbooks, Mobile Internet Devices (MID) and embedded devices. While not as well known or as mature as Android, MeeGo shows great promise. By making it available on Fedora, developers can develop applications for MeeGo. Distribution Package Kit, the default package manager front-end on FedoraThe Fedora Project distributes Fedora in several different ways: – a DVD or CD set of all major Fedora packages at time of shipping; – CD or DVD sized images that can be used to create a Live CD or boot from a USB flash drive and optionally install to a hard disk; – used for installing over HTTP, FTP or NFS. The Fedora Project also distributes custom variations of Fedora which are called Fedora spins. These are built from a specific set of software packages and have a combination of software to meet the requirements of a specific kind of end user. Fedora spins are developed by several Fedora special interest groups. It is also possible to create Live USB versions of Fedora using Fedora Live USB creator. Fedora

2007. This was the first release of Fedora Core to include the Mozilla Firefox web browser. as well as Xen. codenamed Zod.2. there were a number of updates to SELinux.6. Fedora Core 4 was released on June 13.1. Fast user switching was fully integrated and enabled by default. The biggest difference between Fedora Core 6 and Fedora 7 was the merging of the Red Hat "Core" and Community "Extras" repositories. KDE 2.4 of the GNOME desktop environment. KDE 3. 2006. OpenOffice.2 and Firefox 2. and a new desktop theme called Nodoka. a new theme entitled Flying High. This version introduced the new Clearlooks theme. Modified). It was codenamed Yarrow. XFree86 was replaced by the newer X. as well as support for the Indic languages.5. with the codename Bordeaux.3.6. Fedora Core 1 was based on Red Hat Linux 9 and shipped with version 2. Fedora 7 featured GNOME 2. It also shipped with the OpenOffice. codenamed Heidelberg. 2003. 2007. GNOME 2. fontconfig libraries. version 2.Core:Fedora Core 1 was the first version of Fedora and was released on November 6. This version introduced support for the Compiz compositing window manager and AIGLX.19 of the Linux kernel. codenamed Moonshine.18 and KDE 3. and introduced the Fedora Bubbles artwork. Fedora Core 5 was released on March 20. 2004. and other significant improvements. 2006. and K Desktop Environment 3. It shipped with Linux 2. replacing the Fedora Bubbles artwork used in Fedora Core 5. and the new build system put in place to manage those 2. Xcursor. a merger of the previous official X11R6 release.10. Some of the new features and updates in Fedora 8 included: -config-firewall entitled Infinity.11. 2004.It was the first Fedora release to include Mono and tools built with it such as Beagle. 2005. was released on May 31. Also. and SELinux. It shipped with Linux 2. This release introduced the Fedora DNA artwork. A unique feature 5 .0 office Fedora Core 2 was released on May 18.6. F-Spot and Tomboy.Fedora 8. a high performance and secure open source virtualization framework. It was the first release to include the new Fedora Extras repository. Fedora Core 6 was released on October 24. Fedora Core 3 was released on November 8.0.4 and GNOME 2. was released on November 8. Fedora Core 3 shipped with GNOME 2. codenamed Werewolf. Fedora 7. codenamed Tettnang. which additionally included a number of updates to Xrender. with the codename Stentz. It also introduced new package management tools such as pup and pirut (see Yellowdog Updater. Xft.8 and KDE 3.

was released on June 9. Fedora 10. 2008.of Infinity is that the wallpaper can change during the day to reflect the time of day. codenamed Leonidas. like Infinity in Fedora 8. 2009. It flaunts the new Solar artwork. codenamed Sulphur. codenamed Cambridge. changes the wallpaper to reflect the time of day. Its features include: Fedora 11. Some of the new features of Fedora 9 included: Fedora 9 featured a new artwork entitled Waves for systems with fingerprint readers 6 . was released on November 25. 2008. was released on May 13. This was the first release whose artwork is determined by the name instead of by users voting on themes.Some of the features in Fedora 11 are: . Fedora 9.

" Features of Fedora 13 include: -driver & Automatic language pack installation -account tool -line interface for NetworkManager Fedora 14.Fedora 12. Fedora project-leader Paul Frields anticipated "looking at the fit and finish issues. codenamed Goddard. 2010. was released on November 17. During early development. We have tended to build a really tight ship with Fedora. 2009. codenamed Constantine. codenamed Laughlin. was released on May 25. Some of the features in Fedora 12 are: demand Fedora 13. Features of Fedora 14 include: 7 . but now we want to make the décor in the cabins a little more sumptuous and to polish the deck chairs and railings. 2010. was released on November 2.

e stack to Helios releases -v2v tool Experiment No:1 Kernel configuration . Try to view the source code of the kernel Procedure: How to: Compile Linux kernel 2.6 8 . compile the kernel and install it in the local system. compilation and Installation Aim: To Download / access the latest kernel source code from

$ cd /tmp $ wget http://www. This step by step how to covers compiling Linux kernel version 2. However. If gcc compiler and tools are not installed then use yum install command under Fedora Linux to install development tools.6.y.z.X windows (Gtk) based configuration tool. works best under KDE desktop $ make gconfig and download the latest source code.6.tar. Step # 1 Get Latest Linux kernel code Visit http://kernel.bz2 represents 2.tar.tar.25.bz2 -C /usr/src # cd /usr/src Step # 3 Configure kernel Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system. Step # 2 Extract tar (.25 kernel version.y.z. For example make menuconfig command launches a screen: $ make menuconfig 9 .6/linux-x.bz3) file Type the following command: # tar -xjvf linux-2.z is actual version This option also useful on remote server if you wanna compile kernel remotely.z with actual version number. Compiling kernel needs to understand few things and then just type couple of commands.25. # yum install gcc Now you can start kernel configuration by typing any one of the command:    $ make menuconfig .y. $ make xconfig .Compiling custom kernel has its own advantages and disadvantages.kernel.xx under Fedora Linux.6.tar.Text based color menus. where x. For example file inux2.bz2.y. File name would be linux-x. instructions remain the same for any other distribution except for apt-get command. radiolists & dialogs.bz2 Note: Replace x.tar. works best under Gnome Dekstop. However.X windows (Qt) based configuration tool. new Linux user / admin find it difficult to compile Linux kernel.

25 vmlinuz-2.25 Step # 6: Create an initrd image Type the following command at a shell prompt: # cd /boot # mkinitrd -o initrd.25 2.25 initrd images contains device driver which needed to load rest of the operating system later on./boot/grub/menu. Each configuration option has HELP button associated with it so select help button to get help. Not all computer requires initrd.lst Open file using vi: # vi /boot/grub/menu.25 config-2. Step # 7 Modify Grub configuration file . but it is safe to create one.6. Step # 4 Compile kernel Start compiling to create a compressed kernel image.6.25 Default (hd0. kernel 2.6. use su command): $ su # make modules_install Step # 5 Install kernel So far we have compiled kernel and installed kernel modules.lst title root kernel Fedora/Linux.6.6.You have to select different options as per your /boot/vmlinuz root=/dev/hdb1 ro 10 . enter: $ make Start compiling to kernel modules: $ make modules Install kernel modules (become a root user.img-2. # make install It will install three files into /boot directory as well as modification to your kernel grub configuration file:    System. It is time to install kernel itself.6.

If you think editing and writing all lines by hand is too much for you. try out update-grub command to update the lines for each kernel in /boot/grub/menu.6.img-2. Just type the command: # update-grub Neat. Huh? Step # 8 : Reboot computer and boot into your new kernel Just issue reboot command: # reboot 11 . Save and close the file.lst file.25 savedefault boot Remember to setup correct root=/dev/hdXX device.initrd /boot/initrd.

Procedure: Open a virtual machine and use Fedora iso file and follow the basic steps and install fedora 14 in the virtual machine. Step #2. Step #1. 12 .Experiment No:2 Virtualization Environment Aim: To learn virtualization with VMware workstation and to install Fedora14 in the virtual machine.

Step #5. Step #4.Step #3. 13 .

14 . Step #7.Step #6. Step #8.

as a rule of thumb. automake etc. in some cases. If any errors are reported. Generally. it will tell you that so-and-so thing is missing. cmake. configure : This step will check whether you are having all the dependencies required to install that particular software. it means there’s something wrong with the source.Step #9. and creates binaries. This could involve the full process like fetching from a cvs and also include autoconf. Step #1. by compiling from the source. and you need to install these dependencies separately. 15 . Step # 2. It invokes the appropriate compiler [gcc/g++/python etc] to compile the source. Procedure: To install a software. Experiment No:3 Compiling from source Aim: To learn about the various build systems used like the auto* family. ant etc.. instead of just running the commands. you’ll have to carry out three steps. If not. we’ll have to install these by hand. you’d be probably using yum [in fedora/RHEL] or apt-get [in ubuntu/debian]. or configure parameters. make [or gmake ] : This step will do the actual compiling. But. which are stored in the current working directory. make install [or gmake install ] : This step will copy the binaries compiled to locations like /bin or /sbin or /usr/bin etc.conf 16 .0.Step# 3.6.gz efi Store that kernel in /usr/src .PAE.0.fc14.i686 vmlinuz-2.fc14.gz stage2 vstafs_stage1_5 [root@fosslab grub]# vi grub.fc14.6.35.fc14. [root@fosslab linux]#make menuconfig [root@fosslab linux]#make [root@fosslab linux]#make install && make modules-install After executing this will update in the grub folder.35.i686 Download any stable kernel from kernel.6-45.1 [root@fosslab boot]# cp Then copy the configuration file from the existing os to that stable kernel. [root@fosslab boot]# cd grub [root@fosslab grub]# ls device.6-45.conf iso9660_stage1_5 menu.6-45.fc14. [fosslab@fosslab ~]$ uname -r 2.i686 /usr/src/linux/config Then make changes to the config file.img fat_stage1_5 grub.6.gz config-2. [root@fosslab 0]# ls /boot config-2.6.PAE xen-4.i686.35.35.fc14.xpm.6.i686.6.6-45.backup jfs_stage1_5 minix_stage1_5 splash.i686.i686 xen.PAE grub initrd-plymouth.i686 extlinux initramfs-2.fc14.img System.6-45.img System.6.lst reiserfs_stage1_5 stage1 ufs2_stage1_5 xfs_stage1_5 e2fs_stage1_5 ffs_stage1_5 grub.6. so that this can be called directly as a command.35.PAE xen-syms-4.conf.6.fc14.

RPMs are simple and reliable. Almost identical to a binary. and removing binaries. updating. For Linux newcomers or when installing a small standard component. Bear in 17 .Experiment No:4 Introduction to Package Management System Aim: Given a set of RPM or DEB. an RPM is further customized to play nicely with other RPMs and provide a consistent interface to installing. serve packages over http or ftp and also how do you configure client systems to access the package repository Procedure: RPM Installation Those of you running Red Hat Linux may want to take advantage of Red Hat's RPM ("RedHat Package Manager") system. how to build and maintain.

rpm file you obtained. Red Hat 7.rpm you're using for example: apache-1.rpm RPM should grind away.src. Yum install httpd command will install the Apache for that existing Fedora. In fedora this is easily done by running the yum command.3.2311. Or.3. substituting the name of the .mind that an Apache RPM may already be installed on your system depending on how Linux was originally installed on your computer. Navigate to the same directory as the . type: rpm -qa | grep apache If you see something like apache-1.23.23-11.src. Step 1:[root@fosslab] rpm –qa | samba 18 .rpm.3. The student can practice installing the latest version. at the shell prompt.11. an Apache RPM has already been installed. rpm -ivh apache-1.9xxx.src. You can also type that command typing httpd instead of apache to see if it’s installed.3-en/os/i386/RedHat/RPMS and download it. you must obtain one. Barring any errors. point your browser at ftp://ftp. Install samba and share files to windows Install Common Unix Printing System(CUPS) Procedure: Samba : Samba is used to communicate between linux and Windows machine.redhat. To find out.rpm in the RedHat/RPMS directory on the installation CD. If you don't have an Apache RPM. Check whether the packages are available. Of course. and then type the following command. you'll need to become root. Experiment No:5 Installing various software packages Aim: Either the package is yet to be installed or an older version is existing. If you've not already done so. you're done.3.3 ships apache-1. this might need internet access. displaying its progress with a primitive ####### progress

CUPS : Step 1:[root@fosslab]rpm –qa | grep cups. Step 2:[root@fosslab]service cups status Step 3:Move to browser and type localhost:631 19 .5-66.fc14. [root@fosslab]mkdir software [root@fosslab]service smb restart. Step 4:Type smb://server name of the windows machne.5. Similarly check the status of smb by [root@fosslab]service smbd status [root@fosslab]smbpasswd –a root To make the folders sharable [root@fosslab]vi /etc/samba/smb. Step 2:Then use the command yum install samba-3.It will list the packages for samba. Step 5: All files will be listed out.conf Type the share name and the options to be provided.i686 Step 3:Move to Linux machine and type cntrl+L to get the Location bar. [software] Path=/software Writable=yes/no Readonly=yes Public=yes Browseable=yes.

retrieve and update data. Experiment No: 6 Writing userspace drivers using FUSE Aim: To understand the concepts behind File systems in userspace and write a simple userspace drivers. A file system organizes data in an efficient manner and is tuned to the specific characteristics of the device. Insuring reliability is a major responsibility of a file system.Step4: Then a new printer can be added. Some filesystems provide mechanisms to control access to the data and metadata. Introduction: A file system (filesystem) is means to organize data expected to be retained after a program terminates by providing procedures to store. as well as manage the available space on the device(s) which contain it. Some filesystems provide a means for multiple programs to 20 . Now this printer can be added via samba. There is usually a tight coupling between the operating system and the file system.

Filesystem in Userspace (FUSE) is a loadable kernel module for Unix-like computer operating systems that lets non-privileged users create their own file systems without editing kernel code. They may provide access to data on a file server by acting as clients for a network protocol (e. any resource available to a FUSE implementation can be exported as a file system. FUSE is particularly useful for writing virtual file systems.update data in the same file nearly at the same time. SMB. or they may be virtual and exist only as an access method for virtual data (e. procfs). They act as a view or translation of an existing file system or storage device. Without a file system programs would not be able to access data by file name or directory and would need to be able to directly access data regions on a storage device. virtual filesystems do not actually store data themselves. This is achieved by running file system code in user space while the FUSE module provides only a "bridge" to the actual kernel interfaces. Creating filesystems required knowledge of kernel programming and technologies. The developer needed a good expertise in of C and C++. In principle. Unlike traditional file systems that essentially save data to and retrieve data from disk. NFS. FUSE is made up of three main parts: ● A kernel filesystem modules ● A userspace library ● A mount/unmount program The fuse distribution contains a small example program which implements a simple filesystem called the hello world filesystem which is less than a 100 lines long. 21 . or 9P clients).g.. File systems are used on data storage devices such as magnetic storage disks or optical discs to maintain the physical location of the computer files. If other programmers wanted to add features to a filesystem. A userspace filesystem is a filesystem in which data and metadata are provided by an ordinary userspace process.g. they had to gain all the knowledge which was a time consuming task. Generally filesystem development was the job of the kernel developer. This exercise consists of studying the sample code and building it and executing it on a machine..

hello_path) == 0) { 22 . static const char *hello_path = "/hello". > yum install fuse-devel First we create a new directory for this exercise. stbuf->st_nlink = 2. "/") == 0) { stbuf->st_mode = S_IFDIR | 0755. sizeof(struct stat)).h> static const char *hello_str = "Hello World!\n".c Sample code: #define FUSE_USE_VERSION 26 #include <fuse.Description: Students will study the given simple user space filesystem and implement it on their machines. struct stat *stbuf) { int res = 0.h> #include <errno.h> #include <fcntl.h> #include <stdlib. static int hello_getattr(const char *path.h> #include <string. > mkdir fuseprog > cd fuseprog > gedit hello.h> #include <stdio. Pre-requisites: The fuse package and its development files have to be installed in the system. } else if(strcmp(path. 0. memset(stbuf. if(strcmp(path.

char argv[]) { GtkWidget *window. return res. Source code: GTK Program #include <gtk/gtk. } Experiment No: 7a GUI Programming Aim: Write a GUI program using GTK or QT. 23 . stbuf->st_size = strlen(hello_str).stbuf->st_mode = S_IFREG | 0444.&argv).h> int main(int argc. stbuf->st_nlink = 1. } else res = -ENOENT. gtk_init*&argc.

} [fosslab@fosslab ~]$ vi hello.window=gtk_window_new(GTK_WINDOW_TOPLEVEL). gtk_main(). hello.0` it will show the output of window Experiment No: 7b GUI Programming Aim: Write a GUI program using GTK or QT. gtk_widget_show(window). 24 .argv).resize(100.c to compile gtk file [fosslab@fosslab ~]$ gcc -o hello hello.c `pkg-config --cflags --libs gtk+-2. QPushButton hello("Hello World").30). char *argv[]) { QApplication app(argc. Source code: QT Program #include<QApplication> #include<QPushButton> int main(int argc. return 0.

What makes a version control system useful is the fact that it allows you to explore the changes which resulted in each of those versions and facilitates the arbitrary recall of the same. return [fosslab@fosslab qtap]$ . directories over time. Of course. -o main. SVN Procedure: Version Control Basics A version control system (or revision control system) is a system that tracks incremental versions (or revisions) of files and. in some cases.-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronousunwind-tables -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt4/mkspecs/linux-g++ -I.cpp -rw-rw-r-./qtap Experiment No:8 Version Control System Setup and Usage: Aim: To setup a Version Control System and usage using RCS. } [fosslab@fosslab qtap]$ vi main. -I/usr/include/QtCore I/usr/include/QtGui -I/usr/include -I.cpp [fosslab@fosslab qtap]$ qmake-qt4 -project [fosslab@fosslab qtap]$ qmake-qt4 [fosslab@fosslab qtap]$ make g++ -c -pipe -O2 -g -pipe -Wall -Wp. we'll introduce some fairly high-level version control system components and concepts.1 fosslab fosslab 240 Jun 24 14:29 main.o main. CVS.cpp g++ -Wl.-O1 -o qtap main.1 fosslab fosslab 298 Jun 24 14:29 qtap. In this section. We'll limit our discussion to modern version control systems—in 25 .o -rw-rw-r-. merely tracking the various versions of a user's (or group of users') files and directories isn't very interesting in -I.1 fosslab fosslab 133348 Jun 24 14:29 main.o -lQtGui -lQtCore -lpthread [fosslab@fosslab qtap]$ ls -l total 260 -rw-rw-r-.1 fosslab fosslab 6475 Jun 24 14:29 Makefile -rwxrwxr-x 1 fosslab fosslab 112562 Jun 24 14:29 qtap -rw-rw-r-.exec().hello.

tar. Procedure: MYSQL INSTALLATION [root@server root]# cd /root [root@server root]# mkdir /root/files /data /data/mysql [root@server root]# cd files [root@server root]# wget http://www. add these contents into the repository first move to the location Step#4:svn add folder name then commit Step#5:svn commit -m "added files" now this will be updated in /tmp/ammu/db/revpros/ Experiment No:9 Text Processing with Perl (connecting with MYSQL): Aim: Write a simple Perl programs and connect with MYSQL's interconnected world.tar.12. [root@server root]# groupadd mysql 26 .d9x.0. Step #3:svn checkout file:///tmp/ammu here create any folders and inside a folder create a file. Step #1: svn --help go to tmp directory Step #2:svnadmin create ammu (repository name) go to another folder and copy that repository.0. there is very little point in acknowledging version control systems which cannot operate across wide-area networks.gz [root@server root]# tar xzvf mysql-4.12 if your using FreeBSD use "adduser" instead of "useradd".gz [root@server root]# cd

install: libstdc++-devel./configure --prefix=/usr/local/mysql -datadir=/data/mysqlDataDir is where your mysql databases will be stored including the database which contains all mysql user accounts.5 (or where ever it may be)if you get a "mod_auth_dbm" ErrorCopy the can easily backup all databases/users by saving the contents of this folder.[root@server root]# useradd -g mysql mysql [root@server root]# .5 is installed on your system and add the following flag to your configure statement : --with-named-curses-libs=/usr/lib/libncurses./scripts/mysql_install_db [root@server root]# ln -s /usr/local/mysql/share/mysql/mysql. example: gcc if you get " Import Database:[root@server root]# /usr/local/mysql/bin/mysql -u root -p database_name < database_name.h file from /usr/include to the /usr/include/db1 directory (or install db1-devel) if you get a "no acceptable C compiler found in $PATH" ErrorInstall a c compiler.server /sbin/mysqld[root@server root]# chown -R mysql:mysql /data/mysql [root@server root]# chown -R mysql:mysql /usr/local/mysql Set root password:[root@server root]# /usr/local/mysql/bin/mysqladmin -u root p password NEW_PASS 27 . gcc-c++ (same version as gcc) [root@server root]# make [root@server root]# make install [root@server root]# . /data/mysql NOTE: If you see ERROR: No curses/termcap library found" find where libncurses.c:1349: warning: passing arg 5 of `gethostbyname_r' from incompatible pointer type" Erroryou need to install a c++ compiler. Stop & Restart MySQL [root@server root]# mysqld start [root@server root]# mysqld stop [root@server root]# mysqld restartExport Database:[root@server root]# /usr/local/mysql/bin/mysqldump -u root -p database_name > database_name.

+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.1 First create the database as follows in mysql [linuxpert@localhost ~]$ mysql -u root -p Enter password: Welcome to the MySQL monitor.25 sec) mysql> create database student.45 Source distribution Type 'help.create the table in perl that will be automatically updated in database using mysql 1. Commands end with .' or '\h' for help.Uninstalling MySQL [root@server root]# rm -rf /usr/local/mysql [root@server root]# rm -rf /data/mysql [root@server root]# rm -rf /sbin/mysqld 1.1. mysql> show databases. Type '\c' to clear the current input statement. or \g. 28 . Your MySQL connection id is 2 Server version: 5.

00 sec) 1.fc13.609-4.Query OK.i686 29 .2 The following packages should be used to connect PERL with Mysql (use new terminal) [linuxpert@localhost ~]$ rpm -q perl-DBI perl-DBI-1. Connection id: 3 Current database: student mysql> show tables. +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | student | | test | +--------------------+ 4 rows in set (0. Database changed mysql> connect. 1 row affected (0.00 sec) mysql> use student.02 sec) mysql> show databases. Empty set (0.

3 Write the PERL script to connect with mysql as follows #!usr/bin/perl use DBI.013-3. my $dbh=DBI->connect("dbi:mysql:student"."").pl mysql> show tables.i686 1. +-------------------+ | Tables_in_student | +-------------------+ | students | +-------------------+ 30 . 1. } $sth=$dbh->prepare("create table students(rollno int.4 Run the Perl script [linuxpert@localhost ~]$ perl connect.[linuxpert@localhost ~]$ rpm -q perl-DBD-MySQL perl-DBD-MySQL-4.sname varchar(50))"). #connect to database if(!$dbh) { die("error:$!"). $dbh->disconnect.fc13."root". # create the table $sth->execute().

1 row in set (0. $dbh->disconnect.""). #to use the build in package we use "Use". insert the values in perl that will be automatically updated in database using mysql as follows #!usr/bin/perl use DBI.'rmdcse')").pl now the output is mysql> select * from students. 2. # create the table $sth->execute(). DBI is the build in package in perl my $dbh=DBI->connect("dbi:mysql:student". #connect to database if(!$dbh) { die("error:$!"). +--------+----------+ | rollno | sname | +--------+----------+ | 100 | RMDCSE | +--------+----------+ 31 .00 sec) 2. } $sth=$dbh->prepare("insert into students values(100.1 compile the perl [linuxpert@localhost ~]$ perl dbinsert."root".

$sname).1 row in set (0. $sname="CSE". compile the program as [linuxpert@localhost ~]$ perl dbinsert1. my $dbh=DBI->connect("dbi:mysql:student".00 sec) 2. } $sth=$dbh->prepare("insert into students values(?. #to use the build in package we use "Use". $dbh->disconnect. # create the table $sth->execute($rollno.?)").2 insert the values in perl using execute statement #!usr/bin/perl use DBI. +--------+----------+ | rollno | sname | | 100 | RMDCSE| 32 ."root".pl now the output is mysql> select * from students.""). #connect to database if(!$dbh) { die("error:$!"). DBI is the build in package in perl $rollno=200.

Procedure: Running PHP: APACHE INSTALLATION Introduction The Apache Web server is arguably the most popular Web server in use on the Internet today. Here are some of the reasons why Apache is so popular.| 200 | CSE| +--------+----------+ 2 rows in set (0.08 sec) Experiment No:10 Aim: Write a simple applications like login forms using PHP after setting up a LAMP stack. you don't have to be running Windows to run Apache. It was developed on various 33 .

and they have experienced no performance difficulties. it’s lack of portability limits it’s market share. If you're hosting a pretty plain Web site with mostly static content. and then recently ported to Win32. while making database calls at the same time. The Apache Web server service is near bulletproof. kill one.Unix/Linux/BSD platforms. you're going to slow it down. Apache is run on sites that get millions of hits per day. if ever. most efficient. When bugs do show up. they release patches and new versions as soon as they are available. and not from Apache. more stable. It has been tested thoroughly by both developers and users. If you throw tons of CGI scripts at it. The Apache Group maintains rigorous standards before releasing new versions of their server. Another reason for Apache's widespread acceptance is its overall stability. Internet Information Server. Though much of the slowdown will come from your scripts themselves. and their server runs without problems on over one half of all WWW servers available on the Internet. Apache is a fireball. Apache has been shown to be substantially faster. Installation Options I’ll cover three methods of installing Apache under Linux. Although certain commercial servers have claimed to surpass Apache's speed (it has not been demonstrated that any of these "benchmarks" are a good way of measuring WWW server speed at any rate). Lastly. is made for use in the "Windows-only" world. While IIS has many features. Apache evolved out of the NCSA https project to its current status as one of the fastest. and most functional web servers in existence today. While you can slow down an Apache Web server. I say "relatively" as it's relative to what you're doing with it. it's relatively fast. you can rarely. The developers of Apache feel that it is better to have a mostly-fast free server than an extremely fast server that costs thousands of dollars. Apache is run on over 10 million Internet servers (as of May 2002). The three methods are: ·Binary installation ·Using an RPM (Red Hat Package Manager) – recommended for people running Red Hat Linux ·Building from source 34 . a Web server made by Microsoft for the Windows NT platform. and more featurefull than many other web servers.

org. 3. For binary and source installations. This means you don't reap the benefits of the latest bug fixes and feature enhancements. providing you with the best of both worlds -. Apache binaries are usually a version or two behind the current source distribution. Fortunately most Apache binaries include a full source distribution. you must choose a different method of installation. A computer running Linux 2. There are. you must use a binary built specifically for FreeBSD on your FreeBSD machine and a Linux binary on your Linux machine. In other words. the tar and gunzip Unix utilities Binary Installation A binary is pre-configured. you maywant to browse over the documentation. While your downloading Apache. learn later. if you don't see a binary for your particular operating system. Now let's install a binary. This is the easiest way to install Apache for people that are new to Linux. a few things you should keep in mind: 1. Because binaries are pre-configured.apache. If you're a newcomer. Binaries are compiled for a particular operating system. 2. You need to be sure to grab the correct binary. What you need To install Apache. you don't have much opportunity to alter the way the software works. you may not care about this loss of flexibility. Point your browser at 35 .Apache Installation Guide We recommend using the RPM installation method. you will need the following things: 1. Download the Software You can download Apache from the Apache Software Foundation web site located at http://www. in source and binary forms. Root access on this computer 3. which means someone else has gone to the trouble of configuring and building the software for now. however.

sh. You'll most likely be presented with a directory containing multiple versions of Apache in various compressed forms.bindist documents for further information. Linux).35-i686-pc-linux-rh72. then the root password.gz | tar xvf – Some of you may be lucky enough to have a version of tar that is capable of taking care of both tasks. choose either the RPM Installation (if you are running Red Hat Linux) or Build from Source method. Move into the newly created directory. you'll probably want to use one of the other methods I cover in this guide.0. cd httpd-2.tar. If your binary does not seem to contain such an install script. tar xvzf httpd-2.0.tar. Then go ahead and run the install script. If you've not already done so. You can become root by typing su.0.35-i686-pc-linux-rh72. binary distributions contain an install script called install. For the purposes of this guide.http://www. Now let's uncompress the archive using the handy combination of gunzip and tar. You should replace the "httpd-2.apache. with x being the particular subversion of Apache you downloaded. take a look at the README.0. 36 . I'll assume you've downloaded the gzip'd form of the latest and download the binary for your operating system (in our case.0.gz Either way. gunzip < httpd-2.x directory. If you can't find a binary for your operating system.35-i686-pc-linux-rh72.0. you'll need to become root. you should end up with an httpd-2. if these documents don't outline a simple installation method.bindist and/or INSTALL.0.bindist.x As of Apache 1.tar.tar.gz). If there is a README associated with the file you're downloading.x Apache binary (currently that's httpd-2.gz" text below with the name of the gzip'd file you downloaded. you may want to review it for any interesting installation tidbits or possible bugs.3.35-i686-pc-linux-rh72.11.

rpm RPM should grind away.src.3 ships apache-1. an RPM is further customized to play nicely with other RPMs and provide a consistent interface to installing. That's all there is to it on installing binaries. substituting the name of the . To find out./install. Just three more commands than a binary installation and you skip the arduous task of figuring out which binary is the right one for your particular operating system. type: rpm -qa | grep apache If you see something like apache-1.apache.src.3.3.23. displaying its progress with a primitive ####### progress bar.3. Barring any errors.rpm file you obtained.. the default is usually to install everything under /usr/local/apache (confirm this by consulting your README. Navigate to the same directory as the . point your browser at ftp://ftp.bindist documents). Point your browser at http://www.3. at the shell prompt. Build from Source Building Apache from source may seem like a daunting task to newcomers. you must obtain one.redhat. If you don't have an Apache RPM. Red Hat 7.bindist. updating. you'll need to become root. For Linux newcomers or when installing a small standard You can also type that command typing httpd instead of apache to see if it’s installed.bindist and/or INSTALL. RPMs are simple and reliable. RPM Installation Those of you running Red Hat Linux may want to take advantage of Red Hat's RPM ("RedHat Package Manager") system.rpm. If you've not already done so. but the Apache developers have done a wonderful job of making the task about as simple as could and 37 .rpm you're using for example: apache-1. rpm -ivh apache-1.3-en/os/i386/RedHat/RPMS and download it. and removing binaries.11.9xxx. Bear in mind that an Apache RPM may already be installed on your system depending on how Linux was originally installed on your computer. and then type the following command. Or. an Apache RPM has already been This command should install the various bits of the Apache distribution into the appropriate locations.rpm in the RedHat/RPMS directory on the installation CD. Almost identical to a binary.src.2311. you're done.

36.. If you've not already done so.tar.36 at the time of this writing).gz | tar xvf – You should end up with an httpd-2.. i686-pc-linux-gnu Configuring Apache Portable Runtime library . Make 38 .. gunzip < httpd-2.x directory..gz below with the name of the gzip'd file you downloaded.. config.. Apache checking for working mkdir -p. now would be the time to become root.. yes checking build system type../configure checking for chosen layout.0. i686-pc-linux-gnu checking host system type.. .x Now we'll use the the configure and make commands to configure. Make'ing Apache produces screenfulls of output.. Now let's uncompress that archive using gunzip and tar. .. and install the gzip'd form of the current version of Apache (2.0./configure Your screen should look something like: # . i686-pc-linux-gnu checking target system type. You should replace the httpd2..status: executing default commands Unless errors were reported (not warnings). cd httpd-2. make.. x being the particular sub-version of Apache you downloaded.36. Move into the newly created directory. your Apache installation is now configured and we can move on.0.0. This is where things get a bit ugly.tar.

On a Red Hat system.36/srclib' Making all in apr make[2]: Entering directory `/home/ryan/dl/apache_guide/httpd2.Your screen should look something like: # make Making all in srclib make[1]: Entering directory `/home/ryan/dl/apache_guide/httpd2. http://localhost/. Quite a few Linux distributions 39 . make[1]: Leaving directory `/home/ryan/dl/apache_guide/httpd-2. Starting Apache Let's take your new Apache installation out for a spin.0. If everything worked you should see the default home page.36'# Finally. type: /sbin/service httpd start Point your browser at your brand new Web server. type: /usr/local/apache/bin/apachectl start If you used an'll find them in /etc/httpd/conf.. Customize Apache uses some rather easy to understand text files for configuration.0.36/srclib/apr'.0. you're ready to install your Apache build. # make install Now Apache is installed. as root.. If you installed Apache using a binary or from scratch. as root.

here's how you can find it. do a search for "httpd.conf". you should see these three files: ·httpd. When you move into the directory containing httpd.conf Now you should see where the file is them in this same place. Restarting Apache Whevever you make changes to the server configuration files. If you installed Apache using a binary or from scratch. In Linux.conf – This has the settings for the overall configuration for the server. type: /usr/local/apache/bin/apachectl start If you used an RPM. such as httpd. If you're new to Linux. and need help finding this file.Login as root 2.conf – This file contains the MIME definitions and default document names for files on the server. they won't take effect until the server is restarted. you've found the main config files.conf. as root. ·srm.conf.Type: cd / 3. type: /sbin/service httpd start After being restarted the changes will have taken effect 40 .Type: find -name httpd. but if you can't find such a directory. Apache can be restarted depending on how you installed it.conf – This file contains all the security settings for Apache. Once you find these. ·access. 1. as root.

} mysql_free_result($res).'root'. $db=mysql_select_db('cse'. $db=mysql_select_db('cse'.3-1. ?> <?php $con=mysql_connect('localhost'. ?> <?php $con=mysql_connect('localhost'. while($row=mysql_fetch_row($res)) { print "$row[0] $row[1] <br >".$con). if(!$res) { print "Table created".fc14.'root'.CONNECT PHP WITH MYSQL to check whether php mysql available [root@fosslab html]# rpm -q php-mysql php-mysql-5. $qry="select * from amu".'root'. $qry="create table amu(name varchar(10). $res=mysql_query($qry). $db=mysql_select_db('cse'.'').$con). if($res>0) { print "Table created". $res=mysql_query($qry).3. if($res>0) { 41 .i686 <?php $con=mysql_connect('localhost'.'').num int)".''). $res=mysql_query($qry). } mysql_close($con). $qry="insert into amu values('cse'.1000)". } mysql_close($con).$con).

"")or die (mysql-error()).php <?php $cid=$_POST['cid']. echo "connected to database". $cname=$_POST['cname']. $db=@mysql_select_db("cse"."root".$con)or die(mysql_error()). $con=@mysql_connect("localhost". 42 .php" method="post"> <p> "Enter course no"<input type="text" name="cid"></p> <p>"enter the coursename"<input type="text" name="cname"></p> <p>"click here to submit"<input type="submit" name="submit"></p> </form> </body> Type the following in gedit and save it as connect.html <html> <head> <title>LOGIN</title></head> <body> <form action="connect. ?> type the following in gedit and save it as form. } mysql_close($con).print "Table created".

or \g.html when u press the submit button now go to terminal [root@localhost ~]$ mysql -u root -p\ > > Enter password: Welcome to the MySQL monitor.'$cname')".echo "selected database".1. Commands end with . if($res>0) { echo "Record created".45 Source distribution mysql> show databases. $res=@mysql_query($str) or die(mysql_error()). +--------------------+ | Database | +--------------------+ 43 . } ?> TYPE THE FOLLOWING IN THE BROWSER http://localhost/form. $str="insert into courses values($cid. Your MySQL connection id is 28 Server version: 5.

| information_schema | | mysql | | student | | test | +--------------------+ 4 rows in set (0. +-------------------+ | Tables_in_student | +-------------------+ | course | | courses | | students | +-------------------+ 44 .11 sec) mysql> use student . Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> connect Connection id: 29 Current database: student mysql> show tables.

00 sec) mysql> select * from courses.02 sec) Experiment No:11 Aim: Write a simple exercise in Python and establish connection with MySql database Procedure: Running Python: 1. 45 .py #!/usr/bin/python # Hello world python program print "Hello World!".3 rows in set (0. +------+-------+ | cid | cname | +------+-------+ | 1 | java | | 1 | java | +------+-------+ 2 rows in set (0. Write a Hello World Python Program $ vim helloworld.

'dsfdf')") 46 . Verify Python Interpreter Availability Make sure python interpreter is installed on your system as shown below. check whether package MySQL-python available then we will be able to do.4 /usr/lib/python3. [fosslab@fosslab ~]$ rpm -q MySQL-python MySQL-python-1. $ python helloworld.execute("create table s(sno int.6 /usr/include/python2./helloworld.1.6 /etc/python /etc/python2.5 /usr/bin/python2. Execute Python Program You can either execute using ―python helloworld.'cse') cursor=con.c1.2.2.0 /usr/lib/python2.gz $ which python /usr/bin/python‖.execute("insert into s values(234234.5 /usr/include/python2.sname varchar(50))") cursor.i686 #!usr/bin/python print "Hello" import MySQLdb con=MySQLdb.6 /usr/local/lib/python2. $ whereis python python: /usr/bin/python /usr/bin/python2.5 /usr/lib/python2.connect('localhost'.''.cursor() cursor.5 /etc/ Hello World! Note: As python is an interpreted language.6 /usr/share/python /usr/share/man/man1/python./helloworld. you don’t have the compilation step similar to the C‖ or ―.py Hello World! ( or ) $ chmod u+x helloworld.3-0.5.5 /usr/local/lib/ $ .'root'.6 /usr/lib/python2.

DNS. Procedure: [root@fosslab]ifconfig eth0 It will display the configuration of the Ethernet.168. We can make changes to this . IP tables.1.rowcount() rows=cursor.close() Experiment No:12 Setup the complete network interface: Aim: To use ifconfig command link setting gateway.fetchall() for row in rows: print row or while(1): row=cursor.0 up [root@fosslab]route add gw netmask 255..fetchone() print rows or rows=cursor.%s" %(row[0]. [root@fosslab]ifconfig eth0 192.row[1]) con.fetchone() if row==None: break print "%d.1.cursor. etc.execute("select * from s") num=cursor.1 [root@fosslab]cd /etc/sysconfig/network-scripts 47 .255.

0 [root@fosslab]vi /etc/sysconfig/network Type Gateway=192.[root@network-scripts]vi ifcfg-eth0 Update BOOTPROTO as ―satatic‖ IPADDR= NETWORK=192.168.126 NETMASK= [root@fosslab]ifconfig [root@fosslab]service network restart [root@fosslab]ifconfig eth0 [root@fosslab]route –n 48 . [root@fosslab]vi /etc/resolv.conf Type nameserver 192.255.