comp 104: intro to unix
DESCRIPTION
COMP 104: Intro to Unix. Week 3. Review of Last Week. Unix file system structure File types and access permissions Create and use directories and files Edit files with vi Use the following Unix commands: cd, chmod, cp, id, mkdir, mv, pwd, rm, rmdir, touch, umask, vi. Agenda – Activity 1. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/1.jpg)
COMP 104: Intro to Unix
Week 3
![Page 2: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/2.jpg)
Review of Last Week
Unix file system structure File types and access permissions Create and use directories and files Edit files with vi Use the following Unix commands:
cd, chmod, cp, id, mkdir, mv, pwd, rm, rmdir, touch, umask, vi
![Page 3: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/3.jpg)
Agenda – Activity 1 Introduction to Unix Processes
Foreground Process Background Process Running Processes in the background
& character Suspending Processes
^Z special key Displaying suspended jobs
jobs command
![Page 4: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/4.jpg)
Agenda – Activity 1 Continued
Displaying status of processes ps command
Killing Processes kill, and kill –9 command
In Class Exercise
![Page 5: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/5.jpg)
Agenda – Activity 1 Continued
Standard Input and Output Redirection and Pipes
>, >>, <, | Common Unix Filters
grep, look, sort, spell, uniq, wc Demonstration of Unix Filters,
Redirection, and Pipes In Class Assignment
![Page 6: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/6.jpg)
Agenda – Activity 2
How to use WinSCP2 to transfer files from your PC to einstein.
Unix Utilities ftp telnet pine elm
Demonstration of Unix Utilities Break (10 minutes)
![Page 7: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/7.jpg)
Agenda – Activity 3
Review for Today’s Final Exam
![Page 8: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/8.jpg)
Agenda – Activity 4
Course Evaluation Break (10 minutes)
![Page 9: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/9.jpg)
Agenda – Activity 5
Take the Final Exam!
![Page 10: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/10.jpg)
Activity 1
![Page 11: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/11.jpg)
UNIX Processes
A PROCESS is a program that is executing.
Processes have Input and Output
There are two types of Processes Foreground Processes Background Processes
![Page 12: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/12.jpg)
Foreground Process
When running a FOREGROUND process, the shell waits for the program to finish
When the process is finished, you will be returned to the command prompt/export/home/morris07>
![Page 13: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/13.jpg)
Background Process
When running a BACKGROUND process, the shell starts the process, then leaves
This allows you to execute other commands at the command prompt
NOTE: Handy for programs that take a long time to run and do not need to run interactively.
![Page 14: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/14.jpg)
Running Processes in Background
Type an ampersand (&) after the command to run it in the background
> find . –name java > javaLocations.txt &
![Page 15: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/15.jpg)
Suspending Processes
You can SUSPEND a process by typing ^Z
This will pause the process temporarily. The process can be resumed in the Foreground or moved to the Background:
/export/home/morris07> fg [jobid]/export/home/morris07> bg [jobid]
![Page 16: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/16.jpg)
Displaying List of Suspended Jobs
/export/home/morris07> jobs…
[1] Stopped vi document[2] Stopped elm
-l option gives more information
![Page 17: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/17.jpg)
Displaying Status of Processes
Use ps to report the status of a process
/export/home/morris07>ps… PID TTY TIME CMD19834 pts/7 0:05 ksh19954 pts/7 0:04 ps
![Page 18: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/18.jpg)
Killing a Process
Use kill to terminate a process running in the background
/export/home/morris07>kill {process id}
This sends a signal to the process to end.
![Page 19: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/19.jpg)
That Process Won’t Die!!
The kill command waits for the process to perform cleanup: write to files, close files,etc.
If the process will not end, use the ‘-9’ or ‘-KILL’ to kill the process immediately
> kill –9 19954> kill –KILL 19954
![Page 20: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/20.jpg)
In Class Exercise1. Start vi /etc/motd2. In Command Mode type ^Z3. Type jobs -l to see any suspended jobs4. Type fg to bring last suspended job to
foreground.5. In Command Mode type ^Z6. Type jobs -l to see any suspended jobs7. Type kill {Process ID} to kill the process8. Type ps to get current list of processes9. If the process is still running, type ‘kill –9
{Process ID}10. Type ps to get current list of processes
![Page 21: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/21.jpg)
Question/Answer Session
![Page 22: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/22.jpg)
Standard Input and Output
command terminal standard output
standard inputcommandkeyboard
![Page 23: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/23.jpg)
Redirection and Pipes
Redirecting Standard Output to a File with: ‘>’, ‘>>’
ls –al > mylist (creates or overwrites file)
ls –al >> mylist (appends or creates file)
command terminal standard output
command file redirected output
![Page 24: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/24.jpg)
Redirection and Pipes
Redirecting Standard Output to a Command with: ‘|’
ls –al | more (passes output to command)
command terminal standard output
command redirected outputcommand
![Page 25: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/25.jpg)
Redirection and Pipes
Redirecting Standard Input from a File with: ‘<’
cat < file (passes file to command)
standard input
redirected inputcommand
commandkeyboard
file
![Page 26: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/26.jpg)
Filters
A FILTER is any program that reads from Standard Input and writes to Standard Output.
grepuniqlookspellsortwc
![Page 27: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/27.jpg)
Filters: grep
The grep command searches for the pattern specified and writes these lines to Standard Output.
grep [-cilnvw] pattern [file…]
> grep ‘Easy’ assignments.txt
![Page 28: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/28.jpg)
Demonstration - grep
![Page 29: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/29.jpg)
Filters: uniq
The uniq command examines data, looking for consecutive, duplicate lines.
uniq [-cdu] [infile [outfile]] uniq –d , retains one copy of all lines that are
duplicated uniq –u, retains only those lines that are not
duplicated. uniq –c, counts how many times each line is found.
> uniq document.txt
![Page 30: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/30.jpg)
Filters: look
The look command searches data in alphabetical order and will find lines that begin with a specified pattern (alphabetical characters only).
look [-df] pattern [file…]
>look Amer* Access the dictionary of correctly spelled words.
• Look is not really a filter and cannot be used within a pipeline. • File must be pre-sort file with –dfu options. I.e dictionary, fold,
unique.
![Page 31: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/31.jpg)
Filters: look
![Page 32: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/32.jpg)
Filters: spell
The spell command will read data and generate a list of all words that look as if they are misspelled. This is a very primitive spell checker.
spell [file…]
>spell document.txt
![Page 33: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/33.jpg)
Filters: spell
For example, Mispeel was not flagged
Adds standard prefixes and suffixes to words in dictionary
![Page 34: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/34.jpg)
Filters: sort
The sort command sorts data (using ASCII format).
sort [-dfnru] [infile…] [-o outfile]>sort names -o sorted_namesor>sort names > sorted_names
![Page 35: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/35.jpg)
Filters: sort
![Page 36: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/36.jpg)
Filters: sort
![Page 37: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/37.jpg)
Filters: wc
The wc command counts lines, words, and characters.
wc [-lwc] [file…]
> wc -l document.txt
![Page 38: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/38.jpg)
wc options
-c Count bytes.-m Count characters.-C Same as -m.-l Count lines.-w Count words delimited by
white space characters or new line characters.
![Page 39: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/39.jpg)
In Class Assignment
![Page 40: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/40.jpg)
Question/Answer Session
![Page 41: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/41.jpg)
Activity 2
![Page 42: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/42.jpg)
Transferring files to einstein from your PC
WinSCP3 is software that provides secure FTP (File Transfer Protocol), which allows you to transfer files to and from a PC (freeware) Required for secure FTP to/from the class
Unix server einstein. Required for secure FTP from a remote
location, such as your home or your office Download WinSCP3and view directions at the
CLAS Lab Reference Manual web page: http://www.franklin.edu/programs/comp/resources/claslab/index_html/view
![Page 43: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/43.jpg)
Transferring files to einstein from your PC
Locate the WinSCP3 icon on your desktop and double click to open.
![Page 44: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/44.jpg)
Transferring files to einstein from your PC
![Page 45: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/45.jpg)
Transferring files to einstein from your PC
![Page 46: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/46.jpg)
Transferring files to einstein from your PC
![Page 47: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/47.jpg)
UNIX Utilities: ftp
FTP (File Transfer Protocol) allows you to transfer files to and from a remote network site (machine).
ftp [-dgintv] [hostname]
> ftp einstein.franklin.edu
Uses put and get commands to send and receive files.Type bin for setting binary transfer modeType prompt, to turn off promptingType ls, or dir for a directory listing
![Page 48: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/48.jpg)
UNIX Utilities: telnet
Telnet is a user interface to a remote system using the TELNET protocol.
telnet [-8ELcdr] [hostname]
> telnet einstein.franklin.edu
![Page 49: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/49.jpg)
UNIX Utilities: e-mail
Two most popular mail programs are elm and pine.
Note: Most Unix systems still have the “more basic” e-mail package called mail
![Page 50: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/50.jpg)
pine
The pine program has a menu-driven interface and is quite simple to use. One advantage of pine over elm is that it is very simple to include attachments.
> pine
- Follow the prompts in the menu
![Page 51: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/51.jpg)
elm
The elm program is the mail utility that is most often used. It is more difficult to use, but more powerful. It uses vi to compose messages.
> elm
![Page 52: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/52.jpg)
Question/Answer Session
![Page 53: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/53.jpg)
Break (10 Minutes)
![Page 54: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/54.jpg)
Activity 3
![Page 55: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/55.jpg)
Final Review: Week 1
History of Unix Unix design philosophy The Unix shell, variables and options Unix commands: alias, cat, date, echo, exit, finger,
hostname, login, lp, ls, man, more, passwd, set, setenv, uname, wc, whatis, whereis, who, whoami
![Page 56: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/56.jpg)
Final Review: Week 2
Unix file system structure File types and access permissions Create and use directories and files Edit files with vi (try on your
command line) Use the following Unix commands:
cd, chmod, cp, id, mkdir, mv, pwd, rm, rmdir, touch, umask, vi
![Page 57: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/57.jpg)
Final Review: Week 3
Unix processes Redirection, pipes, and filters Unix utilities (e-mail, ftp, telnet) Use the following Unix commands:
elm, ftp, grep, jobs, kill, look, pine, ps, sort, spell, telnet, uniq, wc
![Page 58: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/58.jpg)
Final Exam PoliciesExam Information
Prohibited Items:
No Books No Notes No Dictionary No Calculator No Laptop No Access to any computers No Writing or scratch paper (extra paper will be supplied with the
exam)
Allowed Items:
Writing instrument.
One hour in length allowed for taking the exam.
![Page 59: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/59.jpg)
Activity 4
![Page 60: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/60.jpg)
Please complete the course evaluation Need a student volunteer to collect and take
the evaluations to faculty services. 10 minute break after evaluation is complete.
Course Evaluation
![Page 61: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/61.jpg)
Break (10 Minutes)
![Page 62: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/62.jpg)
Activity 5
![Page 63: COMP 104: Intro to Unix](https://reader035.vdocuments.us/reader035/viewer/2022062722/56813a07550346895da1d3b8/html5/thumbnails/63.jpg)
Good Luck Everyone!!
Final Examination