Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class Introduction. Agenda Syllabus Topics Text etc.

Similar presentations


Presentation on theme: "Class Introduction. Agenda Syllabus Topics Text etc."— Presentation transcript:

1 Class Introduction

2 Agenda Syllabus Topics Text etc

3 Homework/Lab File Format Word processor on PCs is OpenOffice, use “Save As” to convert to.doc I can read.pdf,.doc,.docx or.odt Please no screen shots in homework, plain text is fine! Assignment says “Provide References”, please do so or it’s points off

4 Intro To Linux

5 Unix History Developed at Bell Labs in the late 1960s. First O/S to run on multiple hardware types Original Open Source!

6 Linux History Written by Linux Torvalds as a free clone of Minix –Used the GNU tool chain with a custom kernel.1 came out in 9/1991.2 = 10/1991 Current Stable version: 3.2.11 (as of 3/15/2012) http://www.freebsdnews.net/wp- content/uploads/unix_family_history_tree_1600x 1200.jpg

7 Timeline

8 Linux GUIs KDE = K Desktop Environment –Used QT which wasn’t “free” GNOME = GNU Object Model Environment –Totally “free” desktop environment There are tons of others

9 CLI CLI = Command Line Interface Typically a shell, much more powerful than a GUI but not near as user-friendly

10 File System File System Layout

11 Some Useful Commands ls – lists files cd – change directories cp – copy files mv – move files rm – remove (or delete) files etc, etc, etc

12 Bash

13 Acronym for Bourne Again Shell Default for Linux, available for most commercial Unixes. Advanced Bash Scripting: http://www.faqs.org/docs/abs/HTML/index. html

14 What does a shell do? Reads input Breaks input into tokens Use those tokens to create commands Do shell expansion, i.e. parse *,., ?, etc Check for redirection Return an exit status

15 Basic Token Parsing Typical command: –ls –a -l a* ls is a command -a -l are arguments for the command - = 1 letter arguments -- = human readable arguments a* gets expanded to match all files beginning with a in the current directory

16 Shell startup Reads the following in order to initialize shell variables: –/etc/profile –/etc/bashrc –Run the first one of these: ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc

17 Useful Variables HISTSIZE = # of commands stored PWD = the current directory OLDPWD = your old directory PATH = the path that’s searched for commands PS1 = your prompt Access via commands: set or env

18 Variable Rules Typically UPPERCASE, but don’t have to be No space when asssigning! –VAR=First (works)‏ –VAR = First (does not)‏

19 Aliases New name for a command, use alias to create, unalias to remove alias rm=“rm –i” – always prompt on rm

20 Expansion Brace or {} – used to generate lists Tilde or ~ - shorthand for home directory Command or `` - take the output of what’s in the `` and use it Pattern Matching or Regular Expression – foo* match everything that starts with foo

21 Special Characters \, $, ‘’, “”, `` - are the specials \ (or escape) removes special meaning $ access variables ‘’ means literal output “” means mostly literal output `` stores output from a command

22 Redirection I/O is typically keyboard/screen, shells allow redirection | means pipe one command to another > is overwrite >> is append < is redirect input << read until tag

23 Other features Tab completion History Command Line Editing (defaults to emacs, can use vi)‏ Help

24 Regular Expressions

25 What are they? A regular expression is a string of characters that matches a pattern of some kind. –000 –01010 –aabbcc –Stuart Usually used with meta-characters

26 Metacharacters. = match any character exactly 1 time * = match 0 or more characters + = match 1 or more characters ^ = match at start of line $ = match at end of line

27 Metacharacters II [chars] = match chars in bracket (not PATTERN)‏ [^chars] = ignore chars in bracket (not PATTERN)‏ \ = escape special characters, i.e. \^ | = or choices {this|or|that} {n} = match at least n occurances {n,m} = match at least n but not more than m

28 Metacharacters III: the examples ^[0-9] – matches lines that start with digits b.d – matches anything with a b followed by any character and a d (such as bad, bed, bid, bcd)‏ [a-z] – matches any lower case letter [a-zA-Z] – matches any letter [a-z]\{1,3\} – matches any string of 1 to 3 letters (ask, eee, q, be, bet, etc)‏ [tT][iI][fF]\{1,2\} – matches a t or T followed by an i or I followed by 1 or 2 f or Fs [a-z]\{3\}|[A-Z]\{3\} – matches any three letters as long as all three are upper case or lower case

29 RegExp and ls Can’t use ^, { }, +, or $, but most everything else works –ls *[0-9]* = match files with 0-9 in name. means match., not a single character!

30 grep

31 RegExp and grep grep = Grab REgular exPressions 4 different versions on Linux: –grep – limited regexp set –egrep – largest regexp set (also grep –E)‏ –rgrep – recursive grep (also grep -r) –fgrep (fast grep) – very limited regexp set metacharacters ( $, *, [, ^, |, (, ), \ ) translated literally!

32 Uses for grep Your company just got bought. How many files have the old company in them on the web server? What’s a 7 letter word for “Queens of Russia that starts with ts and ends with an a? How many files got changed in August of last year?

33 Useful grep arguments -c = shows a count of matches in the file(s)‏ -n = shows what lines the matches are on -l = just file names -v – negate the search -i – ignore case

34 More useful grep arguments --color=# - display in color –# = always, color, none

35 Advanced grep arguments -A, -B, -C = context to search –-A # = # lines after –-B # = # lines before –-C # = # lines around --regexp=PATTERN = Use PATTERN as the pattern; useful to protect patterns beginning with -.

36 Finding Words \< = blank space at beginning of word \> = blank space at end of word -w = find word, has to have white space


Download ppt "Class Introduction. Agenda Syllabus Topics Text etc."

Similar presentations


Ads by Google