Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s...

38

Transcript of Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s...

Page 1: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.
Page 2: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Week Three Agenda

• Administrative Issues• Link of the Week• Review Week Two Information• This Week’s Expected Outcomes• Next Lab Assignment• Break-Out Problems• Upcoming Deadlines• Lab Assistance, Questions, and Answers

Page 3: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Administrative Issues

This is the last week for identifying a proctor. Most students have already selected their proctor to administer their midterm exam. By default, the same proctor list will be used for the final exam unless a change request is submitted to the Student Learning Center two weeks prior to the final exam date.

Page 4: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Link of the Week

APA Style writing guidelines will be utilized for all lab assignment reports .

APA Style Sixth Editionhttp://www.apastyle.org/learn/APA Style Writing Workshophttp://www.franklin.edu/student-services/student-learning-center/academic-support/workshops.html

Grading will focus mainly on capitalization, punctuation, grammar, and citation.

Page 5: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Link of the Week

Linux Forums Web SiteThis web site allows individuals to post questions about Fedora Linux and Redhat Linux. The people that maintain this site are knowledgeable users of these operating systems. If your experiencing problems with commands or just want to learn more about these systems, you can find this type of information at this site.

http://www.linuxforums.org/forum/redhat-fedora-linux-help/73994-system-commands-not-working-unless-sbin.html

Page 6: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

Caveat:

Knoppix software was designed to be used as a Live CD because of specific features that make it’s performance and stability very suitable. It has been noted in several articles that Knoppix works best from a Live CD. Knoppix enthusiasts have attempted to install this software on a hard disk and encountered problems in the process. These problems are most pronounced when installing updates and new software.

Page 7: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

What is the next user interface going to be?

The textual (command line) and the visual (graphical user) interfaces are the two most common modalities used to support engineers in network and system administration positions. The command line interface is recognized as the first generation and the graphical user interface is considered the second generation. Currently, research is trying to determine the next best interface. The command line interface is known as, “under the hood” method of interacting with the operating system.

Page 8: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

CLI Benefits:

Manipulate textual dataQuick customization of data allows engineers the ability to change data to another formExcellent for filtering data on systemsCommands are rich, expressive, flexible, and powerful

GUI Benefits:

Reduces data overloadSimple filtering and manipulation of the dataExcellent for displaying trends in data

Page 9: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationUsers can connect the standard output of one command to standard input of another command by using the pipeline operator (|).

Demonstrateps -efps –ef | wc –lps –ef | awk ‘{print $2}’ps –ef | grep dandrearls –l | cut –c1-3

who | sort > test_file.txt

The output of the who command is piped to thesort function and written in ascending order in thetest_file.txt file. The “who” and “sort” commands execute in parallel.

Page 10: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

Commands

who –b (time of last system boot)who –d (print dead processes)who –r (print current run level)

List directory entries using the ls –l | less command

drwxrwxrwx permissions (directory)-rwxrwxrwx permissions (file)lrwxrwxrwx permissions (Symbolic link)-rwxrwxrwx 2 dandrear (Hardlink)

brw-rw---- permissions (block) crw------- Permissions (character)

Page 11: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Week Two Information

A 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 (stdin) : File descriptor 0 is open for reading./dev/stdin

Standard Output (stdout): File descriptor 1 is open for writing./dev/stdout

Standard Error (stderr): File descriptor 2 is open reading./dev/stderr

Demonstratels –a > /tmp/output 2>&1

> is equivalent to 1>< is equivalent to <0

Page 12: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Week Two Information

Keyboard

DisplayScreen

Program

#0 stdin

#1 stdout

#2 stderr

File Descriptor

Page 13: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationA file descriptor is generally an index for an entry in a kernel-resident data structure that contains information on all open files. Each process on the system has its own file descriptor table. A user application passes the abstract key to the kernel through a system call, and the kernel accesses the file for the application.

What is a data structure?

A data structure is a specific way of storing and organizing data in a computer so that it can be accessed with high efficiently. Data structures can be used as a single place for storing unrelated information.

Page 14: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationA data structure is a particular way of storing

and organizing data in a computer so that it can be used efficiently.

Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks.

Some common data structures:

array, hash table, linked list, queue, and stack

Page 15: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

The grep command searches the named input file(s) forlines containing a given pattern. Each line found is reported to standard output.Demonstrate:

grep UNIX foobar_3grep ‘^UNIX’ foobar_3grep ‘UNIX$’ foobar_3grep 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

Page 16: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationRedirection Symbols:

Redirect the standard output of a command to a file. date > /tmp/date_saved

Redirect the standard input of a command so that it reads from a file instead of from your terminal.cat < ~dandrear/Winter_2013_Solutions/test.txt

Append the standard output of a command to a file. cat foobar_2 >> foobar_1

Page 17: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

One Liner Expressions:

wc –l

wc –l `ls`

wc –l `ls` | sort –bn

wc –l `ls` | sort –bn | tail –n 2

wc –l `ls` | sort –bn | tail –n 2 | head –n 1

Page 18: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

Korn Shell Syntax and Commands

srchfile.sh $1 $2original=$PWDcd $originalcd $2listing=`ls –l | cut –c52-80`for file_name in $listingdo (boundary)

Action Statements (block of statements)

done (boundary)

Page 19: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationCommandsls –l | morels –l | less (count the fields/use “q” to quit)ls -a (does not hide entries)less man (utilizes the less command for reading

online documentation).

Page 20: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

Shell Syntax> test_filecat /etc/passwdgrep x /etc/passwd | cut –d’:’ –f1chmod 705 *chmod 705 test_filegrep line ~dandrear/Summer_2012_Solutions/foobar_1

find ~dandrear –type d -print myshellArray[1]=$1 $0

Page 21: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

CommandsThe tilde (~) symbol is used to represent the

user’s current home directory (e.g. /home/dandrear)

Command line arguments example:

./add_all 5 10 8

Command line argument syntax.

$0 = ./add_all, $1 = 5, $2 = 10, and $3 = 8

Page 22: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationDemonstrate

/home/dandrear/.profile umask 077

The umask variable contains the default permissions for a file and a directory.

Variables Used by Korn Shell:HOME = is set to the full path name of your login

directory (/home/dandrear)Command: echo $HOME

PATH = contains the command search path. It is set to a series of path names separated by colons (:).Command: echo $PATH

Page 23: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationVariables Used by Korn ShellSHELL = This entry may be set by the system

administrator to the path name of a shell interpreter other than the standard bash.

Command: echo $SHELLTERM = specifies what terminal you are using.TMOUT = variable contains the integer attribute. If you

set the value greater than zero, ksh terminates if you do not enter a command within the prescribed number of seconds after ksh issues the PS1 prompt.

MAIL = Name of your Mail filesEDITOR = Pathname for your editor

Page 24: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationManual (man) Page

Man formats and displays the on-line manual pages. If you specify section, man only looks at that section of the manual. Name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification.

Each section has an introduction which can be obtained with, e.g., "man 2 intro“ or “man ./foobar_1”.

If MANPATH is set, man uses it as the path to search for manual page files.

Page 25: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Informationecho $MANPATH

/usr/local/man:/usr/local/info:/usr/share/man:/opt/SUNWspro/man

Man Page Sections

1 Commands

2 System calls

3 C library routines

4 Devices and networks

5 File formats

6 Games and demos

7 Miscellaneous

8 System administration.

Page 26: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two InformationTypes of File and Directory Access:

Access File Meaning Directory Meaning

r View file contents Search directory contents

w Alter file contents Alter directory contents

x Run executable file Make your current directory

-rwx------ Owner (columns 2-4) 700 (111000000)

----rwx--- Group (columns 5-7) 070 (000111000)

-------rwx Other (columns 8-10) 007 (000000111)

Page 27: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Review Week Two Information

Shell and Programs Access:

To run a shell script, you will need read (r) and execute (x) access (r-x). The read access mode is a binary 4. The execute access mode is a binary 1.

To run a binary executable program, you will need execute (x) access (--x). The execute access mode is a binary 1.

Page 28: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Week’s 2 & 3 Expected Outcomes

Upon successful completion of this module, the student will be able to:

• Create scripts using shell/Perl variables and program control flow.

• Use redirection and pipes to combine scripts and executables.

• Use man page system and find script tools.

• Discuss Perl Language

Page 29: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Next Lab AssignmentIntroduction to Perl:Perl - Practical Extraction and Report LanguageOriginally developed by Larry Wall, a linguist.Perl is 21 years old and Perl 5 is 14 years old.• Perl is a simple language

- Compiles and executes like a shell script or a batch file- Perl doesn’t impose special growth limitations on arrays and data strings- Perl is a composite of C, AWK, and Basic- Originally developed to process text and automating tasks.

Page 30: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Next Lab AssignmentIntroduction to Perl:The AWK utility is an interpreted programming

language typically used as a data extraction and reporting tool. It is a standard feature of most Unix-like operating systems.

AWK was created at Bell Labs in the 1970s, and its name is derived from the family names of its authors – Alfred Aho, Peter Weinberger, and Brian Kernighan.

The power, terseness, and limits of early AWK programs inspired Larry Wall to write Perl just as a new, more powerful POSIX AWK and gawk (GNU AWK) were being defined.

Page 31: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Next Lab AssignmentPerl’s range of flexibility

- System administration- Web development- Network programming- GUI development

Major features- Procedural Programming

Sequence or unstructured statementsIncludes routines, subroutines, methods, or functions

- Object Oriented ProgrammingModule uses “objects” and their interactions to design applications and computer programs.

Page 32: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Next Lab Assignment

Major features (continued)

- Powerful built-in support for text

processing

- Large collection of third-party

modules.

Page 33: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Next Lab Assignment

• Why is awk language so important?

Awk language is an excellent filter and report writer. Many UNIX utilities generate rows and columns of information. Awk is an excellent tool for processing rows and columns, and it is easier to use awk than other conventional programming languages. Perl recognized the importance of awk, so it was included and enhanced in Perl.

Page 34: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Next Lab AssignmentThe Advanced Scripting lab assignment requires two

shell scripts to be written. srch.sh srchfile.sh

DemonstrateExecution of srch.sh and srchfile.sh

Case #1: ./srch.sh <pattern> <file name / directory name>Case #2: ./srch.sh <pattern> <.>

The srch.sh script will call the srchfile.sh script to perform a specific task. The srchfile.sh searches for a file with a pattern and outputs the matching information to standard output. After all directory entries have been read, control is returned to the main script, srch.sh.

Page 35: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Break Out Problems1. scalar@ARGV2. $ARGV[0]3. filter4. unless5. $NUMBER6. exit 17. $ARGV[1]8. % (%directory)9. $ ($quote)10. @ (@names)11. Regular expressions12. tr [a-z] [A-Z] < foobar > /tmp/foo

Page 36: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Next Lab AssignmentRead your Programming Perl text book.

Chapter One (1)

Chapter Two (2)

Review Chapter 32: Standard Modules

Review Chapter 33: Diagnostic Output Messages

Read Module Two listed under the course web page.

Page 37: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Upcoming Deadlines• Lab Assignment 3-1, Advanced Scripting, due

February 3, 2013.• Lab Assignment 4-1, Simple Perl Exercise,

due February 10, 2013.

Page 38: Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.

Lab Assistance, Questions and Answers

Questions

Comments

Concerns

After class I will help students with their scripts.