CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories...

22
Lecture 1 Izmir Instiute of Technology CS - 102 Lecture Notes are based on the CS 101 notes at the University of Illinois at Urbana-Champaign

Transcript of CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories...

Page 1: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

Lecture 1

I zm ir I nst iute of Technology

CS - 1 0 2

Lecture Notes are based on the CS 101 notes at the Universit y of I llinois at Urbana-Champaign

Page 2: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

What is a program?

What is a “Window Manager” ?What is a “GUI” ?

How do you navigate the Unix/Linux directory tree?

What is a wildcard?

What is kate?

I zm ir I nst iute of Technology

W hat w ill I learn from this Lecture?

Page 3: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

En g in eer in gW or k st at ion s

Un ix

Ap p l i cat ion s

UNI X- operat ing system / C- program m ing language / Mat labFaci l i t a t e m ach in e in d ep en d en t p r og r am d ev elop m en t

Hardw are and Softw are

Page 4: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

Com p u t er p r og r am ( so f t w ar e) : a seq u en ce o f in st r u ct ion s t h at t e l l s t h e com p u t er w h at t o d o . A p r og r am t ak es r aw d at a as in p u t an d p r od u ces in f o r m at ion as ou t p u t .

Sy st em So f t w ar e:

• Op er a t in g Sy st em s

Un ix ,Lin u x ,W in d ow s,MacOS,OS/ 2 ,VM/ CMS,...

• Ed i t o r Pr og r am s em acs, x em acs, k a t e, n an o , p ico , v i , ...

Ap p l ica t ion s So f t w ar e:• Tr an sla t o r s an d I n t er p r e t er s g cc- - g n u c com p i ler sci lab - - in t er p r e t er

• User cr eat ed Pr og r am s! ! !

Softw are

Page 5: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

X- w in d ow s- a W in d ow Man ag er an d GUI ( Gr ap h ica l User I n t er f ace)Cl ick st ar t an d f o l low t h e m en u s o r cl i ck on an icon t o r u n a p r og r am ( in Lab # 2 y ou w i l l u se t h ese f eat u r es) .

X- W indow s: Linux- GUI

Page 6: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

To p r od u ce a com m an d l in e in t er f ace cl ick x t er m ( I n Lab # 2 y ou w i l l p r act ice t h e Lin u x com m an d s p r esen t ed in t h e f o l low in g sl id es) .

W h en t h e f o l low in g sl id es r e f er t o Lin u x com m an d s i t i s assu m ed t h at t h ese ar e en t er ed on t h e com m an d l in e t h at b eg in s w i t h t h e sy m b o l “ # ” ( n u m b er sy m b o l ) .

Linux – Com m and line I nterface

Page 7: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

Dat a, in f o r m at ion , com p u t er in st r u ct ion s, e t c. ar e sav ed in secon d ar y st o r ag e ( au x i l iar y st o r ag e) in f iles. Fi les ar e co l lect ed o r o r g an ized in director ies. Each u ser on a m u l t i - u ser sy st em

h as h is/ h er ow n hom e directory . I n Un ix u ser s an d sy st em ad m in ist r a t o r s o r g an ize f i les an d d i r ect o r ies in a h ier ar ch ica l t ree .

secon d ar y st o r ag e

Home DirectoryWhen a user first logs in on a computer, the user will be “in” the users home directory. To find the name of the directory type> pwd(this is an acronym for print working directory) So the user is in the directory “gturan”

Linux file system – the directory tree

Page 8: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

The st r ing “ / hom e/ g/ gt / gtu/ gursoy” is called a path .The path defines the locat ion of a file or directory in the t ree known by the Unix system. For this example we know that the directory t ree contains the following:

Th e d i r ect o r y “ / ” i s ca l led t h e r oo t d i r ect o r y .

Linux file system – the directory treec

/

etc hom e lib

f g h

gs gt gu

gtu

gturan

Page 9: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

We can navigate through the director ies using the ”cd” com m and. For exam ple, typing in cd .. gives

Linux directories - Navigation

Page 10: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

So t h e .. w i l l t ak e u s u p on e lev e l in t h e t r ee. I f w e r ep eat ed t h is com m an d cd ..

Linux directories - Navigation

Page 11: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

We are now in the / directory. To go back to our home directory :> cd ~ (tilde)or> cdor> cd gtu/gursoy (relative path)or > cd /home/g/gt/gtu/gursoy (absolute path)

To go to a particular directory we can always list a path starting with the root “ / ” and going down directory by directory using the “ / ” as in the last example. This is an example of an absolute path. However since “gtu” is the name of a subdirectory of “gt” we can use a relative path “gtu/gturan”. Here, the symbol “/” does not appear before gtu.

Linux directories - Navigation

Absolute and Relat ive Paths

Page 12: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

Use t h e “ ls” ( list ) com m an d t o v iew t h e con t en t s o f a d i r ect o r y . No t e t h at t h e con t en t s o f a d i r ect o r y ar e f i les an d su b d i r ect o r ies, h ow ev er u sin g “ ls” a lon e d oes n o t d ist in g u ish bet w een t h e t w o .

Linux directories – Viewing the contents

Page 13: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

ls opt ions argum ents

w h er e opt ions ar e an y com b in at ion s o f- a List a l l en t r ies, in clu d in g d o t en t r ies- c List b y t im e o f last f i le ch an g e- l List in lon g f o r m at , g iv in g l in k s, ow n er , size in b y t es, an d t im e o f t h e last f i l e ch an g e.- F Mar k s d i r ect o r ies w i t h a /- R A lso l i st s each su b d i r ect o r y f ou n d

an d argum ents i s a l i st o f d i r ect o r ies an d / o r f i len am es sep ar at ed b y b lan k s.

Linux directories – ls command general format

Page 14: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

> ls - la p r od u ces t h e ou t pu t

Linux directories – ls command option -la

Page 15: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

Th e f i r st f ew l in es o f ou t p u t f r om t h e ls - la com m an d ar e d escr ib ed b elow . No t e: t o set p er m ission s u se t h e chm od com m an d .

Linux directories – ls command option -lac

- = fi

le

d =

dire

ctor

y

Perm

issi

ons

Link

s

user

grou

p

size

in b

ytes

date

of l

asst

cha

nge

File

nam

e

- rw------- 1 gturan users 57 Mar 1 22:34 .xauthfhZ91Xd rwxr-xr-x 2 gturan users 48 Mar 1 23:02 Arastirma

Page 16: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

Per m ission s

r - r eadw - w r i t ex - ex ecu t e

Per m ission s ar e assig n ed t o t h e user , group an d other users.

Linux directories – ls command option -la

Page 17: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

Fr om sl id e 1 4 , i f w e w an t t o r est r i ct o t h er s n o t t o b e ab le t o r ead o r r u n f i l es in t h e ‘Ar ast i r m a ’ d i r ect o r y w e w ou ld t y p e:> chm od o- rx tom

To ch an g e b ack t o t h e o r ig in a l st a t u s, a l low in g p er m ission s t o o t h er u ser s w e w ou ld t y p e:> chm od o+ rx tom

r - r eadw - w r i t ex - ex ecu t ePer m ission s ar e assig n ed t o t h e u user , g group an d o other users.

chmod command

Page 18: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

I n t h e lab s st u d en t s w i l l l ear n t o u se k at e t o cr eat e t ex t f i les. I n p ar t icu lar sci lab f i les w i l l h av e n am es l i k e f .sci o r test .sce o r m y.dat . C f i les w i l l h av e n am es l i k e f .c o r test .c . I f y ou f o r g et t h e ex act n am e o f a f i l e u se> ls * .sce

Th e “ * “ i s a w i ld car d ch ar act er m ean in g , m at ch zer o o r m or e ch ar act er s. An o t h er w i ld car d is “ ? “ w h ich m ean s m at ch ex act ly on e ch ar act er .

Linux directories – ls command wildcards

Page 19: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

To see t h e con t en t s o f a f i le ( w i t h ou t u sin g k at e) on t h e t er m in al u se t h e m or e com m an d .$ m ore odev1 .sce

Linux directories – more command

Page 20: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

W e w i l l u se t h e k at e ed i t o r in CS1 0 2 . To op en k at e, p r ess ALT+ F2 an d t y p e kate .

Kate - editing a text file

Page 21: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –
Page 22: CS - 102 Lecture 1web.iyte.edu.tr/~gursoyturan/Diger-Dersler/CS-102/ders-1.pdf · Linux directories – ls command general format > ls -la produces the output Linux directories –

A p r og r am is a seq u en ce o f in st r u ct ion s t h at t e l l s t h e com p u t er w h at t o d o .

X- W in d ow s is an ex am p le o f a “ W in d ow Man ag er ” .

“ GUI ” m ean s g r ap h ica l u ser in t er f ace.

You n av ig at e t h e Un ix d i r ect o r y t r ee b y u sin g t h e cd com m an d .

A w i ld car d is a ch ar act er su ch as “ * ” o r “ ? ” ( in Lin u x ) t h at ar e u sed t o m at ch f i len am es o r d i r ect o r y n am es.

k at e i s an ed i t o r . Ef f ect iv e u se o f t h is ed i t o r m ean s n o t closin g i t u n t i l y ou h av e f in ish ed y ou r p r og r am m in g session .

What have I learned from this lecture?