Week Two Agenda

download Week Two Agenda

If you can't read please download the document

description

Week Two Agenda. Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments Announcements Break Out Problems Upcoming Deadlines Lab assistance, questions and chat time. Announcements. Class participation - PowerPoint PPT Presentation

Transcript of Week Two Agenda

This Weeks Topics Review week one lab assignment Review week two lab assignment Expected learning outcomes Break out rooms with problems

1Week Two AgendaAnnouncementsLink of the weekUse of Virtual MachineReview week one lab assignmentThis weeks expected outcomesNext lab assignments AnnouncementsBreak Out ProblemsUpcoming DeadlinesLab assistance, questions and chat time

2AnnouncementsClass participationClass participation is an essential element in this class. Many times a students final grade borderlines the next highest grade. The score closeness could be .5 to 1. It is the instructors discretion based on the students performance in class, as to whether the next highest grade is given.Convince me professionally, that you want an A in this course.3Link of the weekThe link below lists most all operating systems that are available.http://dmoz.org/Computers/Software/Operating_SystemsThe link below has tabs for books, posters, software, and toolshttp://www.javvin.com/unix-like-poster.htmlDefinition of Operating System (OS)Common operating systems are:UNIX, Linux, HP-UXBasic tasks performed by an operating systemControl and allocate memoryPrioritize system requestsControl input and output devicesFacilitate networking and management file systems

4Link of the weekServices Operating System (OS) performProcess management Memory managementOS coordinates various types of memory File systemsNetworking Graphical user interface (GUI) and command lineDevice driversSecurityInternal managementExternal management5Use of the Virtual MachineKnoppix featuresDemonstrate how to ftp a file from Knoppix software to the cs.franklin.edu (Einstein) machine using VMware softwareOpen two Konqueror windowsEnter the ftp protocol sftp://[email protected]/export/home/dandrearin one screenOpen a Konsole screen and create a file to transfer to the cs.franklin.edu machine.

6Review week one lab assignmentBasic vi editor commands. vi test_file.txt^ (place cursor on beginning of line)$(place cursor at end of line)o (insert text - alpha character)cw (change an entire word in a file)Esc key (exit insert mode):wq! (save text entered in file):q! (quit without saving changes)

7Review week one lab assignmentless commandq (terminates pagination)Enter or Return key (advance one line)Space bar (refresh full screen)Location of weekly Power Point presentations:http://cs.franklin.edu/~dandrear/itec400/Winter2010_Franklin_LiveFile format: Week_Two_2_ppt.ppt

8Review week one lab assignmentif [ ]thenAction statementsfi

while [ ]doAction statementsdone

for file_name in *doAction statementsdone

9Review week one lab assignmentNUMBER=$1# One argument must be provided, otherwise dont executeif [ ]then Action statement(s)exit ..# The value of the command line argument cant# be less than or equal to zero.elif [ ]thenAction statement(s)exit ..fi

10Review week one lab assignment# Integer value must be greater than zerowhile [ -gt 0 ]do printf $variable# If the value of the argument is greater than one, insert a comma after the integer if [ -gt 1 ] then printf ", " fi# Decrease the value of NUMBER by one with each iteration NUMBER=$(($.................. - 1))doneprintf

11Review week one lab assignmentERROR1="error: can only use 0 or 1 arguments.\nusage: maxlines.sh [directory]"ERROR2="error: argument must be a directory.\nusage: maxlines.sh [directory]\n"# Verify that more than one command line argument doesn't exist.if [[ $# -gt 1 ]] then printf "$ERRORX" exit 1 fiDIR="."12Review week one lab assignment# Case #2 and 3.# The number of arguments on the command line equals one.if [[ $X -eq 1 ]]then # Is the directory entry a directory? if [[ -X $1 ]] then # Assign the command line argument to the variable, DIR="$X" else printf "$ERRORX" exit 1 fi fi13Review week one lab assignment# All case are processed with the following code.# Change directory to the indicated variable content.cd $XXX# Assign file name with highest number of new lines to the variable FILE.FILE=$(wc X `ls` 2>/dev/XXXX | sort X X | tail X X | head X X)# Print statement for all cases.printf "File `echo $FILE | awk '{print $X}'` has the maximum lines with `echo $XXXX| awk '{print $X}'` lines.\n"exit 0

14Review week one lab assignmentCase #1: ./printnum.sh /~dandrear/itec400/homework

Case #1: ./maxlines.sh/~dandrear/itec400/homeworkprintnum.shmaxlines.sh

Case #2: ./maxlines.sh /bincat chmodcp15Review week one lab assignmentman (uses the less command for pagination)ls lpsls -acut c 1-7wc -l$#dateexit 0exit 1NUMBER=$2echo $NUMBERless

16Review week one lab assignmentcp file1 file2mv file1 file2rm file_1 rmdir dir_1clearheadtailpipeswhomyArray[1]=$1moreps ef

17Review week one lab assignmentgrepfindlsls amkdircd $1$1, $2, $3cat chmod mv

18Review week one lab assignmentsleep diff cd sort umaskwhowho am i

19Weeks 2 and 3 expected outcomesUpon successful completion of this module, the student will be able to:Create scripts using shell variables and program control flow. Use man page system and find script tools. Use redirection and pipes to combine scripts and executables.

20Next lab assignmentIn a Unix environment, the commands you enter are executed by a program called the "shell". The user must select a command shell used to communicate with UNIX. Examples are Korn, Bourne, and C Shell.One of the things that makes the UNIX system so flexible is its layered design. At the core is the hardware. The hardware is surrounded by system software that most users never interact with called the kernel. The kernel is surrounded by programs (often called utilities) such as cat, date, and diff, that perform specific tasks. A program that provides easy access to these utilities and the kernel by the user is called a shell.

21Next lab assignmentA shell enables the user to interact with resources of the computer, such as programs, files, directories, and devices. An interactive shell acts as a command interpreter. In its role as a command interpreter, the shell is the interface between the user and the system. The user enters text commands to the shell, and the shell carries them out, usually by running programs. 22Next lab assignmentMost shells can also be used as a programming language. Users can combine command sequences to create new programs. These programs are known as shell scripts. Shell scripts automate the use of the shell as a command interpreter.The first line of any script must begin with #!, followed by the name of the interpreter.Examples: #!/bin/ksh#!/bin/bash#!/usr/bin/perlDemonstrate: cat /etc/shellsecho $SHELL

23Next lab assignmentConcentric Circle Relationship

24Next lab assignmentdrwxrwxrwx permissions (directory)-rwxrwxrwx permissions (file)lrwxrwxrwx permissions (symbolic link)-rwx------ 2 dandrear faculty (hard link)exit Each command has a return value.0 indicates normal exit1 indicates failed exit

The return value of a command can be used with conditional or iteration commands.

25Next lab assignmentUsers can connect the standard output of one command into the standard input of another command by using the pipeline operator (|).Demonstrate:ps -efps ef | wc lps ef | awk {print $2}ps ef | grep dandrearls l | cut c1-3who b (time of last system boot)who d (print dead processes)who r (print current run level).26Next lab assignmentA process associates a number with each file that it has opened. This number is called a file descriptor. When you log in, your first process has the following three open files connected to your terminal.

Standard input: File descriptor 0 is open for reading.Standard output: File descriptor 1 is open for writing.Standard error: File descriptor 2 is open reading.27Next lab assignmentLinux command documentation is known as man. Each page is a self-contained document. The Manual sections are split into eight numbered sections:1 General commands.2 System calls3 C library functions4 Special files (usually devices, those found in /dev) and drivers.5 File formats and conventions6 Games and screensavers7 Miscellaneous8 System administration commands and daemons28Next lab assignmentThe grep command searches the named input file(s) forlines containing a given pattern. Normally,each line found is reported to standard output.Demonstrate: grep text ~dandrear/Winter08_solutions/foobargrep pattern foobar_1grep pattern *The find command lists all pathnames that are in each of the given directories.Demonstrate: find / -type d printfind ~dandrear type d -printfind . printfind / -name foobar

29Next lab assignmentRedirect the standard output of a command to a file. date > /tmp/date_savedRedirect the standard input of a command so that it reads from a file instead of from your terminal.cat < ~dandrear/Winter09_solutions/test.txtAppend the standard output of a command to a file. cat foobar_2 >> foobar_1 30Next lab assignmentThe coding and testing processCode one small script function at a time.Test that function before adding more code to the script.Program coding is an iterative process (code,test,code,test,code,test, ).31Break Out Problemsps | wc lwho | awk {print $1} | sort u | wc lps ef | awk {print $1} | sort u | wc lsort r names.txtps ef | awk {print $9, $1} find /bin -name gzipfind /etc -name motd> newfilerm newfiledate | cut c12-19nohup grep This ~dandrear/Summer09_solutions/report.txt &cp test_data.txt ~dandrea/tempmv test_data.txt ~dandrear/tempprintf $NUMBER

32Upcoming DeadlinesLab Assignment 1-1, Obtain a Proctor for Exams, due January 22, 2010.Lab Assignment 2-1, Simple Shell Scripting, due January 24, 2010.Lab Assignment 3-1, Advanced Scripting, due January 31, 2010.Read Chapters 1 and 2 in Essential System Administration text.Read Module One listed under the course Web site

33Lab assistance, questions and answersQuestionsCommentsConcerns

After class I will help students with their scripts.

34KERNEL

HARDWARE

Shell

Utilities

Kernel

ps

vi

csh

sort