I zm ir I nstiute of Technology CS - 1 0 2 Lecture 1 Lecture Notes are based on the CS 101 notes at the University of I llinois at Urbana-Cham paign
I zm ir I nstiute of Technology W hat w ill I learn from this Lecture? 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?
Hardw are and Softw are Ap p licat io n s Un ix En g in eer in g W o r k st at ion s UNI X- operating syst em / C- program m ing language / Matlab Facilit at e m ach in e in d ep en d en t p r o g r am d ev elop m en t
Softw are Co m p u t er p r o g 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 ells t h e co m p u t er w h at t o d o. A p r o g r am t ak es r aw d at a as in p u t an d p r o d u ces in f o r m at io n as o u t p u t. Sy st em So f t w ar e: Op er at in g Sy st em s Un ix,lin u x,w in d o w s,macos,os/ 2,VM/ CMS,... Ed it o r Pr o g r am s em acs, x em acs, k at e, n an o, p ico, v i,... Ap p licat io n s So f t w ar e: Tr an slat o r s an d I n t er p r et er s g cc- - g n u c co m p iler scilab - - in t er p r et er User cr eat ed Pr o g r am s!!!
X- W indow s: Linux- GUI X- w in d o w s- a W in d o w Man ag er an d GUI ( Gr ap h ical User I n t er f ace) Click st ar t an d f o llow t h e m en u s o r click o n an ico n t o r u n a p r o g r am ( in Lab # 2 y o u w ill u se t h ese f eat u r es).
Linux Com m and line I nterface To p r o d u ce a co m m an d lin e in t er f ace click x t er m ( I n Lab # 2 y o u w ill p r act ice t h e Lin u x co m m an d s p r esen t ed in t h e f o llow in g slid es). W h en t h e f o llo w in g slid es r ef er t o Lin u x co m m an d s it is assu m ed t h at t h ese ar e en t er ed o n t h e co m m an d lin e t h at b eg in s w it h t h e sy m b o l # ( n u m b er sy m b o l).
Linux file system the directory tree Dat a, in f o r m at ion, co m p u t er in st r u ct ion s, et c. ar e sav ed in seco n d ar y st o r ag e ( au x iliar y st o r ag e) in files. Files ar e co llect ed o r o r g an ized in directories. Each u ser o n a m u lt i- u ser sy st em h as h is/ h er o w n hom e directory. I n Un ix u ser s an d sy st em ad m in ist r at o r s o r g an ize f iles an d d ir ect o r ies in a h ier ar ch ical tree. seco n d ar y st o r ag e Home Directory When 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 treec The string / hom e/ g/ gt/ gt u/ gursoy is called a pat h. The path defines the location of a file or directory in the tree known by the Unix system. For this exam ple we know that the directory tree contains the following: Th e d ir ect o r y / is called t h e r o o t d ir ect o r y. / etc hom e lib f g h gs gt gu gtu gt uran
Linux directories - Navigation We can navigate through the directories using the cd com m and. For exam ple, typing in cd.. gives
Linux directories - Navigation So t h e.. w ill t ak e u s u p o n e lev el in t h e t r ee. I f w e r ep eat ed t h is co m m an d cd..
Linux directories - Navigation Absolute and Relative Paths We are now in the / directory. To go back to our home directory : > cd ~ (tilde) or > cd or > 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 Viewing the contents Use t h e ls ( list ) co m m an d t o v iew t h e co n t en t s o f a d ir ect o r y. Not e t h at t h e co n t en t s o f a d ir ect o r y ar e f iles an d su b d ir ect o r ies, h o w ev er u sin g ls alon e d o es n o t d ist in g u ish b et w een t h e t w o.
Linux directories ls command general format ls options argum ent s w h er e options ar e an y co m b in at ion s o f - a List all 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 ile ch an g e - l List in lon g f o r m at, g iv in g lin k s, o w n er, size in b y t es, an d t im e o f t h e last f ile ch an g e. - F Mar k s d ir ect o r ies w it h a / - R Also list s each su b d ir ect o r y f o u n d an d argum ents is a list o f d ir ect o r ies an d / o r f ilen am es sep ar at ed b y b lan k s.
Linux directories ls command option -la > ls - la p r o d u ces t h e o u t p u t
Linux directories ls command option -lac Th e f ir st f ew lin es o f o u t p u t f r o m t h e ls - la co m m an d ar e d escr ib ed b elo w. N o t e: t o set p er m issio n s u se t h e chm od co m m an d. - = file d = directory Permissions Links user group - rw------- 1 gturan users 57 Mar 1 22:34.xauthfhZ91X d rwxr-xr-x 2 gturan users 48 Mar 1 23:02 Arastirma size in bytes date of lasst change File name
Linux directories ls command option -la Per m ission s r - r ead w - w r it e x - ex ecu t e Per m ission s ar e assig n ed t o t h e user, group an d other users.
chmod command Fr o m slid e 1 4, if w e w an t t o r est r ict o t h er s n o t t o b e ab le t o r ead o r r u n f iles in t h e Ar ast ir m a d ir ect o r y w e w o u 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 al st at u s, allo w in g p er m ission s t o o t h er u ser s w e w o u ld t y p e: > chm od o+ rx tom r - r ead w - w r it e x - ex ecu t e Per m ission s ar e assig n ed t o t h e u user, g group an d o other users.
Linux directories ls command wildcards I n t h e lab s st u d en t s w ill lear n t o u se k at e t o cr eat e t ex t f iles. I n p ar t icu lar scilab f iles w ill h av e n am es lik e f.sci o r test.sce o r m y.dat. C f iles w ill h av e n am es lik e f.c o r test.c. I f y o u f o r g et t h e ex act n am e o f a f ile u se > ls *.sce Th e * is a w ild car d ch ar act er m ean in g, m at ch zer o o r m o r e ch ar act er s. An o t h er w ild car d is? w h ich m ean s m at ch ex act ly o n e ch ar act er.
Linux directories more command To see t h e co n t en t s o f a f ile ( w it h o u t u sin g k at e) o n t h e t er m in al u se t h e m o r e co m m an d. $ m ore odev1.sce
Kate - editing a text file W e w ill u se t h e k at e ed it o r in CS1 0 2. To o p en k at e, p r ess ALT+ F2 an d t y p e kate.
What have I learned from this lecture? A p r o g r am is a seq u en ce o f in st r u ct ion s t h at t ells t h e co m p u t er w h at t o d o. X- W in d o w s is an ex am p le o f a W in d o w Man ag er. GUI m ean s g r ap h ical u ser in t er f ace. Yo u n av ig at e t h e Un ix d ir ect o r y t r ee b y u sin g t h e cd co m m an d. A w ild 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 ilen am es o r d ir ect o r y n am es. k at e is an ed it o r. Ef f ect iv e u se o f t h is ed it o r m ean s n o t clo sin g it u n t il y o u h av e f in ish ed y o u r p r o g r am m in g session.