
Lecture Notes 9-1-09 & 9-3-09 ENGR 0011 - Dr. Lund • Welcome to ENGR 0011 • ENGR 0011 webpage • My webpage • Accessing my.pitt.edu • Intro to UNIX Course Information • Professor : Laura Lund, PhD • Email : [email protected] • ENGR 11 Website : www.engr.pitt.edu/~eng11 • Text : Introduction to Engineering Analysis by Dan Budny • My website : www.pitt.edu/~lwlund courseweb.pitt.edu • TA : Michael Richard ([email protected]) Course Goals • To develop programming skills • To understand and learn to apply commonly used engineering analysis techniques • To develop your writing, communication and team skills • To significantly increase your expectation of and ability to manage a heavy homework load 1 Lecture Notes Chapter 2 - UNIX Topics… 1. Unix Commands Language for using Unix file system 2. Telnet Protocol for communicating with Unix host 3. FTP File transfer protocol with Unix file system 4. PICO Unix text editor 5. Pine Unix email program Why Are We Learning About UNIX? 1. So you can understand how to store, organize, access and manipulate webpages and other files on your personal Pitt Unix account space. 2. To teach the concept of absolute and relative addressing WHY? This concept is important in programming because it is the means by which a programmer successfully and effectively accesses file data or runs other programs that are stored in locations different than the location of the program from where this information is being accessed. For example, you may want to create and store a program in a certain folder of your computer, but in that program you may need to read in data or run another sub-program that is stored in another folder on your computer, or maybe on another computer all together. How do you tell your program to find that data or sub-program? 1.A. Introduction to UNIX • What is UNIX? – UNIX is an operating system designed for use on mainframe computers – UNIX is a time-sharing and multitasking operating system – Univ of Pittsburgh’s mainframe uses the UNIX operating system – The Pitt UNIX mainframe stores all student, faculty and staff account information and files – This mainframe is also a web server; everyone with an account on the Pitt mainframe can use their account to store and serve web pages – UNIX software includes tools for communication between the mainframe and any network linked PC 2 1.B. UNIX Components • Kernel – Master control; the part of the program which controls all computer operations • Shell – user interface window; allows a user to send commands and receive information to and from the Kernel • File System – system for storing units of information, or files; UNIX sorts files by user • Utilities – useful programs which are part of the UNIX operating system, such as email programs, file editors, database programs… 1.C. Intro to the UNIX File System • The value of learning to use the UNIX file system is that: – You can access the files you place here from any computer at Pitt and almost any computer worldwide (that is hooked up to a network) – You can create and post a personal web page • To communicate with the UNIX system and to access your UNIX account/folder requires a software program that utilizes a specific protocol. This type of communication program is referred to as a SHELL. • Telnet is a terminal emulation protocol (a shell) for communication between a local and remote computer in plain text. It is not a secure protocol! • SSH is a secure shell protocol for communication which encrypts all keystrokes (i.e. your login and password!) 1.D. Opening a secure session • Pitt now requires the we use an SSH connection. • To do so, we will be using a software program called “PuTTY ”. This program is available on many PCs, in our labs, and is free to download. – Open the “PuTTY” program and make sure the “SSH” button is selected. – Enter the following in the Host Name (or IP address) box: unixs.cis.pitt.edu – Click “open ”. – Enter your university login and password. – After some system messages, you should see the UNIX prompt. 3 1.E. UNIX File System • If you type the command “ pwd ” (stands for present working directory) and hit enter, you will be shown your home directory • The top of the tree is known as the root directory, which is / (not /afs ) • All user account files are stored under the “home” subdirectory /afs/pitt.edu/home 1.F. Common Commands • man – help command • pwd – present working directory • ls – list command • mkdir – make a new directory command • rmdir – remove directory command • cd – change directory command • rm – the remove command • cp – the copy command • mv – the move file command • chmod – changes protections on files and directorries • exit – logout of system 1.G.i. ls Command options • -a lists all files, including .___ hidden files • -F indicates file types • -m shows files as a comma separated list • -s shows size of files • -C forces multiple column output • -1 forces single column output • -d forces ls to list directories rather than their contents • -R causes ls to list recursively directories below specified one • -l forces long listing, i.e. gives all file info • Examples : ls –a –l (lists all files in working directory with all file info) ls public/html (lists files in subdirectory /afs/pitt.edu/home/l/w/lwund/public/html directory using relative addressing) 4 1.G.ii. “cp” Command • Use to copy one or more files to a different directory, or to same directory with a different name • Examples: – cp file1 file2 (Copies to same directory with different name) – cp public/file1 private (copies to new directory, name stays same) – cp file1 file2 file3 private/backup (Copies 3 files to private/backup directory, keeping same names) – cp public/html/* private/backup (Copies all files in public/html to private/backup) 1.G.iii. “mv” Command • Use to move files or directories • Use to rename a file or directory • Examples: – Move a file… mv file1 private/file1.bkp (Moves file1 to private dirctory and changes name to file1.bkp) mv file1 private (Moves file1 to private, keeping same name) mv file1 file2 file3 private (Moves 3 files to private) – Move a directory… mv public/html/eng11 private/eng12bkp (takes eng12 directory and moves it and all of its files to a new directory under private called eng12bkp) – Rename a file… mv private/file1 private/file1.old 1.H. Absolute & Relative Addressing • Path – the path is the direction to a subdirectory or file Ex: /afs/pitt.edu/home/l/w/lwlund/Public/html/ • Absolute addressing – the path starting from the root directory • Relative addressing – the path relative to the present directory – “..” Means up one level Ex: cd ../../../b/u/budny This command would follow the path of going up three directories from your home directory then down to the b/u/budny directory – For a relative path to a folder below (or within) your present directory, start with the name of a lower folder without putting a slash at the beginning Ex: cd public/html/ 5 1.I. Special Addressing Characters Wild Characters : * Can be used to represent multiple wild card characters (Ex: cp private/pictures/*.jpg ../../../b/u/budny/public ) ? Can be used to represent a single wild card character Absolute Addressing Characters: ~ Starts path at user’s home directory (Ex: cd ~/public/html) . Refers to present working directory (Ex: mv /private/Courses/file1 . ) Sample Unix File System User’s home /afs/pitt.edu/home/j/o/joeng public private backup html R10 eng11 calc chem homework classwork hw1 hw2 hw3 hw4 ca090406 Some Examples Assume you are “ joeng ” and have opened a Telnet session with your Unix account, and are currently in your home directory. Your file system is shown on the screen above. • If you type “pwd”, what would be returned? /afs/pitt.edu/home/j/o/joeng • Using relative addressing, what command would you use to list the contents of the “homework” directory? ls private/eng11/homework • Using absolute addressing, what command would you use to change your current location to the “R10” directory? cd /afs/pitt.edu/home/j/o/joeng/public/R1 6 • Now that you are in the R10 directory, what single command would you use to copy all of the homework files from the homework directory to the R10 directory (use relative addressing)? cp ../../private/eng11/homework/hw* . • What command would you use to create a new directory called “writing” under the “eng11” directory, from the R10 directory? mkdir ../../private/eng11/writing • What command would you use to list the contents of the R10 directory so that you can view all of the files with their protection modes? ls –a –l or ls -al • What command would you use to get help on the “ls” command if you forgot the extensions? man ls 1.J. More Commands • finger – finger command for finding people • cat [filename] – (catenate) displays contents of file • cal – calendar • date – gives day, date and time • more [filename] – affects how info is displayed • pg [filename] – similar to more • grep – search command • who – gives a list of the users currently signed on to UNIX • who am I • clear – clears screen • du –k – gives disk utilization • tree –d – shows file folder structure of account 1.K. File names in UNIX • Very flexible up to 256 characters (128 on some older systems) • Any type of characters – numbers, letters, dash, comma, etc. • NEVER USE SPACES IN A UNIX FILE NAME • stuff, STUFF, Stuff, stuFF are all different! 7 3.A. What is “sftp”? • “sftp” is a secure file transfer protocol used to transfer files between a local system (your computer) and a remote system (Pitt’s server).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages11 Page
-
File Size-