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.

Slides:



Advertisements
Similar presentations
Shell Script Assignment 1.
Advertisements

Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Chapter One The Essence of UNIX.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Introduction to Linux and Shell Scripting Jacob Chan.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Review week two lab assignment This week’s expected outcomes Next lab assignment.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Week One Agenda IntroductionIntroduction Administrative AnnouncementsAdministrative Announcements Link of the WeekLink of the Week Expected OutcomesExpected.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Shell The Shell The agency that.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
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 Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
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.
UNIX and Shell Programming (06CS36) Unit 1 Continued… Shrinivas R. Mangalwede Department of Computer Science and Engineering K.L.S. Gogte Institute of.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Guide To UNIX Using Linux Third Edition Chapter 8: Exploring the UNIX/Linux Utilities.
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.
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.
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.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
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 One Agenda IntroductionIntroduction Administrative AnnouncementsAdministrative Announcements Link of the WeekLink of the Week Expected OutcomesExpected.
Introduction to Programming Using C An Introduction to Operating Systems.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Use of the Virtual Machine Review week two lab assignment This week’s expected.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
Chapter Six Introduction to Shell Script Programming.
Week Three Agenda Administrative Issues Link of the week Review week two lab assignment This week’s expected outcomes Next lab assignment Upcoming deadlines.
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.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux Commands C151 Multi-User Operating Systems.
Week Three Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems.
Sydney Opera House. Week Three Agenda Administrative Issues Link of the week Use of the Virtual Machine Review week two lab assignment This week’s expected.
Agenda Introduction Administrative Announcements Link of the Week Expected Outcomes This Week’s Topics Next Week’s Lab Assignment Break Out Problems Upcoming.
Agenda Introduction Administrative Announcements Link of the Week Expected Outcomes This Week’s Topics Next Week’s Lab Assignment Break Out Problems Upcoming.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
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.
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.
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.
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.
Linux Administration Working with the BASH Shell.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Lesson 5-Exploring Utilities
Week Two Agenda Announcements Link of the week Use of Virtual Machine
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Week Three Agenda Link of the Week Review Week Two Information
C151 Multi-User Operating Systems
Sydney Opera House.
Chapter 2: System Structures
Shell Script Assignment 1.
Unix Operating System (Week Two)
INTRODUCTION TO UNIX: The Shell Command Interface
Week Three Agenda Link of the Week Review Week Two Information
Introduction to Linux Week 0 - Thursday.
Chapter Four UNIX File Processing.
Linux Shell Script Programming
Presentation transcript:

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 Class participation is an essential element in this class. Many times a student’s final grade borderlines the next highest letter grade. The course instructor has the authority to assign or not assign the next highest final grade when the score is within.5 and 1 points of the next highest letter grade. Convince me professionally, that you want an “A” in this course.

Link of the week The link below lists most all operating systems that are available. The link below has tabs for books, posters, software, and tools Definition of Operating System (OS) Common operating systems discussed in this class will be: UNIX, Linux, HP-UX, and Windows Basic tasks performed by an operating system –Control and allocate memory for processes –Prioritize system requests for the CPU –Control input and output transmissions to and from devices –Facilitate networking and support file system management

Link of the week Services Operating System (OS) perform –Process management –Memory management OS coordinates various types of memory –File systems –Networking –Graphical user interface (GUI) and command line –Device drivers –Security Internal management External management

Link of the week Services Operating System (OS) perform Process management – Background and foreground processes Memory management - The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to the computer system. Random Access Memory (RAM) – Static and dynamic RAM. Cache Memory - is a cache used by the central processing unit of a computer to reduce the average time to access memory Shared Memory - The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to the computer system. –C

Iink of the Week File systems - Is an abstraction to store, retrieve and update a set of files. The term identifies data structures specified by some of those abstractions, which are designed to organize multiple files as a single stream of bytes. Network protocols are specified by other abstractions, which are designed to allow files on a system to be accessed remotely. Networking – Internal and external communication. Graphical user interface (GUI) and Command line (CLI). Device drivers - Is a computer program that operates or controls a particular type of device that is attached to a computer. A driver typically communicates with the device through the computer bus or communications subsystem to which the hardware connects

Link of the Week Security -Internal management and external management. Internal security pertains to employees inside the company and visitors that come to a company to sale products, repair equipment and delivery persons. External security encompasses users needing access to company data and/or assets. The list of external users accessing data for a company could be significant depending on the nature of the business. The list includes employees working remotely, branches offices, and company suppliers.

Use of the Virtual Machine Knoppix features Use the sftp command to move a file from Knoppix software to the cs.franklin.edu (Einstein) machine using VMware software Open two Konqueror windows Enter the sftp protocol in one screen Open a Konsole screen and create a file to transfer to the cs.franklin.edu machine.

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

Review week one lab assignment less and more command q (terminates pagination) Enter or Return key (advance one line) Space bar (refresh entire screen) Location of weekly Power Point presentations: UNIX_Presentations/ File format: Week_Two_2_UNIX_ppt.ppt Week_Two_2_UNIX.pptx

Review week one lab assignment if [ ] then Action statements fi while [ ] do Action statements done for file_name in * do Action statements done

Review week one lab assignment #!/bin/ksh NUMBER=$1 # One argument must be provided, otherwise don’t execute if [ …] then …… Action statement(s) exit ….. # The value of the command line argument can’t # be less than or equal to zero. elif [ …] then ……Action statement(s) exit ….. fi

Review week one lab assignment # Integer value must be greater than zero while [ ……… -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=$(($ )) done printf

Review week one lab assignment ERROR1="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 fi # Default variable setting DIR="."

Review week one lab assignment # Case #2. # The number of arguments on the command line equals one. if [[ $X -eq 1 ]] then # Is the command line argument a directory? if [[ -X $1 ]] then # Assign the command line argument to the variable, DIR="$X" else printf "$ERRORX" exit 1 fi

Review week one lab assignment # All cases 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

Review week one lab assignment Case #1: Execute script:./printnum.sh Execution location: /~dandrear/itec400/homework Objective: Provide script with data from the command line. Case #1: Execute script:./maxlines.sh or./maxlines.sh. Execution location: /~dandrear/itec400/homework Objective: Visit every directory entry under homework Case #2: Execute script:./maxlines.sh /bin Execution location: /~dandrear/itec400/homework Objective: Visit every directory entry under /bin directory

Review week one lab assignment man (uses the “less” command for on-line page control)  ls –l  ps  ls –a cut –c 1-7 wc -l $#  date exit 0 exit 1  NUMBER=$2  echo $NUMBER less

Review week one lab assignment cp file1 file2 mv file1 file2  rm file_1  rmdir dir_1  clear head tail  who myArray[1]=$1 more  ps –ef

Review week one lab assignment grep find  ls mkdir cd $1 $1, $2, $3 (Example:./printnum.sh 6)  cat  chmod

Review week one lab assignment  sleep  diff  cd  sort  umask  umask -S  who  who am I  uname -n

Weeks 2 and 3 expected outcomes Upon 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.

Next lab assignment In a Unix environment, the commands you enter are executed by a program called the "shell". The user must select a command shell to communicate with UNIX. Examples are Korn, Bourne, and C Shell. One of the things that makes the UNIX operating 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. One of these software applications is called the kernel. The kernel is surrounded by programs (often called utilities) such as cat, date, and diff commands that perform specific tasks. A shell program communicates with these utilities and the kernel with text type information. Ultimately, the kernel sends and receives information from the user’s shell.

Next lab assignment A shell program enables a user to interact with computer resources, such as programs, files, directories, and devices. Shells allow users to interact on a system interactively as a command interpreter. When acting as command interpreter, the shell is the interface between the user and the system in a real time environment. To observe the different types of shells on a system, execute the following command: Demonstrate: cat /etc/shells

Next lab assignment Most shells are 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/sh, /bin/bash, /sbin/nologin /bin/ksh, /bin/tcsh, /bin/csh Verify the shell currently being used. Demonstrate: echo $SHELL

Next lab assignment Concentric Circle Relationship

Next lab assignment Command: ls –l drwxrwxrwx permissions (Directory) -rwxrwxrwx permissions (File) lrwxrwxrwx permissions (Symbolic link) -rwx dandrear faculty (Hard link) crw root root audio (Character device) brw-rw root disk aztcd (Block device)

Next lab assignment Exit command Allows you to exit from a program, or shell The exit command may be used to terminate a script, just as in a C program. It can also return a value, that can be examined by the parent process for further action. Every command returns an exit status (sometimes referred to as a return status ). The exit command values range is from indicates normal exit 1 through 255 indicates a failed exit

Next lab assignment Awk Commands 1.The awk command scans its instructions and executes any actions specified to occur before the input file is read. 2.One record is read from the input file. 3.The record is compared against each pattern specified by the awk command's instructions. 4.The command instructions can specify that a specific field within the record be compared. By default, fields are separated by white space (blanks or tabs). Each field is referred to by a field variable. The first field in a record is assigned the $1 variable, the second field is assigned the $2 variable, and so forth. The entire record is assigned to the $0 variable. 5.If the record matches a pattern, any actions associated with that pattern are performed on the record.

Next lab assignment Pipe Command Users can connect the standard output of one command into the standard input of another command.by using the pipeline operator (|). Demonstrate command usage: ps -ef ps –ef | wc –l ps –ef | awk ‘{print $2}’ ps –ef | grep dandrear ls –l | cut –c1-3 who –b (Time of last system boot) who –r (Print current run level) who –s (Print short version of user on system).

Next lab assignment File Descriptor A process associates a number with each file it has open. 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.

Next lab assignment Manual (man) Command Linux 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 calls 3 C library functions 4 Special files (usually devices, those found in /dev) and drivers. 5 File formats and conventions 6 Games and screensavers 7 Miscellaneous 8 System administration commands and daemons

Next lab assignment Grep Command The grep command searches the named input file(s) for lines in a file containing a given pattern. When a pattern is found, each line is reported to standard output. Demonstrate: grep [options] pattern file(s) grep inc_A ~dandrear/xyz grep inc_A prog1 prog2 grep inc_A *

Next lab assignment Find Command The find command lists all pathnames that are in each of the given directories. Demonstrate: find ~dandrear –type d –print find ~dandrear –type f -print find. –print find / -type f –print

Next lab assignment Redirections Many UNIX commands take text-like input and produce text-like output. It's sometimes useful to be able to control where the input comes from and output goes (via redirection), or even pass the output from one command to another's input (via pipes).

Next lab assignment Redirection (cont) 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/Fall_2013_Solutions/foobar Append the standard output of a command to a file. cat foobar_2 >> foobar_1

Next lab assignment Coding and Testing Process Code 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, …).

Break Out Problems 1.ps | wc –l 2.who | awk ‘{print $1}‘ | sort –u | wc –l 3.ps –ef | awk ‘{print $1}’ | sort –u | wc –l 4.sort –r names.txt 5.ps –ef | awk ‘{print $8, $1}’ 6.find /bin -name gzip 7.find /etc -name motd 8.> newfile 9.rm file_name 10.date | cut –c cp test_data.txt ~dandrea/temp 12.mv test_data.txt ~dandrear/temp 13.printf $NUMBER 14. touch newfile

Upcoming Deadlines Lab Assignment 2-1, Simple Shell Scripting, due September 29, Lab Assignment 3-1, Advanced Scripting, due October 6, Read Chapters 1 and 2 in Essential System Administration text. Read Module Two listed under the course Web site. Everyone should have received a Shell Quick Reference document and script logic for Lab Assignment 2-1.

Lab assistance, questions and answers Questions Comments Concerns After class I will help students with their scripts.