Вы находитесь на странице: 1из 35

1

INDEX
Sr.no. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Name of Program Study of windows 2000 operating system. Administration of Windows 2000 (including DNS, LDAP, Directory services). Study of Linux OS (Linux kernel, shell, Basic commands pipe & filter commands). Administration of Linux operating system. Writing shell script commands. Write a shell script to generate the Fibonacci series. Write a shell script to show the factorial of a number. Write a shell script to find whether a number is prime or not. Write a shell script to find greatest of three numbers. AWK programming. Teachers signature

Exercise #1

Introduction to Windows 2000

Mainstream business desktop Full featured: Easiest Windows Yet Industrial Strength Reliability Standards-based Security State-of-the-art mobile support Plug and play, USB, IR, Hot Docking Higher performance Increased manageability Lowest TCO Desktop System Business Server Full featured: Active Directory Windows Management Tools Kerberos and PKI Security Windows Terminal Support COM+ Enhanced Internet Services Up to 4-way SMP Powerful Mid-Range Solution Full featured: Windows 2000 Server Features

TCP/IP Load Balancing Enhanced MSCS Clustering Up to 8 GB Main Memory Highest Performance Full featured: All Windows 2000 Advanced Server Features Up to 16-way SMP Up to 64 GB Main Memory 4 node clustering Optimized for: OLTP, Data Warehousing Technical Computing and Modelling Tested for the Data Centre

What is Active Directory?


Active Directory is an integral part of Windows 2000 Server that delivers essential network operating system services: Focal Point for management of network elements (users, applications, devices, etc.) Trusted Repository of security data for authentication and authorization Open Platform for application development and integration with other systems Slide Objective: Directories must seamlessly provide essential services in modern network operating systems. The Active Directory transparency delivers this functionality as an integral part of Windows 2000. A directory service is an essential and inseparable part of a modern network operating system. It has deep implications on the future of your infrastructure, your system administration practices and the overall user experience of your companys information systems. Windows 2000 provides an integrated directory service in Active Directory to simplify

management and strengthen security of your current network infrastructure and extend to future systems as your company grows. Focal Point Active Directory provides a single, consistent, point of management for users, devices and applications. It takes the place of the domain architecture of Windows NT Server and enables new, powerful management features such as Intellimirror, group policy, and automated software distribution and delegation f administration tasks. Trusted Repository Active Directory is the backbone of security for Windows 2000 Server because it acts as the single authorative point of authentication and authorization of users to access network resources. It enables the operating system to represent network resources and make them available to end users - this is essential to basic application, file and print services and represents a significant architectural change from previous version of Windows NT. Open Platform Active Directory provides a key integration point by exposing all of Windows 2000s directory features through standardsbased interfaces such as LDAP, ADSI, JADSI, and MAPI to enable integration/consolidation of your existing system and development of directory-enabled applications and networks. Presenters Notes: The main point here is that NDS for NT is technically not a very good idea in that it rips and replaces many of the core functions of the Windows NOS.

The Operating System Structure

Booting Windows 2000


Process
Idle System Smss.exe Csrss.exe Winlogon.exe Isass.exe Services.exe

Description
Not really a process, but home to idle thread Creates smss.exe &paging files; reads registry; opens DLLs First real proc; much initialization; creates csrss & winlogon Win32 subsystem process Login daemon Authentication manager Looks in registry and starts services Allows remote jobs to the printer Serves request for local files Allows remote logins Accepts and stores inbound emails Accepts and prints inbound faxes Internet domain name system server Logs various system events Monitors hardware to see what is to out there

Printer server File server telnet daemon incoming email handler incoming fax handler DNS resolver Event logger Plug and play manager

Processes starting up during boot phase Those above the line and are always started. Those below are examples of services which could be started

Ile system API Calls in Windows 2000


/* Open files for input and output*/
Inhandle=CreateFile(data, GENERIC_READ, 0, Null, OPEN_EXISTING, 0, Null); Outhandle=CreateFile(newf, GENERIC_WRITE, 0, Null, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, Null);

/*Copy the file*/


Do { S = ReadFile(inhandle, buffer, count, &ocnt, Null); If (s&& count>0) WriteFile(outhandle, buffer, count, &ocnt, Null); } While(s>0&& count>0);

/*Close the files*/


Closehandle(inhandle); Closehandle(outhandle);

Caching in Windows 2000

Disk

Disk

A program fragment for copying a file using the Windows 2000 API functions provides the means of organising the layout of the data storage in complex ways. The Shell is the command interpreter. Although the shell is just a utility program and is not properly a part of the system, it is the part that the user sees. The shell listens to your terminal and translates your requests into actions on the part of the kernel and the many utility programs. Linux is a freely available, open source, UNIX like operating system. It was written originally for the PC by Linus Torvalds {A young student in the University of Helsinki}, with the help of many other developers across the internet. Now Linux runs on multiple hardware platforms, from the smallest to the largest, and serves a wide variety of needs from servers to moviemaking to running business to user desktops.

Linux Commands

Listing Files and Directories


ls (list) When you first login to any Linux machine, your working directory is your home directory. Your home directory has the same name as your username. Example 1: to find out what is in your home directory, type: % ls There may be no files visible in your home directory, in such case, the Linux prompt will returned. Alternatively, there may be some files inserted by the system administrator when your account was created. ls doesnt, in fact, cause all files in your home directory to be listed, but only those ones whose name doesnt begin with a dot (.). Files beginning with a dot (.) are known as hidden files and usually contain important program configuration information. They are usually containing important program configuration information. They are hidden because you should not change them unless you are familiar with Linux!!!

Making Directories
mkdir (make Directory) You will now make subdirectory in your home directory to hold the files you will be creating and using in this course. Example: To make a subdirectory called ics102 in your current working directory type: % mkdir ics102 Now to see the directory you have just crested, type: % ls Please note that creating a subdirectory will not change your current position in the file system tree. Thus, after creating ics102, your current working directory still remains your Home directory.

10

Text Processing
Cat concatenate files and print on the standard output. Usage: cat [OPTION][FILE] e.g. cat file1.txt file2.txt cat n file1.txt echo display a line of text Usage: echo [OPTION] [STRING] Example: echo I love India Echo $HOME

Path names
Pwd (print working directoy): The pwd command is very useful to know your current position in the file system. It displays the full path name of your current working directory. Example: now type % pwd What is your current working directory? Be sure your current working directory is Lab00 before moving to next section. Gedit: Text Editor Program While using Linux you will often want to create a text file and then change its content in some way. A text editor is a program that has been designed especially for this purpose. gedit editor is one of the editors available in Linux.

11

Removing Files and directories


rm (Remove) rmdir (Remove Directory) To delete (remove) a file, use the rm command. However, to delete a directory use the rmdir command. There is one constraint to delete a directory; the directory must be empty. Example1: We know that your backup directory contains two files named salam.txt and salam.bak. We are going to delete the file salam.txt and, as an exercise, delete the second file. % rm backup/salam.txt Example2: If you successfully delete the two files, you can delete the backup directory. To delete the backup directory, type: % rmdir backup

System Administration
Chmod Change file access permissions Usage : chmod [OPTION] [MODE][FILE] Eg. Chmod 744 calculate.sh

Chown change file owner and group Usage : chown [OPTION] OWNER[:[GROUP]] FILE... Eg. Chown remo myfile.txt

su change user ID or become superuser usage : su [OPTION] [LOGIN]

12

eg. Su remo, su

passwd update a users authentication token(s) Usage : passwd [OPTION] Eg. Passwd

who show who is logged on Usage : who [OPTION] Eg. Who, who b, who q

Displaying the Contents of a File on the Screen


Clear (clear screen) Before you start the next section, you may like to clear the terminal window of the previous commands so the output of the following commands can be clearly understood. At the prompt, type: % clear This will clear all text and leave you with the % prompt at the top of the window.

Cat (concatenate) The command cat can be used to display the contents of a file on the screen. Example: To verify your work in previous section, you can view the content of hello.txt by typing: % cat hello.txt

13

The cat command is useful for displaying short files of a few lines. To display longer files use less or more commands.

Advantages of Linux
Affordable you pay your technical support, documentation, CD-ROM but never pay for the software (the code itself). Stability If an application crashes in Linux, it doesnt crash the entire system. Reliability Because Linux is open source and many developments are made by the users, there is no pressure to release new application or upgrades by a certain date. File System On the file systems of other operating systems, files are broken into smaller fragments that are stored in multiple locations around a hard disk, which reduces the efficiency. File creation and deletion leads to more fragmentation, which leads to lower hard disk efficiency. Security Securing Linux may take a little bit of extra knowledge, but that extra knowledge usually leads to a more secure operating system. Open Source Software Because Linux is open source, programmers around the world to develop patches whenever security holes are found. Multi-user Capabilities Linus has the abilities to handle and regulate many processes running at the same time. Linux handles multitasking very well because its memory allocation is designed to keep system lag a minimum.

Disadvantages of Linux
Because you must learn Linux commands, it takes longer to learn about Linux Printed instruction manuals and technical support is much harder to find. Configuring devices in Linux is generally more difficult. Linux doesnt have an abundance of commercial software, such as wordprocessing software, internet browsers, and games.

14

Exercise # 2 Simply Network Administration:


Service for network Telnet Client and Server Scripting PERL and Shell Command Line Windows 2000 Windows Installer Windows Scripting Host Windows Management Instrumentation Microsoft Management Console Active Directory Catalogues Are replicated within a forest Users same replication and storage mechanisms as domain replicas Each catalogue holds selectable attributes from all objects in the forest Enables efficient cross-domain data sharing

15

Network Administrator

Domain Name System (DNS)


DNS: Provides translation between host name and IP address Distributed database implemented in hierarchy of many name servers Distributed for scalability & translation Hostname to IP address translation Host aliasing - Canonical and alias names Mail server aliasing Load Distribution - Replicated Web servers : set of IP addresses for one canonical name Internet Hosts:

16

IP address(32 bit) used for addressing datagrams name, eg., www.yahoo.com used by humans

Names Hierarchy in DNS

Hostname =dot separated concatenation of domain names along path toward the root - Unc.edu - Cs.unc.edu - Classroom.cs.unc.edu Contacted by local name server that cannot resolve name Root Name Server: - Contacts authoritative name server if name mapping not known - Gets mapping - Returns mapping to local name server Top Level Domain (TLD) server: Responsible for com, org, net, edu, etc and all top-level country domains uk, fr, ca, jp, in. - Network solutions maintains servers for com TLD - Educates for edu TLD

17

Authoritative DNS Servers: organisations DNS servers providing authoritative hostname to mappings for organisations servers (e.g., Web and Mail). - can be maintained by organisation or service provider Each ISP (residential ISP, company, university) has one.

18

Exercise # 3, 4 Introduction to Linux


In order to understand the popularity of Linux, we need to travel back in time, about 40 years back Imagine computers as big as houses, even stadiums. While the sizes of those computers posed substantial problems, there was one thing that made this even worse: every computer had a different operating system. Software was always customized to serve a specific purpose and software for one given system didnt run on another system. Being able to work with one system didnt automatically mean that you could work with another. It was difficult, both for the users and the system administrators. Computers were extremely expensive then, and sacrifices had to be made even after the original purchase just to get the users to understand how they worked. The total cost per unit of computing power was enormous. Technologically the world was not quite that advance, so they had to live with the size for another decade. In 1969, a team of developers in the Bell Labs laboratories started working on a solution for the software problem, to address these compatibility issues. They developed a new operating system, which was: 1. Simple and elegant 2. Written in the C programming language instead of in assembly code 3. Able to recycle code The Bell Labs developers named this project UNIX. The code recycling feature was very important. Until then, all commercially available computer systems were written in a code specifically developed for one system. UNIX on the other hand needed only a small piece of that special code, which is now commonly named the kernel. This kernel is the only piece of code that needs to be adapted for every specific system and forms the base of the UNIX system. The operating system and all other functions were built around this kernel and written in a higher programming language, C.

19

History
Linux is a modern, free operating system based on UNIX

standards. First developed as a small but self-contained kernel in 1991 by Linus Torvalds, with the major design goal of UNIX compatibility. Its history has been one of the collaboration by many users from all around the world, corresponding almost exclusively over the internet It has been designed to run efficiently and reliably on common PC hardware, but also runs on a variety of other platforms The core Linux operating system kernel is entirely original, but it can run much existing free UNIX software, resulting in an entire UNIX-compatible operating system free from proprietary code Many, varying Linux distributions including the kernel, the applications and management tools

The kernel is that part of the operating system which manages the

resources of whatever computer system it lives on, to keep track of the disks, tapes, printers, terminals, communication lines and any other devices.

20

The file system is the organizing structure for data. The file system

is perhaps the most important part of the Linux operating system. The file system goes beyond being a simple repository for data and information.

21

Exercise # 5
Linux Shell Programming
This section on shell programming is a brief introduction to shell programming, and only talks about the bash shell. Linux Variables When variables are used they are referred to with $ symbol in front of them. There are several useful variables available in the shell program. Here are a few: $$= The PID number of the process executing the shell $?= Exit status variable $0= The name of the command you used to call a program $1= The first argument on the command line $2= The second argument on the command line $*= All the arguments on the command line $#= The number of command line arguments

The shift command can be used to shift command line arguments to the left i.e. $1 becomes the value of $2, $3 shifts into $2, etc. The command shift 2 will shift 2 places means the new value of $1 will be the old value of $3 and so forth. Iteration, Control and Conditional Statements If Used to execute one or more statements on a condition. Example: if [! d /mnt] #be sure that directory /mnt exists then mkdir /mnt fi Case Used to execute specific commands based on the values of a variable. Example:

22

case $NUM of 1) echo the number is 1 ; ; 2) echo The number is 2 ; ; *) echo The number is not 1 or 2 ; ; esac For Used to loop for all cases of a condition. In the example below, it is used to copy all files found in /mnt/floppy to the /etc directory. The lines were numbered for reference with descriptions: 1. The for loop statement will loop until all files have been found. 2. A test to be sure the file is a normal file and not a directory 3. A comment line 4. This line extracts the name of the file from its full path pointed by the variable $i and puts it in the variable $filename. The method used here is called parameter expansion and is documented in the bash main page. 5. This line sends a statement to the standard output, telling what file is being copied. 6. This line performs the copy command using the p option to preserve file attributes. Note: much ability to perform a script programming is couched in the ability to know and use the various commands, programs and tools available in the Linux rather than a strict understanding of syntax. This is obvious to

23

anyone who reads the system start-up script files in /etc/rc.d and associated directories. 7. This line ends the if statement 8. This line ends the for statement Example: 1.for i in /mnt/floppy/*; do 2.if [ -f $i ]; then 3.# if the line is there 4.filename = ${i # /mnt/floppy/} 5.echo copying $i to etc/$filename 6.cp p $i /etc/$filname 7.fi 8.done until cycles through a loop until some condition is met. The syntax for the command is shown below: until [expression] do statements done while ccles through a loop while some condition is met. The below example will cycle through a loop forever: while[1] do statements done tests - there is a function provided by bash called test which returns a true or false value depending on the result of the tested expression. Its expression is: test expression It can also be implemented as follows: [expression] The tests below are test conditions provided by the shell: -b file = True if the file exists and is block special file

24

-c file = True if the file exists and is character special file -d file = True if the file exists and is a directory -e file = True if the file exists -f file = True if the file exists and is a regular file -g file = True if the file exists and the set-group-id bit is set -k file = True if the files sticky bit is set -L file = True if the file exists and is a symbolic link -p file = True if the file exists and is a named pipe -r file = True if the file exists and is readable -s file = True if the file exists and its size is greater than zero -S file = True if the file exists and is a socket -t file = True if the file descriptor is opened on a terminal -u file = True if the file exists and its set-user-id bit is set -w file = True if the file exists and is writable -x file = True if the file exists and is executable -O file = True if the file exists and is owned by the effective user id -G file = True if the file exists and is owned by the effective group id file1 nt file2 = True if file1 is newer, by modification date, than file2 file1 ot file2 = True if file1is older than file2 file1 ef file2 = True if file1 and file2 have the same device and inode numbers -z string = True if the length of the string is 0 -n string = True if the length of string is non-zero string1 = string2 = True if the strings are equal sring1 != string2 =True if the strings are not equal !expr = True if the expr evaluates to false expr1 a expr2 = True if both expr1 and expr2 are true expr1 o expr2 = True if either expr1 or expr2 is true the syntax is: arg1 OP arg2

25

where OP is one of eq, -ne, -lt, -gt, or ge. Arg1 and arg2 may be positive or negative integers or the special expression -1 string which evaluates to the length of string. An example script The file below is an example file which demonstrates some of the testing as talked above along with several looping an control statements. # ! /bin/bash # Use the bash shell to run the script # This is an example file to take entries from the user # entries version 1.0 May 22,2000 Done =no ENTRIES = Hello bye ls 1 while [$ Done = no ] do echo Valid entries are: $ENTRIES Read ENTRY # Read the variable ENTRY from the user case $ENTRY in 1) pwd ; ; Hello) echo How are you? ; ; Bye) echo exiting . . . Done =yes ; ; ls) ls al |more ; ; *) echo $ENTRY is an unrecognised command

26

esac done

27

Exercise # 6
Write a shell script to generate the Fibonacci Series
echo Enter the number read num a=0 b=1 echo $a echo $b i=1 n=`expr $num 2` while [$i le $n] do fib=`expr $a + $b` a=$b b=$fib i=`expr $i + 1` done

Output:
Enter the number: 10 0 1 1 2 3 5 8 13 21 34

28

Exercise # 7
Write a shell script to show the factorial of a number.
echo Enter the number: read num let fact=1 let i=1 echo Factorial of the number is: while [ $i le $num] do let fact = $fact\*i let i = $i+1 done echo $fact

Output
Enter the number: 6 Factorial of the number is: 720

29

Exercise # 8
Write a shell script to find whether a number is prime or not echo Enter the number: read num i=2 flag=0 while [$i le `expr $num/2`] do if [`expr $num % $i` -eq 0] then flag=1 break fi i=`expr $i+1` done if[ $flag eq 0] then echo $num is a prime number else echo $num is not a prime number fi

Output Enter the number: 5 5 is a prime number

30

Exercise # 9
Write a shell script to find the greatest out of three numbers
echo Enter any three numbers: read a,b,c if[$a gt $b a $a gt $c] then echo a is largest number elif[$b gt $c] then echo b is largest number else echo c is largest number fi

Output Enter any three numbers: 10 4 32 C is largest number

31

Exercise # 10
AWK Programming
Introduction
If you are like many computer users, you would be frequently like to make changes in various texts less wherever certain patterns appear, or extract data from parts of certain lines while discarding the rest. To write a program to do this in a language such as C or Pascal is a time consuming inconvenience that may take many lines of code. The job may be easier with awk. The awk utility interprets a special purpose programming language that makes it possible to handle simple data reformatting jobs with just a few lines of code. The GNU implementation of awk is called gawk; it is fully upward compatible with the system V release 4 version of awk. gawk is also upward compatible with the POSIX specification of the awk language. This means that all properly written awk programs should work with gawk. Thus, we usually dont distinguish between gawk and other awk implementations. Using awk you can: - manage small, personal databases - generate reports - validate data - produce indexes and perform other document preparation tasks - even experiment with algorithms that can be adapted later to other computer languages Examples you would type at the command line are preceded by the common shell primary and secondary prompts, `$` and `>` Output from the command is preceded by the glyph \a. this typically represents the commands standard output. Error messages, and other

32

output on the commands standard error, are preceded by the glyph\error. For example: $ echo Hi on stdout a hi on stdout $ echo Hello on stderr 1>&2 Error hello on stderr In the text, command names appear in this font, while code segments appear in the same font and quoted, `like this`. Some things will be emphasized like this, and if a point needs to be made strongly, it will be done like this. The first occurrence of a new term is usually its definition, and appears in the same font as the previous occurrence of \definition in this sentence, file names are indicated like this: `/path/to/ourfile`. Characters that you type at the keyboard look like this. In particular, there special characters called \control characters. These are characters that you type by holding down both the CTRL key and another key, at the same time. For example, a CTRL-d is typed by first pressing and holding the CTRL key, next pressing the d key, and finally releasing both keys.

Data Files for the Examples


Many of the examples take their input from two sample data files. The first, called `BBS-list`, represents a list of computer bulletin board systems together with information about those systems. The second data file, called `inventory-shipped`, contains information about shipments on a monthly basis. In both files, each line is considered to be one record. In the file `BBS-list`, each record contains the name of a computer bulletin board, its phone number, the boards baud rate, and a code for the number of hours it is operational. An `A` in the last column means the board operates 24 hours a day. A `B` in the last column means the board operates evening and weekend hours only. A `C` means the board operates only on weekends. Aardvark 555-5553 1200/300 B Alpo-net 555-3412 2400/1200/300 A Barfly 555-7685 1200/300 A

33

Bites 555-1675 2400/1200/300 A Camelot 555-0542 300 C Core 555-2912 1200/300 C Fooey 555-1234 2400/1200/300 B Foot 555-6699 1200/300 B Macfoo 555-6480 1200/300 A Sdace 555-3430 2400/1200/300 A Sabafoo 555-2127 1200/300 C The second data file called `inventory shipped`, represents information about shipments during the year. Each record contains the month of the year, the number of green crates shipped, and the number of blue packages shipped, respectively. There are 16 entries, covering the 12 months of one year and 4 months of the next year. Jan 13 25 15 115 Feb 15 32 24 226 Mar 15 24 34 228 Apr 31 52 63 420 May 16 34 29 208 Jun 31 42 75 492 Jul 24 34 67 436 Aug 15 34 47 316 Sep 13 55 37 277 Oct 29 54 68 525 Nov 20 87 82 577 Dec 17 35 61 401 Jan 21 36 64 620 Feb 26 58 80 652 Mar 24 75 0 495 Apr 21 70 74 514

Getting started with awk


The basic function of awk is to search less for lines (or other units of text) that contains certain patterns. When a line matches one of the patterns, awk performs specified actions on that line. awk keeps processing input

34

lines in this way until the end of the input less are reached. Programs in awk are different from programs in most other languages, because awk programs are data-driven; i.e. you describe the data you wish to work with, and then what to do when you end it. Most other languages are procedural; you have to describe, in great detail, every step the program is to take. When working with procedural languages, it is usually much harder to clearly describe the data your program will process. For this reason, awk programs are often refreshingly easy to both write and read. When you run awk, you specify an awk program that tells awk what to do. The program consists of a series of rules. It may also contain function definitions, an advance feature which we ignore for now. Each rule specifies one pattern to search for and one action to perform when that pattern is found. Syntactically, a rule consists of a pattern followed by an action. The action is enclosed in curly braces to separate it from the pattern. Rules are usually separated by newlines. Therefore, an awk program looks like this: Pattern{ action } Pattern{ action } A Rose By Any Other Name The awk language has evolved over the years. Because of this, many systems have multiple versions of awk. Some systems have an awk utility that implements the original version of the awk language and a nawk utility for the new version. Others have an oawk for the \old awk language and plain awk for the new one. Still others only have one version, usually the new one. All in all, this makes it difficult for you to know which version of awk you should run when writing your programs. The best advice we can give here is to check your local documentation. Look for awk, oawk, and nawk, as well as for gawk. Chances are, you will have some version of new awk on your system.

35

Вам также может понравиться