Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
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
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.
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
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
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
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
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
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
15
Network Administrator
16
IP address(32 bit) used for addressing datagrams name, eg., www.yahoo.com used by humans
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
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
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
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.
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
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