Week Two Agenda
-
Upload
uriel-bradshaw -
Category
Documents
-
view
13 -
download
0
description
Transcript of Week Two Agenda
![Page 1: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/1.jpg)
![Page 2: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/2.jpg)
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
![Page 3: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/3.jpg)
Announcements
Class participation
Class participation is an essential element in this class. Many times a student’s 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.
![Page 4: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/4.jpg)
Link of the week• The link below lists most all operating systems that are
available.• http://dmoz.org/Computers/Software/Operating_Systems• The link below has tabs for books, posters, software, and tools• http://www.javvin.com/unix-like-poster.html• Definition of Operating System (OS)• Common operating systems are:
UNIX, Linux, HP-UX• Basic tasks performed by an operating system
– Control and allocate memory– Prioritize system requests– Control input and output devices– Facilitate networking and management file systems
![Page 5: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/5.jpg)
Link of the weekServices 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
![Page 6: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/6.jpg)
Use of the Virtual Machine
Knoppix features• Demonstrate how to ftp a file from Knoppix
software to the cs.franklin.edu (Einstein) machine using VMware software
Open two Konqueror windows
Enter the ftp protocol
sftp://[email protected]/export/home/dandrear
in one screen
Open a Konsole screen and create a file to transfer to the cs.franklin.edu machine.
![Page 7: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/7.jpg)
Review 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)
![Page 8: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/8.jpg)
Review week one lab assignmentless command
q (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/
Fall_Franklin_Live_Presentations
File format: Week_Two_2_ppt.ppt
Week_Two_2.pptx
![Page 9: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/9.jpg)
Review week one lab assignmentif [ ]
thenAction statements
fi
while [ ]do
Action statementsdone
for file_name in *do
Action statementsdone
![Page 10: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/10.jpg)
Review week one lab assignmentReserved words
The following reserved words for the Bourne shell are recognized only when they appear without quotation marks as the first word of a command.
for esac fi while
do if elif until
done then else { }
case ( )
![Page 11: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/11.jpg)
Review week one lab assignmentNUMBER=$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
![Page 12: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/12.jpg)
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=$(($.................. - 1))
done
printf
![Page 13: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/13.jpg)
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 fiDIR="."
![Page 14: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/14.jpg)
Review 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
fi
![Page 15: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/15.jpg)
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
![Page 16: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/16.jpg)
Review week one lab assignmentCase #1: ./printnum.sh <numeric value>
/~dandrear/itec400/homework
Case #1: ./maxlines.sh
/~dandrear/itec400/homework
printnum.sh
maxlines.sh
Case #2: ./maxlines.sh <directory value>
cat
chmod
cp
![Page 17: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/17.jpg)
Review week one lab assignmentman (uses the “less” command for pagination)
ls –l
ps
ls -a
cut –c 1-7
wc -l
$#
date
exit 0
exit 1
NUMBER=$2
![Page 18: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/18.jpg)
Review week one lab assignmentcp file1 file2
mv file1 file2
rm file_1
rmdir dir_1
clear
head
tail
who
myArray[1]=$1
more
ps –ef
![Page 19: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/19.jpg)
Review week one lab assignment
grep
find
ls
mkdir
cd $1
$1, $2, $3
cat <file name>
chmod <permission> <file name>
echo $NUMBER
less
![Page 20: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/20.jpg)
Review week one lab assignment
sleep <number of seconds>
diff <file name> <file name>
cd <directory>
sort <file name>
umask
umask -S
who
who am i
![Page 21: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/21.jpg)
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.
![Page 22: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/22.jpg)
Next 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 of these layers is the hardware. The hardware is surrounded by system software that most users never interact withThis system software is called the kernel. The kernel is surrounded by programs (often called utilities) such as cat, date, and diff, that perform specific tasks. The shell program provides easy access to utilities and the kernel for the user.
![Page 23: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/23.jpg)
Next lab assignment
A shell via the kernel allows user to interact with resources such as programs, files, directories, and devices. An interactive shell acts as a command interpreter.
![Page 24: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/24.jpg)
Next lab assignmentMost shell statements can 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/perl
Demonstrate: cat /etc/shells
echo $SHELL
![Page 25: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/25.jpg)
Next lab assignmentConcentric Circle Relationship
KERNELHARDWARE
Shell
Utilities
Kernel
csh
sort
ps
vi
![Page 26: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/26.jpg)
Next lab assignment
drwxrwxrwx 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 exit
1 indicates failed exit
The return value of a command can be used with conditional or iteration commands.
![Page 27: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/27.jpg)
Next 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)
.
![Page 28: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/28.jpg)
Next 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.
![Page 29: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/29.jpg)
Next lab assignmentLinux Manual 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
daemons
![Page 30: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/30.jpg)
Next 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:
~dandrear/Fall2010_Solutions/foobar_1grep pattern foobar_1grep pattern *
![Page 31: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/31.jpg)
Next lab assignmentThe 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 32: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/32.jpg)
Next lab assignment
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/Fall2010_solutions/test.txt
Append the standard output of a command to a file.
cat foobar_2 >> foobar_1
![Page 33: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/33.jpg)
Next lab assignmentThe 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, …).
![Page 34: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/34.jpg)
Break Out Problems1. ps | wc –l2. who | awk ‘{print $1}‘ | sort –u | wc –l3. ps –ef | awk ‘{print $1}’ | sort –u | wc –l4. sort –r names.txt5. ps –ef | awk ‘{print $9, $1}’ 6. find /bin -name gzip7. find /etc -name motd8. > newfile9. rm newfile10. date | cut –c12-1911. nohup grep This ~dandrear/Fall09_Solutions/report.txt &12. cp test_data1.txt ~dandrea/temp/test_data2.txt13. mv test_data1.txt /tmp/test_data_one.txt14. printf $NUMBER
![Page 35: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/35.jpg)
Upcoming Deadlines
• Lab Assignment 2-1, Simple Shell Scripting, due September 26, 2010.
• Lab Assignment 3-1, Advanced Scripting, due October 3, 2010.
• Read Chapters 1 and 2 in Essential System Administration text.
• Read Module Two listed under the course Web site
![Page 36: Week Two Agenda](https://reader035.fdocuments.us/reader035/viewer/2022070401/56813769550346895d9efd02/html5/thumbnails/36.jpg)
Lab assistance, questions and answers
• Questions• Comments• Concerns
• After class I will help students with their scripts.