74
Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Embed Size (px)

Citation preview

Page 1: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Lecture 2Unix Basics

Corpus LinguisticsFall 2004

© Kevin Cohen

Page 2: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Last time

• ssh –l my_name babel.colorado.edu

(connect with babel)• pwd (where am I?)• ls (what’s here?)• cd (I want to go somewhere else)• mkdir

Page 3: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Switches: Unix adverbs

• options that you specify• ls –l: long listings• ls –a: show hidden files, too• ls –t: sort by time• ls –lat: show all files, in long

format, sorted by time

Page 4: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Switches

Page 5: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Arguments: objects

• No argument allowed:– pwd

• Argument required:– mkdir

[kev@compbio kev]$ mkdirmkdir: too few argumentsTry `mkdir --help' for more information.[kev@compbio kev]$

Page 6: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Arguments

• Argument(s) optional:– cd (no arg—what happens?)– cd .. (arg is ..—what happens?)

Page 7: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Arguments

• Argument(s) optional:– cd (no arg—what happens?)– cd .. (arg is ..—what happens?)– ls (no arg—what happens?)– ls .cshrc (arg is .cshrc)

Page 8: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Arguments

• Argument(s) optional:– cd (no arg—what happens?)– cd .. (arg is ..—what happens?)– ls (no arg—what happens?)– ls .cshrc (arg is .cshrc)babel>ls .cshrc

.cshrc

babel>ls i_like_my_dog

i_like_my_dog not found

File named .cshrc exists

File named i_like_my_dog doesn’t exist

Page 9: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Wildcards

• Underspecified objects• Syntax: combine with any amount

of the name of an argument• Examples:• ls ling*• ls linguistics*• ls *linguistics

Page 10: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Wildcards

• Underspecified objects• Syntax: combine with any amount

of the name of an argument• Examples:• ls ling*• ls linguistics*• ls *linguistics

Semantics: “allow zero or more of any character(s) here”

Show me:

ling

linguist

linguistics

Page 11: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>pwd /home/kev/demo_wildcardsbabel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

Page 12: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls ling

ling

babel>ls ling*

ling

linguistic_anthropology

linguistic_phonetics

linguistics

linguistics_and_the_law

linguists

Page 13: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls linguist*

Page 14: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls linguist*

linguistic_anthropology

linguistic_phonetics

linguistics

linguistics_and_the_law

linguists

Page 15: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls *linguistics

Page 16: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls *linguistics

linguistics

psycholinguistics

sociolinguistics

Page 17: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls *ics

Page 18: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls *ics

linguistic_phonetics

linguistics

phonetics

psycholinguistics

sociolinguistics

Page 19: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls *and*

Page 20: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

babel>lslinglinguistic_anthropologylinguistic_phoneticslinguisticslinguistics_and_the_lawlinguistsmorphologyphoneticspsycholinguisticssociolinguistics

babel>ls *and*

linguistics_and_the_law

Page 21: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Switches + Arguments

• You can combine them. – Switches come first.

• ls –lt li*• “List everything that starts with li

followed by zero or more of any other character…

• …show me the “long” version…• …and arrange them by “time.”

Page 22: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Two ways of specifying location

• Relative: walk out the door. Take stairs to first floor. Exit building from east. Take 36 to I-70. Get off at Vasquez exit. Merge onto Colorado. Turn left onto 23rd. Turn right onto Krameria. Go to next block. Go to house on southwest corner.

Page 23: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Two ways of specifying location

• Relative: walk out the door. Take stairs to first floor. Exit building from east. Take 36 to I-70. Get off at Vasquez exit. Merge onto Colorado. Turn left onto 23rd. Turn right onto Krameria. Go to next block. Go to house on southwest corner.

• Absolute: Go to 2089 Krameria St., Denver, CO.

Page 24: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

I’m in /home/kev, and I want to see the contents of /home• Using relative

path:

ls ..

• Using absolute path:

ls /home

Page 25: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

I’m in /home/kev, and I want to see the contents of

/home/jurafsky• Using relative

path:

ls ../jurafsky

• Using absolute path:

ls /home/jurafsky

/

bin home etc usr

otherfolks

jurafskykev

Page 26: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

More things you can do with files

• View their contents• Copy• Rename/move them • Delete them• Count contents• Compare their contents

Please open a terminal and ssh to

babel

Page 27: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Viewing file contents

• The whole thing at once• The whole thing, a bit at a time• Just part of it

Page 28: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Viewing file contents

• The whole thing at once• cat filename• Example:• cd• ls -a• cat .cshrc

Page 29: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Viewing file contents

• The whole thing, a bit at a time• more filename• Example:• ls /corpora/celex/english• more /corpora/celex/english/README

Page 30: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Viewing file contents

• Just some of it (just the beginning)• head filename• head –number_of_lines filename• Example:• head /corpora/celex/english/README• head –20 /corpora/celex/english/README

Page 31: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Viewing file contents

• Just some of it (just the end)• tail filename• tail –number_of_lines filename• Example:• head /corpora/celex/english/README• head –20 /corpora/celex/english/README

Page 32: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Copying: cp

• A ditransitive verb• cp original_file new_file• Example:• cd• cp .cshrc .cshrc_bak

Page 33: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Caution: no guardrails

• touch junk• cat junk• cp .cshrc junk • cat junk

Page 34: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Moving/renaming: mv

• A ditransitive verb• mv original_file new_file• Example 1:• cd• ls• mv .cshrc.bak .cshrc_bak01

Page 35: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Moving/renaming: mv

• A ditransitive verb• mv original_file new_file• Example 1:• cd• ls• mv .cshrc.bak .cshrc_bak01

Renames the file

Page 36: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Moving/renaming: mv

• A ditransitive verb• mv original_file new_file• Example 2:• cd ling5200• ls• mv ../junk .

Page 37: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Moving/renaming: mv

• A ditransitive verb• mv original_file new_file• Example 2:• cd ling5200• ls• mv ../junk .

Moves the file from parent

to current directory

Page 38: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Moving/renaming: mv

• A ditransitive verb• mv original_file new_file• Example 3:• cd ling5200• ls• mv ../junk mango

Page 39: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Moving/renaming: mv

• A ditransitive verb• mv original_file new_file• Example 3:• cd ling5200• ls• mv ../junk mango

Moves from parent to current directory

and changes name

Page 40: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

man pages

• Unix’s help facility• Syntax: man command_name• E.g.: man cp

To see more, hit the spacebar

Page 41: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Comparing files: diff

• A ditransitive verb• diff one_file another_file• Example 3:• cd ling5200• diff ../junk mango• touch junk• diff junk mango

Page 42: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

man pages

• Name• Synopsis of syntax• Description• Options

Page 43: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

man pages

Page 44: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Remember you said you’d like cp to ask you before it blew

away your file?

• Consult the man page for cp• Make a back-up copy of your .cshrc file

(cp .cshrc .cshrc.bk01)• Open it in a text editor (emacs .cshrc)• Create an alias for cp• Ctrl-XS Ctrl-X Ctrl-C• Tell Unix about your new alias

(source .cshrc)

Page 45: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Interlude

Page 46: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

HW1

1. Well?

Page 47: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

HW1 #1

“He has all of the primary facts that he needs, in the form of a corpus of approximately one zillion running words, and he sees his job as that of deriving secondary facts from his primary facts. At the moment he is busy determining the relative frequencies of the eleven parts of speech as the first word of a sentence versus the second word of a sentence.”

--Fillmore

Page 48: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

HW1 #1

He sits in a deep soft armchair, with his eyes closed and his hands clasped behind his head. Once in a while he opens his eyes, sits up abruptly shouting, ‘Wow, what a neat fact!’, grabs his pencil, and writes something down…having come still no closer to knowing what language is really like.”

--Fillmore

Page 49: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

HW1 #1

• Why should I think anything you tell me is true?

• Why should I think anything you tell me is interesting?

Page 50: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

HW1 #1

“They [take] this to be science, very genuinely and very sadly.”

--Postal

Page 51: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

HW1 #1

• Rationalism as theory, yes—method, no (Sampson)

• “I don’t think there can be any corpora, however large, that contain information about all of the areas of English lexicon and grammar that I want to explore…[but] every corpus I have had the chance to examine, however small, has taught me facts I couldn’t imagine finding out any other way.” (Fillmore)

Page 52: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

HW1

5. ssh

Page 53: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Some important Unix concepts

• Redirection• Security/permissions• Environment

Page 54: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Piping and redirection

• Piping: sending the output of one command to another command as its input

cat .cshrc | wc

Use the output of

that…

…as the input for this

Page 55: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Piping and redirection

• ls –l /corpora2• ls –l /corpora2 | head• ls –l /corpora2 | head -5

Page 56: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Piping and redirection

• Redirection: sending output someplace other than to your screen

ls –l /corpora2 > corpora2_contents

Put the output of

this command

…into this file

Page 57: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Piping and redirection

• If the file doesn’t already exist…• If the file does already exist…• >>• cat .cshrc > junk• ls –lt /corpora2 >> junk

No space!

Page 58: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

LINGUIST-L

Position Description:

Primary responsibility is the creation and maintenance of linguistic test data. This involves analyzing a set of sentences and generating the expected linguistic analysis based on the specification. Other responsibilities include evaluating linguistic coverage, reporting accuracy, generating linguistic bugs, and tracking regression of the products and technology.

Page 59: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

• passwd: change your password– no real words– mix case (E.g. M!nkeY, not m!nkey)– mix letters, other symbols (@rm3n!an)– change frequently– nothing obvious (chomsky, phonology,

birthday, cat’s name)– DON’T email them

Page 60: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

You

Page 61: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

You

...Z

Y

X

Page 62: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

students

...

staff

Page 63: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Permissions

File Directory

r •view•copy

list contents

w •change•delete

•create•delete

x execute cd into

Page 64: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

• Permissions

“-” means file

“d” means directory

you

(user)

Page 65: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

• Permissions

“-” means file

“d” means directory

Page 66: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

• Permissions

“-” means file

“d” means directory

you

(user)

group

Page 67: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Security

• Permissions

“-” means file

“d” means directory

you

(user)

group

others (world)

Page 68: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Changing permissions

• Easy way: chmod who+/-what filename

• Who:– u: user (you)– g: group– o: other (world)

Page 69: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Changing permissions

• Easy way: chmod who+/-what filename• Who:

– u: user (you)– g: group– o: other (world)

• What:– r: read– w: write– x: execute

Page 70: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Changing permissions

• Easy way: chmod who+/-what filename• Who:

– u: user (you)– g: group– o: other (world)

• What:– r: read– w: write– x: execute

chmod u+x helloWorld.pl

Page 71: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Changing permissions

• Easy way: chmod who+/-what filename• Who:

– u: user (you)– g: group– o: other (world)

• What:– r: read– w: write– x: execute

chmod u+x helloWorld.pl

chmod go-w helloWorld.pl

Page 72: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Changing permissions

• Medium: chmod u=rwx,g=r,o=r hello.pl• Who:

– u: user (you)– g: group– o: other (world)

• What:– r: read– w: write– x: execute

chmod u+x helloWorld.pl

chmod go-w helloWorld.pl

Page 73: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Changing permissions

• Hard: chmod 744 helloWorld.pl• Who:

– First digit: user (you)– Second digit: group– Third digit: other (world)

• What:– 4: read– 2: write– 1: execute– 0: nothing

chmod u+x helloWorld.pl

chmod go-w helloWorld.pl

Page 74: Lecture 2 Unix Basics Corpus Linguistics Fall 2004 © Kevin Cohen

Environment

• uname• echo $SHELL• echo $PATH• setenv• setenv DUMMY_VARIABLE melgibsonsux• echo $DUMMY_VARIABLE