Set4: UNIX1

898 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
898
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
33
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Drawing shadowed boxes with PowerPoint is easy. Simply use the Rectangle tool to draw the box and then choose Shadowed from the Draw menu. Be sure to delete this word processing box before using this template for your own presentation.
  • Set4: UNIX1

    1. 1. Title Slide <ul><li>Internet Concepts </li></ul><ul><li>The UNIX Operating System (1) </li></ul><ul><li>By </li></ul><ul><li>Ralph B. Bisland, Jr. </li></ul>CSS 404/504
    2. 2. The UNIX Operating System <ul><li>Developed from the Multics Operating System project </li></ul><ul><li>Developed at Bell Labs in 1969 (Originally called Unics) </li></ul><ul><li>UNIX commands are text based (command interpreter) </li></ul><ul><li>Windows version of UNIX: X-Windows </li></ul>
    3. 3. Versions Of UNIX <ul><li>Called shells </li></ul><ul><ul><li>C-Shell (csh) </li></ul></ul><ul><ul><li>TC Shell (tcsh) </li></ul></ul><ul><ul><li>Korn Shell (ksh) </li></ul></ul><ul><ul><li>Z shell (zsh) ( what I use ) </li></ul></ul><ul><ul><li>Borne Shell (bsh) </li></ul></ul><ul><ul><li>Borne Again Shell (bash) ( USM CS Default ) </li></ul></ul>
    4. 4. Why Learn UNIX <ul><li>Most Internet Service Providers (ISPs) utilize the UNIX Operating System </li></ul><ul><li>Some ISPs use GUI interfaces - limit what you can do </li></ul><ul><li>UNIX Operating systems have communications software built into their software. </li></ul>
    5. 5. UNIX Basics <ul><li>UNIX commands are very cryptic (Often 2 letters) </li></ul><ul><li>The case of UNIX commands is very important !!!!!!!! </li></ul><ul><ul><li>ls  LS  Ls </li></ul></ul><ul><li>UNIX commands are usually entered in lowercase </li></ul>
    6. 6. Command Parameters <ul><li>UNIX commands may have parameters </li></ul><ul><li>Parameters are uused to specify options to commands </li></ul><ul><li>Case is important here too </li></ul><ul><li>Parameters are preceded by a dash </li></ul><ul><li>Multiple parameters may be grouped together or specified separately </li></ul><ul><li>Multiple parameters may be placed in any order the user desires </li></ul><ul><li>Examples </li></ul><ul><ul><li>ls -a </li></ul></ul><ul><ul><li>ls -al </li></ul></ul><ul><ul><li>ls -la </li></ul></ul>
    7. 7. UNIX Basics (ctd) <ul><li>The UNIX prompt differs with each shell </li></ul><ul><li>Z-Shell default prompt is: orca:~% </li></ul><ul><ul><li>This may be altered </li></ul></ul><ul><li>UNIX is not MS-DOS, Windows, or Macintosh OS X </li></ul><ul><li>Since MS-DOS &quot;borrowed&quot; some concepts from UNIX, some UNIX concepts are very similar to MS-DOS </li></ul>
    8. 8. Connecting to Orca <ul><li>For security reasons this must be done through secure shell (ssh) and not telnet. </li></ul><ul><li>To get a free ssh client program enter ssh client (or ssh macintosh) into a search engine. </li></ul><ul><li>You also try Putty (win32 client) </li></ul><ul><li>Click on the Secure Shell icon to start it up. </li></ul><ul><li>Click on “Quick connect” to connect to orca. </li></ul>
    9. 9. Login Names & Passwords <ul><li>To connect to a UNIX based computer system two things are needed: </li></ul><ul><ul><li>Login name (login ID) </li></ul></ul><ul><ul><li>Password </li></ul></ul>
    10. 10. Login Names <ul><li>General rules: </li></ul><ul><ul><li>6-8 characters </li></ul></ul><ul><ul><li>digits </li></ul></ul><ul><ul><li>Can contain special characters such as -, _, and . </li></ul></ul><ul><ul><li>Case sensitive </li></ul></ul><ul><li>This is assigned by the system administrator and can not be changed. </li></ul><ul><li>This becomes your E-mail address. [email_address] </li></ul>
    11. 11. Passwords <ul><li>General rules: </li></ul><ul><ul><li>At least 6 characters, at least 2 must be non-lowercase letters </li></ul></ul><ul><li>Passwords should be kept confidential. </li></ul><ul><li>Do not use simple names, dates, etc. as passwords. </li></ul><ul><li>Use a sentence to create your password. </li></ul><ul><li>Example: I am a Computer Science major IaaCSm </li></ul>
    12. 12. Changing Passwords <ul><li>To change your password, use the password command (passwd) </li></ul><ul><li>Format: passwd NOTE: This will not work on the ocean system </li></ul><ul><li>Example: </li></ul><ul><li>orca% passwd </li></ul><ul><li>Enter login (LDAP) password: </li></ul><ul><li>New UNIX password: </li></ul><ul><li>Retype new UNIX password: </li></ul><ul><li>orca% </li></ul><ul><li>Note that for security reasons the passwords are not echoed </li></ul>
    13. 13. Disconnecting from Orca <ul><li>To disconnect from orca, enter any of the following commands: (well most probably) </li></ul><ul><ul><li>logout (This one works all the time) </li></ul></ul><ul><ul><li>exit </li></ul></ul><ul><ul><li>bye </li></ul></ul><ul><ul><li>lo (works for me) </li></ul></ul><ul><li>Remember that case is important when entering the commands!!!! </li></ul><ul><li>After doing this you also have to exit the ssh client. </li></ul>
    14. 14. UNIX Files <ul><li>A file is a collection of data that is stored on some secondary storage device. </li></ul><ul><li>UNIX file names have no maximum storage limit. </li></ul><ul><li>UNIX file are where the HTML commands for creating web pages are stored. </li></ul>
    15. 15. UNIX File Naming Conventions <ul><li>Limited to 64 characters </li></ul><ul><li>May contain special characters (except blank, / and possibly a leading -) </li></ul><ul><li>Files that begin with a period (called a dot) have special meanings </li></ul><ul><li>Case of letters is important. </li></ul><ul><li>my-file  MY-FILE  My-File </li></ul><ul><li>Convention calls for a file extension to be appended to each file name. </li></ul><ul><li>Place a period after the file name and add the extension </li></ul><ul><li>my-file.dat </li></ul>
    16. 16. UNIX Directories <ul><li>Directories/subdirectories are used to segregate files </li></ul><ul><li>On PC/Macs these are called folders </li></ul><ul><li>The UNIX directory system forms a tree or hierarchical structure </li></ul><ul><li>The top directory of the tree is called the root </li></ul><ul><li>Each user has a home directory (which is a subdirectory of root ) </li></ul><ul><li>The user's home directory is the user's login name </li></ul>
    17. 17. UNIX Directories Root Bisland Gregg Rimes Not exact but close enough for now
    18. 18. Directory Notes <ul><li>You may currently &quot;reside&quot; in only one directory/subdirectory at a time. </li></ul><ul><li>Once you transfer from one directory to another, you leave the first one and enter the second one. </li></ul><ul><li>The directory/subdirectory that you currently reside in is called your &quot;current working directory&quot; (cwd) or &quot;working directory“. </li></ul>
    19. 19. Orca’s Directory Structure <ul><li>Orca’s directory system is configured its UNIX directories as follows: </li></ul><ul><li>/logical-computer-name/group-name/login-name </li></ul><ul><li>(slashes separate subdirectories) </li></ul><ul><li>Where </li></ul><ul><ul><li>logical-computer-name: Logical name of the computing systems </li></ul></ul><ul><ul><li>group-name: Logical group name that the user falls into. Probably faculty, student, many others </li></ul></ul><ul><ul><li>login-name: User's login name </li></ul></ul><ul><li>Example: </li></ul><ul><li>/orca/faculty/bisland </li></ul>
    20. 20. Orca’s Directory Structure orca Faculty Students Staff others Bisland Gregg Internet Database SE-Eng T-Hunts Tests
    21. 21. Creation Of Subdirectories <ul><li>To create a subdirectory, use the make directory (mkdir) command </li></ul><ul><li>Format: mkdir subdirectory-name </li></ul><ul><li>Example: </li></ul><ul><li>orca% mkdir internet-course </li></ul><ul><li>The command creates a subdirectory in your working current directory </li></ul>
    22. 22. Moving To Subdirectories <ul><li>To make a subdirectory your current working directory, use the change directory (cd) command. </li></ul><ul><li>Format: cd subdirectory-name </li></ul><ul><li>Example: </li></ul><ul><li>orca% cd internet-course </li></ul><ul><li>Use the cd command by itself move back to your home directory from any subdirectory. </li></ul>
    23. 23. Moving To Subdirectories (ctd) <ul><li>Every directory contains two files called . (dot) and .. (dot dot) </li></ul><ul><ul><li>. => Name of the current working directory </li></ul></ul><ul><ul><li>.. => Name of the superdirectory of the current working directory </li></ul></ul><ul><li>To move back up one level, use the command cd .. </li></ul><ul><li>$ cd .. </li></ul>
    24. 24. Files In Other Directories <ul><li>To access a file in another directory, you must specify the path to the file </li></ul><ul><li>The path may be specified in either of two ways: </li></ul><ul><ul><li>Absolute Path: The exact path to the file relative to the computer’s home directory </li></ul></ul><ul><ul><li>Relative Path: Relative to the current working directory </li></ul></ul>
    25. 25. Relative Path Names Location of a file relative to the current working directory. bisland internet grades database projects Assume that the cwd is internet, the relative path to the file test1.dat in the subdirectory grades is grades/test1.dat Note that a slash does not precede the first subdirectory name
    26. 26. Absolute Path Names Location of the file regardless of the current working directory bisland internet grades database projects Assume the cwd is database and we wanted to get to the file test1.dat in the grades subdirectory, the absolute path name is: /orca/faculty/bisland/internet/grades/test1.dat Note that absolute directory names are preceded by a slash Note that the absolute path name includes the logical computer name followed by the group name, followed by the logon name (the home directory), followed by the subdirectories
    27. 27. The Tilde Symbol <ul><li>The tilde symbol (~) can be used to get to a user's home directory </li></ul><ul><li>UNIX uses it's internal files to find the specified home directory </li></ul><ul><li>To get to the test1.dat file in the previous example, we could specify the path: </li></ul><ul><li>/orca/faculty/bisland/internet/grades/test1.dat </li></ul><ul><li>or using the tilde notation we could access it with the following path: </li></ul><ul><li>~bisland/internet/grades/test1.dat </li></ul>
    28. 28. Where Am I? <ul><li>To display the absolute path to your current working directory use the print working directory (pwd) command. </li></ul><ul><li>Format: pwd </li></ul><ul><li>Example: </li></ul><ul><li>orca% pwd </li></ul><ul><li>orca/faculty/bisland/internet </li></ul>
    29. 29. Removing Directories <ul><li>Subdirectories can only be removed when they are empty! </li></ul><ul><li>The only files they contain are . and .. (Removal of files is discussed later) </li></ul><ul><li>To remove a directory, the cwd must be the parent directory </li></ul><ul><li>To remove a subdirectory, use the remove directory command (rmdir) </li></ul><ul><li>Format: rmdir subdirectory-name </li></ul><ul><li>Example: </li></ul><ul><li>orca % rmdir internet </li></ul>
    30. 30. Displaying A Directory <ul><li>To display the names of the files in a directory use the list command (ls) </li></ul><ul><li>Format: ls [-parameters] </li></ul><ul><li>Example 1: (list the names of the files in the cwd) </li></ul><ul><li>orca% ls </li></ul><ul><li>Example 2: (lists the names of the files in the subdirectory internet-course) </li></ul><ul><li>orca% ls internet-course </li></ul>
    31. 31. Displaying A Directory (ctd) <ul><li>Parameters: </li></ul><ul><ul><li>a: All files with a directory (including ones that begin with a period) </li></ul></ul><ul><ul><li>F: Directories are displayed with a slash suffix and programs are displayed with an asterisk suffix </li></ul></ul><ul><ul><li>l: Produces a long listing of each directory entry </li></ul></ul><ul><li>Example 3: (produces a long list of everything in cwd) </li></ul><ul><li>orca % ls -l </li></ul>
    32. 32. Displaying The Contents Of A File <ul><li>There are several utility programs to list the contents of a file available in UNIX </li></ul><ul><ul><li>Catenate (cat): </li></ul></ul><ul><ul><li>More (more) </li></ul></ul><ul><ul><li>Less (less) </li></ul></ul><ul><ul><li>Head (head) </li></ul></ul><ul><ul><li>Tail (tail) </li></ul></ul>
    33. 33. Catenate <ul><li>Lists the contents of a file from top to bottom. </li></ul><ul><li>If the file is too long to fit on a page, the excess is scrolled off the top of the page. </li></ul><ul><li>Good for listing small files. </li></ul><ul><li>Format: cat filename </li></ul><ul><li>orca% cat my-file.dat </li></ul>
    34. 34. More <ul><li>Displays the first &quot;page&quot; of the file and waits for instructions </li></ul><ul><ul><li>Return Key = One new line is displayed </li></ul></ul><ul><ul><li>Space Bar = One new page is displayed </li></ul></ul><ul><ul><li>q = Quit the display </li></ul></ul><ul><li>Format: more filename </li></ul><ul><li>orca% more my-file.dat </li></ul>
    35. 35. Head & Tail <ul><li>The head and tail commands are used to display parts of a text file. </li></ul><ul><li>You may optionally specify the number of lines to list. </li></ul><ul><li>Default is 10 lines </li></ul><ul><li>Formats: head [-l] <filename> </li></ul><ul><li>tail [-|+l] <filename> </li></ul><ul><li>orca% head my-file.dat </li></ul><ul><li>orca% tail my-file.dat </li></ul><ul><li>orca% head -20 my-file.dat </li></ul><ul><li>orca% tail -20 my-file.dat </li></ul><ul><li>orca% tail +10 my-file.dat {list from line 10 to EOF} </li></ul>
    36. 36. UNIX Text Editors <ul><li>Text Editor: A program that allows the creation and editing of text files. </li></ul><ul><li>This is what we will use to create the HTML files. </li></ul><ul><li>Similar to a word processor but without all the features </li></ul><ul><li>Text Editors create lines of text </li></ul><ul><ul><li>Each line is terminated by an EOLN mark </li></ul></ul><ul><ul><li>Each file is terminated by an EOF mark </li></ul></ul><ul><li>No fancy editing features like a word processor </li></ul><ul><ul><li>Word wrap </li></ul></ul><ul><ul><li>Boldface, centering, underlining, etc. </li></ul></ul>
    37. 37. PICO <ul><li>PICO = PI ne CO mposer </li></ul><ul><li>Very simple text editor - can only be used on text files (ASCII files). </li></ul><ul><li>Limited in what it can do (find and replace, delete multiple lines, etc.) </li></ul><ul><li>Default editor on the orca system. </li></ul><ul><li>Some of the PICO commands are shown across the bottom of the screen. </li></ul><ul><li>All PICO commands begin with a control key (shown as ^letter). </li></ul>
    38. 38. PICO (ctd) <ul><li>To enter the PICO Editor, enter the word &quot;pico&quot;, followed by a blank space, followed by the name of the file you wish to create/edit. </li></ul><ul><li>orca % pico my-file.dat </li></ul><ul><li>The screen will clear and the PICO edit window is now open. </li></ul><ul><li>Use the arrow keys to move the cursor around. </li></ul><ul><li>Whatever you enter will be entered in the text file. </li></ul>
    39. 39. List Of The PICO Commands ^G: Help on PICO. (F1) ^F: Move the cursor forward one character. ^B: Move the cursor backward one character. ^N: Move the cursor down (next) one line. ^P: Move the cursor up (previous) line. ^A: Move the cursor to the beginning of the current line. ^E: Move the cursor to the end of the current line. ^V: Move cursor forward a page. (F8) ^Y: Move the cursor backward a page. (F7) ^W: Search for (where is) text neglecting case. (F6) ^L: Refresh the display. ^D: Delete the character at the cursor ^K: Delete (kill) the entire line at the current cursor position. (F9) Note: Consecutive deletes append lines to the buffer which subsequently undeletes will write at the current cursor position. ^U: Undelete the last line(s) deleted at the cursor. (F10) ^I: Insert a tab at the current cursor position.
    40. 40. List Of PICO Commands (ctd) ^J: Format (justify) the current paragraph. (F4) Note: Paragraphs delimited by blank lines or indentation ^T: Invoke the spelling checker. (F12) ^C: Report the current cursor position. (F11) ^R: Insert an external file at the current cursor position. (F5) ^O: Output the current buffer to a file. (F3) ^X: Exit pico, saving the contents of the buffer to a file. (F2)
    41. 41. Sample PICO Edit Session PICO 1.7 File: my-file.dat  [ New file ] ^G Get Help ^O WriteOut ^R Read File^Y Prev Pg ^K Del Line ^C Cur Pos ^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnDel Lin^T To Spell
    42. 42. Deleting Files <ul><li>To delete a file from the system, use the remove command (rm) </li></ul><ul><li>Format: rm filename </li></ul><ul><li>orca% rm my-file.dat </li></ul><ul><li>You will probably be asked for confirmation when you remove a file. </li></ul><ul><li>orca% rm my-file.dat </li></ul><ul><li>rm: remove ‘my-file.dat’? </li></ul>
    43. 43. Wildcards <ul><li>In some file commands wild cards can be used to substitute for characters or character strings </li></ul><ul><li>Wildcard Meaning </li></ul><ul><li>-------- --------------------------------------------- </li></ul><ul><li>* Match any sequence of zero or more characters </li></ul><ul><li>? Match any single character </li></ul><ul><li>[ ] Match one of the enclosed characters </li></ul><ul><li>Note: The only character that can not be matched by a wildcard is the slash (/) </li></ul>
    44. 44. Wildcard Examples orca% rm *.dat orca% rm file* orca% rm ?.dat orca% rm set[123].dat orca% ls -l *.dat orca% ls *.* orca% rm *
    45. 45. Renaming A File <ul><li>To rename a file, use the move command (mv) </li></ul><ul><li>Format: </li></ul><ul><li>mv oldfile-name newfile-name </li></ul><ul><li>Example: </li></ul><ul><li>orca% mv my-file.dat your-file.dat </li></ul><ul><li>Since a directory is in essence a file, directories can be renamed via the mv command. </li></ul><ul><li>Format: </li></ul><ul><li>mv old-directory-name new-directory-name </li></ul><ul><li>orca% mv internet-course internet - stuff </li></ul>
    46. 46. Making A Duplicate Copy Of A File <ul><li>To make a duplicate copy of a file, use the copy command (cp) </li></ul><ul><li>Format: cp old-file new-file </li></ul><ul><li>Example: </li></ul><ul><li>orca% cp my-file.dat your-file.dat </li></ul>
    47. 47. Files In Different Directories <ul><li>To move a file from one directory to another directory, use the mv command </li></ul><ul><li>Format: mv <filename> <directory-name> </li></ul><ul><li>Example: </li></ul><ul><li>orca% mv my-file.dat internet-course </li></ul><ul><li>To copy a file from one directory to another, use the cp command </li></ul><ul><li>Format: cp <filename> <directory-name> </li></ul><ul><li>orca% cp my-file.dat internet-course </li></ul>
    48. 48. History <ul><li>History allows you to retrieve previously entered commands. </li></ul><ul><li>This only works on commands entered during the current terminal session. </li></ul><ul><li>Once a command has been retrieved, it can be executed and/or editted. </li></ul><ul><li>To retrieve previously entered commands use the up arrow or the down arrow key. </li></ul><ul><li>To edit a command, use the backward or forward key to position the cursor at the editing point, then enter character or delete characters. </li></ul>
    49. 49. Filename Completion <ul><li>UNIX allows the user to enter enough character of a filename to determine a unique file name, then completes the file name for you. </li></ul><ul><li>To do this, enter enough characters for UNIX to identify the file name, then press the TAB key – UNIX completes the file name for you. </li></ul><ul><li>This feature only works on file names, not commands. </li></ul>
    50. 50. Printing <ul><li>Any text file may be printed on the laser printer in JST 205 or TEC207 </li></ul><ul><li>Caution: Only print text files on the printer!!! </li></ul><ul><li>The command to print a text file is lpr. </li></ul><ul><li>Format: lpr <filename> </li></ul><ul><li>Example: </li></ul><ul><li>orca% lpr my-file.dat </li></ul><ul><li>To check on the status of the USM printers use the lpstat command </li></ul><ul><li>orca% lpstat </li></ul>

    ×