Online Labs

November 18, 2008

Network & Operating System

Filed under: Uncategorized — sarjukottapuram @ 8:27 am

LINUX – THE OS

Linux is a Unix-like computer operating system. Linux is one of the most prominent examples of free software and open source development; its underlying source code can be modified, used, and redistributed by anyone, freely.

            The Linux kernel was first released to the public on 17 September 1991, for the Intel x86 PC architecture. The kernel was augmented with system utilities and libraries from the GNU project to create a usable operating system, which later led to the alternate term GNU/Linux.Linux is now packaged for different uses in Linux distributions, which contain the kernel along with a variety of other software packages tailored to requirements.

Predominantly known for its use in servers, Linux has gained the support of corporations such as IBM, Sun Microsystems, Hewlett-Packard, and Novell, and is used as an operating system for a wide variety of computer hardware, including desktop computers, supercomputers, and embedded devices such as mobile phones and routers.

The Unix operating system was conceived and implemented in the 1960s and first released in 1970. Its wide availability and portability meant that it was widely adopted, copied and modified by academic institutions and businesses, with its design being influential on authors of other systems.

A 2001 study of Red Hat Linux 7.1 found that this distribution contained 30 million source lines of code. Using the Constructive Cost Model, the study estimated that this distribution required about eight thousand man-years of development time. According to the study, if all this software had been developed by conventional proprietary means, it would have cost about 1.08 billion dollars (year 2000 U.S. dollars) to develop in the United States.

Most of the code (71%) was written in the C programming language, but many other languages were used, including C++, Lisp, assembly language, Perl, Fortran, Python and various shell scripting languages. Slightly over half of all lines of code were licensed under the GPL. The Linux kernel itself was 2.4 million lines of code, or 8% of the total

 

Programming on Linux

Most Linux distributions support dozens of programming languages. Core system software such as libraries and basic utilities are usually written in C. Enterprise software is often written in C, C++, Java, Perl, Ruby, or Python. The most common collection of utilities for building both Linux applications and operating system programs is found within the GNU toolchain, which includes the GNU Compiler Collection (GCC) and the GNU build system. Amongst others, GCC provides compilers for C, C++, Java, and Fortran. The Linux kernel itself is written to be compiled with GCC.

Most also include support for Perl, Ruby, Python and other dynamic languages. Examples of languages that are less common, but still well-supported, are C# via the Mono project, and Scheme. A number of Java Virtual Machines and development kits run on Linux, including the original Sun Microsystems JVM (HotSpot), and IBM’s J2SE RE, as well as many open-source projects like Kaffe. The two main frameworks for developing graphical applications are those of GNOME and KDE. These projects are based on the GTK+ and Qt widget toolkits, respectively, which can also be used independently of the larger framework. Both support a wide variety of languages. There are a number of Integrated development environments available including Anjuta, Eclipse, KDevelop, MonoDevelop, NetBeans, and Omnis Studio while the traditional editors Vim and Emacs remain popular.

            Although free and open source compilers and tools are widely used under Linux, there are also proprietary solutions available from a range of companies, including the Intel C++ Compiler, PathScale, Micro Focus COBOL, Franz Inc, and the Portland Group.

                  We use here, vi editor for all entering and editing purposes. The commands used in vi editors are….

To Start

                  To use vi on a file type in vi filename. If the file named filename exist, then it wthe file will be displayed,otherwise an empty file and screen are created into which you may enter the text.

vi filename –edit filename startng at line 1

vi –r filename recover filename that was being edited when system crashed.

To Exit vi

                 Usually the new or modified filename is saved when you leave vi. However it also possible to quit without saving the file.

:x<return>  – quit vi, writing out modified file named in original invocation.

:wq<return>  – quit vi, writing out the modified file to file named in original invocation.

:q< return> -quit(or exit) vi.

: q!<return> -quit vi even though latest cvhanges have not been saved for this vi call.

Moving the cursor

                 The symbol ^ shown below , before  a letter means that the <ctrl>key should be held down while the letter is pressed.

J or ,return>{or down arrow]  – move the cursor down one line.

K[or up-arrow]   – move the cursor up one line.

H or <Backspace>[or left arrow] –move cursor left one character.

L or <space>[or right arrow]  -move cursor right one character.

0(zero)  -move cursor to start of the current line.

$  -move cursor to end of current line.

w –move cursor to the beginning of the next word.

B  -move the cursor back to beginning of the preceeding word.

:0<return>or 1G  -move the cursor to first line in file.

:n<return> or nG  -move the cursor to line n.

:$<return> or G  -move cursor to last of the line.

 Screen Manipulation

                 The following commands allow the vi editor screen(or window) to move up or down several lines and to be refreshed.

^f  -move forward one screen.

^b –move backward one screen.

^d –move down(forward) one half screen.

^u –move up(back) one half screen.

^l – redraws the screen removing the deleted lines.

Inserting or Adding  Text

                 The following commands allow you to insert and add text. Each of these commands puts the vi editor into insert mode; thus the >Esc> key must be pressed to terminate the entry of thetext and to put the vi editor back into command mode.

i  – insert text before cursor, until<Esc> hit.

I – insert text at begginning of current line, until<Esc> hit.

a – append text after cursor, until <Esc> hit.

A –append text to end of the current line,until<Esc> hit.

o –open and put text in a new line below current line, until<Esc>hit.

O –open and put text in anew line above current line, until <Esc> hit.

Deleting Text

 The following commands allow you to delete  text.

x- delete single character under cursor.

Nx –delete N characters, starting with character under cursor.

dw – delete the single word beginning with the character under cursor.

dNw – delete N words beginning with the character under cursor.

D – delete the remainder of line,starting with current cursor position.

dd –delete entire curent line.

Ndd or dNd –delete N lines beginning with the curent line.

Cutting and Pasting Text

                 The following commands allow you to copy and paste text.

yy  – copy(yank,cut)the curent line into buffer.

Nyy or yNy –copy(yank,cut) the next N lines, including the curent line, into the buffer.

p –put(paste) the line(s) in the buffer into the text after the current line.

Searching Text

                 A common occurences in text editing is to replace one word or phrase by another.To locate instances of particular sets of characters(or strings), use the following commands.

/string –search forward for occurrence of string in text.

?string –search back ward for occurences of string in text.

n –move to next occurrence of search string.

N –move the next occurence of search string in opposite direction.

Saving and Reading Files

                 These commands permit you to input and output files other than the named file with which you are currently working.

:r filename<return> -read file named filename and insert after current line.

:w<return> -write current contents to file named in original vi call.

:w newfile<return> -write current contents to a new file bnamed newfile.

:12,35w smallfile<return> -write the contents of the lines numbered 12 through 35 to a new file named smallfile.

:w! prevfile<return> – write curent contents over a pre-existing file named prevfile.

GCC Commands

gcc programname.c –This compile and link the program and a.out file is created . This can be executed by ./a.out .

gcc –o outputprogramname programname.c- This compile and link the programand a.out file is created. This can be executed by outputprogramname.

gcc –o outputprogramname programname.c-lpthread – To compile with threads

Advertisements

Blog at WordPress.com.