slide1 n.
Skip this Video
Download Presentation
Week Two Agenda

Loading in 2 Seconds...

play fullscreen
1 / 39

Week Two Agenda - PowerPoint PPT Presentation

  • Uploaded on

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.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Week Two Agenda' - gefjun

Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
week two agenda

Week Two Agenda


Link of the week

Use of Virtual Machine

Review week one lab assignment

This week’s expected outcomes

Next lab assignments


Break Out Problems

Upcoming Deadlines

Lab assistance, questions and chat time


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 to 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
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, and HP-UX

  • 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 week1
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
use of the virtual machine
Use of the Virtual Machine

Knoppix features

  • Use the sftp command to move a file from Knoppix software to the (Einstein) machine using VMware software

Open two Konqueror windows

Enter the ftp protocol


in one screen

Open a Konsole screen and create a file to transfer to the machine.

review week one lab assignment
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)

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 assignment1
Review week one lab assignment

Less 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


review week one lab assignment2
Review week one lab assignment

if [ ]


Action statements


while [ ]


Action statements


for file_name in *


Action statements


review week one lab assignment3
Review week one lab assignment



# One argument must be provided, otherwise don’t execute

if [ …]


…… Action statement(s)

exit …..

# The value of the command line argument can’t

# be less than or equal to zero.

elif [ …]


……Action statement(s)

exit …..


review week one lab assignment4
Review week one lab assignment

# Integer value must be greater than zero

while [ ……… -gt 0 ]


printf $variable

# If the value of the argument is greater than one, insert a comma after the integer

if [ ………… -gt 1 ]


printf ", "


# Decrease the value of NUMBER by one with each iteration

NUMBER=$(($.................. - 1))



review week one lab assignment5
Review week one lab assignment

ERROR1="error: can only use 0 or 1 arguments.\nusage: [directory]"

ERROR2="error: argument must be a directory.\nusage: [directory]\n"

# Verify that more than one command line argument doesn't exist.

if [[ $# -gt 1 ]]


printf "$ERRORX"

exit 1


# Default variable setting


review week one lab assignment6
Review week one lab assignment

# Case #2.

# The number of arguments on the command line equals one.

if [[ $X -eq 1 ]]


# Is the command line argument a directory?

if [[ -X $1 ]]


# Assign the command line argument to the variable,



printf "$ERRORX"

exit 1



review week one lab assignment7
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 assignment8
Review week one lab assignment

Case #1:

Execute script: ./ <numeric value>

Execution location: /~dandrear/itec400/homework

Case #1:

Execute script: ./ or ./ .

Execution location: /~dandrear/itec400/homework

Case #2:

Execute script: ./ /bin

Execution location: Current working directory (homework)

review week one lab assignment9
Review week one lab assignment

man (uses the “less” command for pagination)

ls –l


ls -a

cut –c 1-7

wc -l



exit 0

exit 1


echo $NUMBER


review week one lab assignment10
Review week one lab assignment

cp file1 file2

mv file1 file2

rm file_1

rmdir dir_1







ps –ef

review week one lab assignment11
Review week one lab assignment





cd $1

$1, $2, $3

cat <file name>

chmod <permission> <file name>

review week one lab assignment12
Review week one lab assignment

sleep <number of seconds>

diff <file name> <file name>

cd <directory>

sort <file name>


umask -S


who am I

uname -n

weeks 2 and 3 expected outcomes
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
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 assignment1
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 determine the different types of shells that are on a system, execute the following command:

Demonstrate: echo /etc/shells

next lab assignment2
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/ksh



Demonstrate: echo $SHELL

next lab assignment3
Next lab assignment

drwxrwxrwx permissions (directory)

-rwxrwxrwx permissions (file)

lrwxrwxrwx permissions (symbolic link)

-rwx------ 2 dandrear faculty (hard link)

crw------- 1 root root 14, 4 Jun 24 2004 audio

(Character device)

brw-rw---- 1 root disk 29, 0 Jun 24 2004 aztcd

(Block device)

next lab assignment4
Next lab assignment

Exit command

Allows you to exit from a program, shell or log you out of a UNIX network.

The exitcommand may be used to terminate a script, just as in a C program. It can also return a value, which is available to the script's parent process.

Every command returns an exit status (sometimes referred to as a return status ).

The exit command values range is from 0-255.

0 indicates normal exit

1 through 255 indicates a failed exit

next lab assignment5
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 | grepdandrear

ls –l | cut –c1-3

who –b (time of last system boot)

who –d (print dead processes)

who –r (print current run level)


next lab assignment6
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: Filedescriptor 0 is open for reading.

Standard output: File descriptor 1 is open for writing.

Standard error: File descriptor 2 is open reading.

next lab assignment7
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 assignment8
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.


grep text ~dandrear/Winter08_solutions/foobar

grep pattern foobar_1

grep pattern *

next lab assignment9
Next lab assignment

Find Command

The find command lists all pathnames that are in each of the given directories.


find / -type d –print

find ~dandrear –type d -print

find . –print

find / -name foobar

next lab assignment10
Next lab assignment


Many UNIX commands take text-like input and/or 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 assignment11
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_2011_Solutions/test.txt

Append the standard output of a command to a file.

cat foobar_2 >> foobar_1

next lab assignment12
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
Break Out Problems
  • ps | wc –l
  • who | awk ‘{print $1}‘ | sort –u | wc –l
  • ps –ef | awk ‘{print $1}’ | sort –u | wc –l
  • sort –r names.txt
  • ps –ef | awk ‘{print $9, $1}’
  • find /bin -name gzip
  • find /etc -name motd
  • > newfile
  • rmfile_name
  • date | cut –c12-19
  • cp test_data.txt ~dandrea/temp
  • mv test_data.txt ~dandrear/temp
  • printf $NUMBER
upcoming deadlines
Upcoming Deadlines
  • Lab Assignment 2-1, Simple Shell Scripting, due September 25, 2011.
  • Lab Assignment 3-1, Advanced Scripting, due October 2, 2011.
  • Read Chapters 1 and 2 in Essential System Administration text.
  • Read Module Two listed under the course Web site.
  • Did everyone receive a Shell Quick Reference document and script logic for Lab Assignment 2-1?
lab assistance questions and answers
Lab assistance, questions and answers
  • Questions
  • Comments
  • Concerns
  • After class I will help students with their scripts.