1 / 41

Operating Systems and Using Linux

Learn about operating systems and how to use Linux with frequently used commands. Connect to UMBC Linux servers and communicate with the computer. Understand files, directories, and commonly used Linux commands.

sauter
Download Presentation

Operating Systems and Using Linux

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems and Using Linux • Review Operating System. • Linux Overview. • Frequently Used Linux Commands. • Definition of an Algorithm. • Algorithm Examples.

  2. Review Operating System • A computer program. • Performs many operations, such as: • Allows you to communicate with the computer (tell it what to do). • Controls access (login) to the computer. • Keeps track of all processes currently running. • At this point, your main concern is how to communicate with the computer using the OS.

  3. Connecting to UMBC Linux Servers • See http://www.umbc.edu/oit/pc_ppp/index.html for dtails. • Setup your PC for dial-up connections. • Dial 410-719-1094 or 301-322-6199 with your myUMBC or gl account. (Helpdesk: 410-455-3838 or ECS 020). • Telnet to one of the following linux servers: • telnet linux1.gl.umbc.edu • telnet linux2.gl.umbc.edu • telnet linux3.gl.umbc.edu

  4. Connecting to UMBC Linux Servers

  5. Connecting to UMBC Linux Servers

  6. Connecting to UMBC Linux Servers

  7. How Do I Communicate With the Computer Using the OS? (con’t) • When you log in to the Linux system here, a user • prompt will be displayed: • linux#[1]% _ • where # is the number of the Linux server that you have connected to. You may use any of the Linux servers. • The number in the brackets will change as you work. It is • the “number” of the command that you are about to type. • If this prompt is not on the screen at any time, you are not communicating with the OS.

  8. Linux Overview • Files and Filenames. • Directories and Subdirectories. • Frequently Used Commands.

  9. Files • A file is a sequence of bytes. • It can be created by • a text editor (xemacs or pico), • a computer program (such as a C program). • It may contain a program, data, a document, or other information . • Files that contain other files are called directories (sometimes called folders).

  10. Linux Filenames • Restrictions • May not contain blanks or other reserved characters. • Have a maximum length. • Are case sensitive. • It is best to stick with filenames that contain letters (uppercase or lowercase), numbers, and the underscore ( _ ) for now.

  11. Directories • Directories contain files or other directories called subdirectories. They may also be empty. • Directories are organized in a hierarchical fashion. • They help us to keep our files organized.

  12. Directories (con’t) /afs/umbc.edu/users/j/d/jdoe28 junk recipes cmsc104 pies cookies projects lectures apple peach choc_chip

  13. Directories (con’t) • Your home directoryis where you are located when you log in (e.g., /afs/umbc.edu/users/j/d/jdoe28). • The current directory is where you are located at any time while you are using the system. • Files within the same directory must be given unique names. • Paths allow us to give the same name to different files located in different directories. • Each running program has a current directory and all filenames are implicitly assumed to start with the name of that directory unless they begin with a slash.

  14. Moving in the Directory Tree • . (dot) is the current directory. • . . (dot-dot) is the parent directory. • Use the Linux command cd to change directories. • Use dot-dot to move up the tree, e.g., cd .. • Use the directory name to move down, e.g., cd cmsc104. • Use the complete directory name (path name) to move anywhere, e.g., cd cmsc104/proj1.

  15. Wildcard Characters • You will find wildcard characters useful when manipulating files (e.g., listing or moving them). • The wildcard characters are * and ?. • ? is used to represent any single character. • * is used to represent 0 or more characters.

  16. Frequently Used Linux Commands • pwd – present working directory to check where you are in the directory tree. • ls – list of files or subdirectories, e.g., ls proj* or ls –l. • cd – change directory to pathname, cd pathname. • cp – copy files from file1 to file1b, e.g., cp file1 file1b. • mv – rename file from file1 to file2, e.g., mv file1 file2. • rm – remove (delete) files, e.g., file1 file2 … • mkdir – make directory dir-name, e.g. mkdir dir-name. • rmdir – remove (delete) directory, e.g. rmdir dir-name. • man – look up how to use the command, man cp. • passwd – to change password. • ctl-c – to terminate command, process, … • Other commands: cat, more.

  17. Frequently Used Linux Commands References: • Linux man page. • Links from the cmsc 104 homepage. http://www.cs.umbc.edu/courses/undergraduate/104/fall02/chen/ • Books and the Internet.

  18. Examples • For example, • make a subdirectory for cmsc104, e.g., • mkdir cmsc104, cd cmsc104, and • make subdirectories for projects, lectures, homeworks, exams, e.g., mkdir projects homeworks exams lectures . • Directory tree: cmsc104 exams homeworks lectures projects ex1 ex2 final hw1 … hwn L1 … Ln proj1 … projn

  19. linux1[3]% ls -l • drwxr-xr-x 2 lichen 32 2048 Sep 9 15:49 Desktop • lrwxr-xr-x 1 lichen 32 7 Sep 2 00:38 Mail -> ../Mail • drwxr-xr-x 2 lichen 32 2048 Aug 13 1998 bin • drwx------ 3 lichen 32 2048 Sep 10 15:25 li • lrwxr-xr-x 1 lichen 32 10 Sep 2 00:38 www -> ../pub/www access # links owner group file size last modified date filename r: read w: write x: execute l: link d: directory

  20. Algorithms, Part 1 of 3 Topics • Definition of an Algorithm. • Algorithm Examples. • Syntax versus Semantics. Reading • Sections 3.1 - 3.3

  21. Problem Solving • Problem solving is the process of transforming the description of a problem into the solution of that problem. • We use our knowledge of the problem domain. • We rely on our ability to select and use appropriate problem-solving strategies, techniques, and tools.

  22. Algorithms • An algorithm is a step by step solution to a problem. • Why bother writing an algorithm? • For your own use in the future. You won’t have to rethink the problem. • So others can use it, even if they know very little about the principles behind how the solution was derived.

  23. Examples of Algorithms • Washing machine instructions. • Washing hair instructions (ambiguous algorithm). • A classic: finding the greatest common divisor (GCD) using Euclid’s Algorithm.

  24. Washing Machine Instructions • Separate clothes into white clothes and colored clothes. • If white clothes: • Set water temperature knob to HOT. • Place white laundry in tub. • If colored clothes: • Set water temperature knob to COLD. • Place colored laundry in tub. • Add 1 cup of laundry detergent to tub. • Close lid and press the start button.

  25. Washing Machine Instructions (con’t) Observe that • There are a finite number of steps. • We are capable of doing each of the instructions. • When we have followed all of the steps, the washing machine will wash the clothes and then will stop.

  26. Refinement of Algorithm Definition • Our old definition: • An algorithm is a step by step solution to a problem. • Adding our observations: • An algorithm is a finite set of executable instructions that directs a terminating activity.

  27. Ambiguous Algorithms Washing Hair Instructions: • Lather. • Rinse. • Repeat. How could these instructions be hard to follow?

  28. Final Version of the Algorithm Definition • Our old definition: • An algorithm is a finite set of executable instructions that directs a terminating activity. • Final version: • An algorithm is a finite set of unambiguous, executable instructions that directs a terminating activity.

  29. History of Algorithms • The study of algorithms began as a subject in mathematics. • The search for algorithms was a significant activity of early mathematicians. • Goal: To find a single set of instructions that can be used to solve any problem of a particular type (a general solution).

  30. Euclid’s Algorithm Problem: Find the largest positive integer that divides evenly into two given positive integers, i.e., the Greatest Common Divisor (GCD). Algorithm: • Let M, N be two positive integers, where M > N. • Divide M by N and call the remainder R. • If R is not 0, then Let M = N, N=R. Go to step 2. • Else (R = 0) GCD = N.

  31. Finding the GCD of 24 and 9 M N R 24 9 6 9 6 3 6 3 0 Done. So, 3 is the GCD of 24 and 9.

  32. Euclid’s Algorithm (con’t) • Do we need to know the theory that Euclid used to come up with this algorithm in order to use it? • What intelligence is required to find the GCD using this algorithm?

  33. The Idea Behind Algorithms • Once an algorithm behind a task has been discovered. • We don't need to understand the principles. • The intelligence is "encoded into the algorithm.“ • The task is reduced to following the instructions.

  34. Algorithm Representation • Syntax and Semantics • Syntax refers to the representation itself. • Semantics refers to the concept represented (i.e., the logic).

  35. Contrasting Syntax and Semantics • In the English language, we have both syntax and semantics. • Syntax is the grammar of the language. • Semantics is the meaning. • Given the following sentence, I walked to the corner grocery store. • Is this sentence syntactically correct? • Is it semantically correct?

  36. Contrasting Syntax and Semantics (con’t) • Given the following sentence, I talked to the funny grocery store. • Is this sentence syntactically correct? • Is it semantically correct? • How about I grocery store walked corner the to.

  37. Contrasting Syntax and Semantics (con’t) • Conclusion: An English sentence may be syntactically correct, yet semantically incorrect. • This is also true of algorithms. • And it is also true of computer code. • Note that it only makes sense to consider semantic if syntax is correct.

  38. Next • More problem solving and algorithms. • Pseudocode. • Assignment: • Read 3.1 – 3.10 (skip the C code, just the pseudocode.) • Login to one of the linux servers, perform some of the unix commands from home or school. • linux1.gl.umbc.edu • linux2.gl.umbc.edu • linux3.gl.umbc.edu

More Related