Next Previous Contents

4. Arxeia kai Programmata

4.1 Arxeia: Eisagwgika 8emata

H domh twn arxeiwn kai katalogwn toy Linux einai arketa paromoia me aythn toy DOSWin. Ta arxeia exoyn onomata poy ypokeintai se orismenoys kanones, fylassontai se katalogoys, kapoia einai ektelesima kai metaju twn ektelesimwn kapoia exoyn diakoptes (switches) ws entoles. Epipleon, mporeite na xrhsimopoieite xarakthres mpalantes (wildcard), anakateu8ynshs (redirection) kai piping. Yparxoyn mono kapoies mikres diafores:

Mporeite twra na metafer8eite sthn enothta Metafrash entolwn apo to DOS sto Linux, sth 8esh sas omws 8a diabaza ki allo.

4.2 Symbolikoi desmoi

Sto UNIX yparxei ena eidos arxeiwn poy den yparxei sto DOS: o symbolikos desmos (symbolic link). Ayto mporei na 8ewrh8ei ws deikths pros ena arxeio h enan katalogo, kai mporei na xrhsimopoieitai anti gia to deiknyomeno· einai paromoio me tis syntomeuseis twn Windows. Paradeigmata symbolikwn desmwn einai to /usr/X11, poy deixnei sto /usr/X11R6· to /dev/modem, poy deixnei eite sto /dev/ttyS0 h sto /dev/ttyS1.

Gia na ftiajete enan symboliko desmo:

$ ln -s <arxeio_h_katalogos> <onoma_desmou>

Paradeigma:

$ ln -s /usr/doc/g77/DOC g77manual.txt

Twra mporeite na anafereste sto g77manual.txt anti gia to /usr/doc/g77/DOC. Oi desmoi fainontai etsi sthn ejodo toy ls :

$ ls -F
g77manual.txt@
$ ls -l
(diafora_pragmata...)           g77manual.txt -> /usr/doc/g77/DOC

4.3 Dikaiwmata kai Idiokthsies

Ta arxeia kai oi katalogoi sto DOS exoyn ta akoloy8a xarakthristika (attributes): A (archive, arxeia), H (hidden, kryfa), R (read-only, mono gia anagnwsh), and S (system, systhmatos). Monon ta H kai ta R exoyn nohma sto Linux: ta kryfa arxeia jekinoun me mia teleia, oso gia to attribute R, diabaste ki allo.

Sto UNIX ena arxeio exei «dikaiwmata» (permissions) kai enan idiokthth (owner), o opoios me th seira toy anhkei se mia «omada» (group). Deite to paradeigma:

$ ls -l /bin/ls
-rwxr-xr-x  1  root  bin  27281 Aug 15 1995 /bin/ls*

To prwto pedio periexei ta dikaiwmata toy arxeioy /bin/ls, poy anhkei ston root, omada bin. Afhnontas tis ypoloipes plhrofories poy dinei h entolh, stekomaste sth shmasia toy -rwxr-xr-x apo aristera pros ta dejia:

- einai to eidos toy arxeioy (- = kanoniko arxeio, d = katalogos, l = desmos, klp)` rwx einai ta dikaiwmata toy idiokthth toy arxeioy (owner) kai einai(read=anagnwsh, write=eggrafh, execute=ektelesh)· r-x einai ta dikaiwmata ths omadas (group) toy idiokthth (owner) toy arxeioy kai einai (read=anagnwsh, execute=ektelesh)· (De 8a kalucw thn ennoia ths omadas, 8ewrw oti mporeite na kanete kai xwris aythn, ef' oson eiste arxarioi ;-) kai r-x einai ta dikaiwmata gia oloys toys alloys xrhstes (read=anagnwsh, execute=ektelesh).

O katalogos /bin exei epishs dikaiwmata: deite sthn enothta Directories Permissions gia peraiterw plhrofories. Gi' ayto den mporeite na diagracete to arxeio /bin/ls para mono an eiste root: den exete to dikaiwma (permission) na to kanete. Gia na allajete ta dikaiwmata enos arxeioy, h entolh einai:

$ chmod <whoXperm> <file>

opoy who einai u (user=xrhsths, einai o idiokthths), g (group=omada), o (other=alloi), X einai eite + h -, perm einai r (read=anagnwsh), w (write=eggrafh), or x (execute=ektelesh). Kapoia paradeigmata ths xrhshs ths chmod einai ta akoloy8a:

$ chmod +x file

ayto 8etei to dikaiwma ekteleshs gia to arxeio.

$ chmod go-rw file

ayto afairei ta dikaiwmata anagnwshs kai eggrafhs gia oloys, plhn toy idiokthth.

$ chmod ugo+rwx file

ayto dinei se oloys (xrhsth, omada, alloys) dikaiwmata anagnwshs, eggrafhs kai ekteleshs.

# chmod +s file

ayto ftiaxnei ena arxeio «setuid» h «suid» --- ena arxeio poy mporoun oloi na ektelesoyn, me ta dikaiwmata toy idiokthth toy. 8a synanthsete arketa suid arxeia toy root· ayta einai synh8ws shmantika arxeia toy systhmatos, opws o X server.

Enas pio suntomos tropos gia na anafer8ei kaneis sta dikaiwmata einai me ari8mhtika chfia: To rwxr-xr-x mporei na ekfrastei ws 755 (ka8e gramma antistoixei se enan ari8mo: to --- einai 0, to --x einai 1, to -w- einai 2, to -wx einai 3...). Deixnei duskolo, alla me ligh ejaskhsh 8a katalabete thn ennoia. O root, ontas o «yperxrhsths» mporei na allajei ta dikaiwmata twn arxeiwn olwn twn xrhstwn. RMP.

4.4 Arxeia: Metafrazontas entoles

Aristera briskontai oi entoles toy DOS· dejia oi antistoixes gia to Linux.

ATTRIB:         chmod
COPY:           cp
DEL:            rm
MOVE:           mv
REN:            mv
TYPE:           more, less, cat

Telestes anakateu8ynshs (redirection) kai plumbing: < > >> |

Xarakthres Mpalanter: * ?

nul: /dev/null

prn, lpt1: /dev/lp0 h /dev/lp1; lpr

Paradeigmata

DOS                                     Linux
---------------------------------------------------------------------

C:\NIKOS>ATTRIB +R FILE.TXT             $ chmod 400 file.txt
C:\NIKOS>COPY JOE.TXT JOE.DOC           $ cp joe.txt joe.doc
C:\NIKOS>COPY *.* TOTAL                 $ cat * > total
C:\NIKOS>COPY FRACTALS.DOC PRN          $ lpr fractals.doc
C:\NIKOS>DEL TEMP                       $ rm temp
C:\NIKOS>DEL *.BAK                      $ rm *~
C:\NIKOS>MOVE PAPER.TXT TMP\            $ mv paper.txt tmp/
C:\NIKOS>REN PAPER.TXT PAPER.ASC        $ mv paper.txt paper.asc
C:\NIKOS>PRINT LETTER.TXT               $ lpr letter.txt
C:\NIKOS>TYPE LETTER.TXT                $ more letter.txt
C:\NIKOS>TYPE LETTER.TXT                $ less letter.txt
C:\NIKOS>TYPE LETTER.TXT > NUL          $ cat letter.txt > /dev/null
        n/a                             $ more *.txt *.asc
        n/a                             $ cat section*.txt | less

Shmeiwseis:

4.5 Ektelesh Programmatwn: Polydiergasia kai Synedries (Sessions)

Gia na trejete ena programma plhktrologeiste to onoma toy opws 8a kanate kai sto DOS. An o katalogos (Enothta Xrhsh Katalogwn) poy einai egkatesthmeno to programma periexetai sto the PATH (Section Arxeia Arxikopoihshs (Initialisation) Systhmatos), to programma 8a jekinhsei. Ejairesh: En anti8esei pros to DOS, sto Linux ena programma poy periexetai ston trexonta katalogo de 8a trejei, ektos an o katalogos periexetai sto PATH. Lush: an to programma einai prog plhktrologeiste ./prog.

H synh8hs grammh ergaleiwn einai kapws etsi:

$ command [-s1 [-s2] ... [-sn]] [par1 [par2] ... [parn]] [< input] [> output]

opoy -s1, ..., -sn einai oi diakoptes ths entolhs, par1, ..., parn einai oi parametroi toy programmatos. Mporeite na xrhsimopoihsete perissoteres ths mias entoles sthn grammh entolwn:

$ command1 ; command2 ; ... ; commandn

Ayta exw na pw gia to trejimo programmatwn, einai omws polu aplo na poume kati perissotero. Enas apo toys basikous logoys gia th xrhsh toy Linux einai to gegonos oti prokeitai gia ena polydiergasiako L.S., dhladh oti mporei na trexei perissotera toy enos programmata (ef' ejhs diadikasies (processes) taytoxronws). Mporeite na jekinate diadikasies sto peri8wrio (background) synexizontas na ergazeste opws prin. Epipleon, sto Linux mporeite na exete polles synedries: einai san na exete pollous ypologistes na leitoyrgoun taytoxronws!

Xrhsei aytwn twn entolwn mporeite na diamorfwsete ena disko, na sympiesete ena plh8os arxeiwn, na metaglwttisete ena programma kai na aposympiesete ena sympiesmeno arxeio taytoxronws, exontas akomh to prompt sth dia8esh sas! Dokimaste na to kanete ayto kai sta Windows kai deite thn diafora apodosews (ef' oson den kollhsoyn....).

4.6 Ektelesh Programmatwn se Apomakrysmenoys Ypologistes.

Gia na trejete ena programma se enan apomakrysmeno ypologisth onomati remote.machine.edu:

$ telnet remote.machine.edu

Afou kanete log in, jekinhste to agaphmeno sas programma. Ennoeite pws 8a prepei na exete logariasmo kelufoys (shell account) ston apomakrysmeno ypologisth.

An exete X11, mporeite na trejete kai efarmoges X apo apomakrysmenoys ypologistes, kanontas tis na fainontai sthn o8onh toy proswpikou sas ypologisth. Estw remote.machine.edu to apomakrysmeno susthma kai local.linux.box to Linuxokoyto sas. Gia na trejete apo to local.linux.box mia efarmogh X eyriskomenh sto remote.machine.edu, kante ta parakatw:

Et voila! To progname 8a jekinhsei ston remote.machine.edu kai 8a fainetai ston ypologisth sas. Kalutera na mhn to xrhsimopoihsete omws me sundesh mesw modem, giati 8a einai ejairetika argo kai ara oxi idiaitera xrhsimo.. Epipleon, einai mia ajesth kai anasfalhs me8odos: kalutera diabaste to «Remote X Apps mini-HOWTO» sth dieu8ynsh http://sunsite.unc.edu/LDP/HOWTO/mini/Remote-X-Apps.


Next Previous Contents