Upload
documentosseth
View
7
Download
0
Embed Size (px)
Citation preview
ElentornodeprogramacinUNIXdeBrianW.KernighanyRobPike.
ExtractodelPrefacio
ElsistemaoperativoUNIXseinicienunaDECPDP7desechada,enlosLaboratoriosBelldurante1969.KenThompson,conideasyelapoyodeRuddCanaday,DougMcIlroy,JoeOssannayDennisRitchie,escribiunsistemadetiempocompartidoydeusogenerallobastanteadecuadoycmodocomoparaatraerausuariosentusiastasyconsuficientecrdibilidadparajustificarlaadquisicindeunamquinamsgrande:unaPDP1120.UnodelosprimerosusuariosfueRitchie,quienayudoatrasladarelsistemaalaPDP11en1970.RitchietambindiseyescribiuncompiladorparaellenguajedeprogramacinC.En1973,RitchieyThompsonreescribieronelncleo(Kernel)deUNIXenC,rompiendoasconlatradicindequeelsoftwaredesistemasestescritoenlenguajeensamblador.Conesareescritura,elsistemaadquiriesencialmentelaformaenqueloconocemoshoy.
Hacia1974fuepresentadoenlasuniversidadesconfineseducacionalesyalcabodepocosaosestabayadisponibleparausocomercial.Enesetiempo,lossistemasUNIXprosperaronenlosLaboratoriosBellydeallsedifundieronalaboratorios,aproyectodedesarrollodesoftware,acentrosdeprocesamientosdepalabrasyasistemasdeapoyodeoperacionesenlascompaasdetelfonosdelosEstadosUnidos.Desdeentonces,sehanutilizadoentodoelmundoysehaninstaladoenmilesdesistemas,desdemicrohastamacrocomputadoras.
AquesedebetalxitodelsistemaoperativoUNIX?Podemosdistinguirvariasrazones.Primero,estescritoenCyesporttil.Segundo,elcdigofuenteestdisponibleyescritoenunlenguajedealtonivel,locullohacefcildeadaptaraexigenciasparticulares.Porltimo,yestoeslomsimportante,esunbuensistemaoperativo,especialmenteparalosprogramadores.Suambientedeprogramacinesdeextraordinariariquezayproductividad.
AuncuandoelsistemaoperativoUNIXpresentavariosprogramasymtodosinnovadores,sueficacianosedebeaunprogramaoideaenparticular,sinoasuenfoquedeprogramacin,unafilosofadecmoutilizarlacomputadora.Aunqueesafilosofanopuededescribirseenunasolafrase,sebasaenlaconviccindequelapotenciadeunsistemadependemsdelasrelacionesentrelosprogramasquedelosprogramaspropiamentedichos.MuchosprogramasdeUNIXhacenaisladamentetareastriviales,peroalcombinarseconotrosseconviertenenherramientasgeneralesytiles.
LaHistoriadeLinuxVersin2.2.0porRagibHasan
DepartamentodeCienciasdelaComputacinUniversidaddeIllinoisenUrbanaChampaign
Traduccin:HugoJimnezPrez
ElInicio.Era1991,yladespiadadaagonadelaguerrafraestaballegandogradualmenteasufn.Haba unaire de pazy tranquilidadqueprevalecaenel horizonte. Enel campode lacomputacinungranfuturoparecaqueibaacaer,talcomoelhardwarepoderosoempujabaloslmitesdelascomputadorasmsalldeloquecualquieraesperaba.
Perotodavafaltabaalgo.
Ynoeraotrocosaqueotrosistemaoperativo,dondeungranvacoparecihaberaparecido.
Por un lado, DOS tena todava el reinado supremo en ese vasto imperio de lascomputadoraspersonales.CompradoporBillGatesdeunhackerdeSeattlepor$50,000,eldesnudo sistema operativo haba anidado en cada rincn del mundo en virtud de unaestrategiacomercial adecuada.LosusuariosdePCsnotenanotraopcin.LasMacsdeAppleeranmejores,peroconpreciosastronmicosquenadiepodapagar,permanecieroncomounhorizontefueradelalcancedemillones.
ElotrocampodedicadoalacomputacineraelmundodeUNIX(UnixWorld).PeroUNIXenseramuchomscaro.Enlabsquedadegrandinero,losvendedoresdeUNIXtazaronsussistemaslosuficientementealtoscomoparaasegurarquelosusuariosdelospequeosPCssemantuvieranalmargen.ElcdigofuentedeUNIX,unavezllevadoalasuniversidadesporcortesa de los Laboratorios Bell, eran guardados cautelosamente y no publicados.Adicionalmente a la frustracin de los usuarios de PCsde todo el mundo, los grandesjugadoresenelmercadodesoftwarefallaronenproporcionarunasolucineficienteaesteproblema.
UnaposiblesolucinsepercibaenformadeMINIX.EstesistemafueescritocompletamenteporAndrewS.Tanenbaum,unprofesoralemnnacidoenlosEstadosUnidosquequeraensearasusalumnosltrabajointernodeunsistemaoperativoreal.EstefuediseadoparaejecutarseenlosmicroprocesadoresIntel8086quehabaninundadoelmercado.
Comounsistemaoperativo,MINIXnoeraespectacular,perotenalaventajadetenerelcdigo fuentedisponible. Cualquieraque tuvierael libro 'OperatingSystems:DesignandImplementation'deTanenbaumpodatenerlas12,000lneasdecdigo,escritasenCyenlenguajeensamblador.Porprimeravez,unaspiranteaprogramadorounhackerpodaleerelcdigofuentedelsistemaoperativo,queporesetiempo,losvendedoresdesoftwarehabanguardado escrupulosamente. Un brillante autor, Tanenbaum, cautivo a las mentes msbrillantes de lasciencias de la computacincon la elaboradae inmaculadamentevvidadiscusindelartedecrearunsistemaoperativofuncional.EstudiantesdelasCienciasdelaComputacinde todoel mundoestudiaronesmeradamenteel libro, leyendoa travsdelcdigopraentenderelsistemaqueseejecutabaensuscomputadoras.
YunodeelloseraLinusTorvalds.
UnnuevobebeenelhorizonteEn1991, Linus Benedict Torvalds era un estudiante de segundo ao deCiencias de laComputacinenlaUniversidaddeHelsinkiyunhackerautodidacta.Eljovenfinlandsde21aos,pelirojoydehablarsuaveadorabapensarenlapotenciadelascomputadorasyloslmitesa loscualesel sistema laspuede llevar. Perotodo loquefaltabaeraunsistemaoperativoquepodieraalcanzarlasdemandasdelosprofesionales.MINIXerabueno,perotodava era un sistema operativo para estudiantes, diseado como una herramienta deenseanzaenlugardeunapotenteherramientaindustrial.
Duranteesetiempo,losprogramadoresdetodoelmundoestabaninspiradosporelproyectoGNUdeRichardStallman,unmovimientodesoftwarequeproporcionabasoftwarelibreydecalidad.Aclamadocomounhroeenelreinodelcmputo,StallmaninicisuexitosacarreraenelfamosoLaboratoriodeInteligenciaArtificialdelMIT,ydurantemediadosafinalesdelossetentascre el editorEMACS.Aprincipiosde losochentas, lascompaasdesoftwarecomercialsellevaronamuchosdelosmsbrillantesprogramadoresdeloslaboratoriosdeInteligencia Artificial, y negociaronseveros y no reveladores acuerdospara proteger sussecretos.PeroStallmantenaunavisindiferente.Su ideaeraqueadiferenciadeotrosproductos, el software debera ser libre de las restricciones que iban en contra de losderechos de autor o de la modificacin con el fin de hacer mejores y ms eficientesprogramasdecomputadora.Consufamosomanifiestode1983quedeclarlosprincipiosdelproyecto GNU, inici un movimiento para crear y distribuir software que transmitiera sufilosofa(Incidentalmente,elnombredeGNUesunacrnimorecursivoqueenuncia'GNUisNotUNIX').Peropararealizarestesueodecrearfinalmenteunsistemaoperativolibreelnecesitabacrearprimerolasherramientas.Asqueiniciandoen1984,Stallmanempezaescribir el compilador GCC (GNU C Compiler), una asombrosa hazaa para un soloprogramador. Con su legendaria hechicera (wizardry: que proviene de un juego demazmorras y calabozos popular en los 80s) tcnica el solo clasific grupos enteros deprogramadoresdelosvendedoresdesoftwarecomercialencrearGCC,consideradocomounodelosmseficientesyrobustoscompiladoresjamscreado.
En1991,ElproyectoGNUhabacreadomuchsimasherramientas.ElesperadocompiladordeCdeGNUestabadisponibleporentonces,perotodavanotenaunsistemaoperativo.AunMINIXtena licencia.(Mstarde,enabril del2000,Tanenbaumliber MINIXbajo lalicencia BSD.) El trabajo se dirigi hacia el kernel deGNU, llamadoHURD,peronoseesperabaquefueraterminadosinopasadovariosaos.
EsoeramuchoretrasoparaLinus.
El25deagostode1991unhistricomensajefueenviadoalgrupodenoticiasdeMINIXporLinus.
From:[email protected](LinusBenedictTorvalds)Newsgroups:comp.os.minixSubject:Whatwouldyouliketoseemostinminix?Summary:smallpollformynewoperatingsystemMessageID:Date:25Aug9120:57:08GMTOrganization:UniversityofHelsinki
HelloeverybodyoutthereusingminixI'mdoinga(free)operatingsystem(justahobby,won'tbebigandprofessionallikegnu)for386(486)ATclones.Thishasbeenbrewingsinceapril,andisstartingtogetready.I'dlikeanyfeedbackonthingspeoplelike/dislikeinminix,asmyOSresemblesitsomewhat(samephysicallayoutofthefilesystem(duetopracticalreasons)amongotherthings).I'vecurrentlyportedbash(1.08)andgcc(1.40),andthingsseemtowork.ThisimpliesthatI'llgetsomethingpracticalwithinafewmonths,andI'dliketoknowwhatfeaturesmostpeoplewouldwant.Anysuggestionsarewelcome,butIwon'tpromiseI'llimplementthem:)Linus([email protected])PS.Yesit'sfreeofanyminixcode,andithasamultithreadedfs.ItisNOTprotable(uses386taskswitchingetc),anditprobablyneverwillsupportanythingotherthanATharddisks,asthat'sallIhave:(.
Comoesaparentedelmensaje,elmismoLinusnocreaquesucreacinfueraaserlosuficientementegrandecomoparacambiarelcmputoparasiempre.Laversin0.01deLinuxfueliberadaamediadosdeseptiembredelmismoaoyfuedistribuidaeninternet.Elentusiasmoseacumulalrededordeestenuevo'chicodelpueblo',yelcdigofuedescargado,probado,corregidoyreenviadoaLinus.Laversin0.02llegel5deoctubrejuntoconlafamosadeclaracindeLinus:
From:[email protected](LinusBenedictTorvalds)Newsgroups:comp.os.minixSubject:Freeminixlikekernelsourcesfor386ATMessageID:Date:5Oct9105:41:06GMTOrganization:UniversityofHelsinkiDoyoupineforthenicedaysofminix1.1,whenmenweremenandwrotetheirowndevicedrivers?AreyouwithoutaniceprojectandjustdyingtocutyourteethonaOSyoucantrytomodifyforyourneeds?Areyoufindingitfrustratingwheneverythingworksonminix?Nomoreallnighterstogetaniftyprogramworking?Thenthispostmightbejustforyou:)AsImentionedamonth(?)ago,I'mworkingonafreeversionofaminixlookalikeforAT386computers.Ithasfinallyreachedthestagewhereit'sevenusable(thoughmaynotbedependingonwhatyouwant),andIamwillingtoputoutthesourcesforwiderdistribution.Itisjustversion0.02(+1(verysmall)patchalready),butI'vesuccessfullyrunbash/gcc/gnumake/gnused/compressetcunderit.Sourcesforthispetprojectofminecanbefoundatnic.funet.fi(128.214.6.100)inthedirectory/pub/OS/Linux.ThedirectoryalsocontainssomeREADMEfileandacoupleofbinariestoworkunderlinux(bash,updateandgcc,whatmorecanyouaskfor:).Fullkernelsourceisprovided,asnominixcodehasbeenused.Librarysourcesareonlypartiallyfree,sothatcannotbedistributedcurrently.Thesystemisabletocompile"asis"andhasbeenknowntowork.Heh.Sourcestothebinaries(bashandgcc)canbefoundatthesameplacein/pub/gnu.
Laversin0.03deLinuxarribenpocassemanas.Paradiciembreyasetenalaversin0.10.Linuxtodavaeraunpocomsqueunesqueleto.TenasoportenicamenteparadiscosdurosdeAT,no tena login (cargabadirectamenteal BASH). Laversin0.11eramuchomejor, consoporteparatecladosmultilenguajes,controladoresdediskettes,soporteparaVGA,EGA,Hercules,etc.Losnmerosdeversinfuerondirectamentede0.12a0.95y0.96yassucesivamente.ProntoelcdigosedistribuyalmundoenteromediantelossitiosdeftpenFinlandiayotraspartes.
ConfrontacinyDesarrolloPronto,LinustuvounaonfrontacinconnadiemsqueAndrewTanenbaum,elgranprofesorqueescribieraMINIX.EnunmensajeaLinus,Tanenbaumcoment:
"Istillmaintainthepointthatdesigningamonolithickernelin1991isafundamentalerror.
Bethankfulyouarenotmystudent.Youwouldnotgetahighgradeforsuchadesign:)"(AndrewTanenbaumtoLinusTorvalds)
LinusadmitiposteriormentequeestoeralopeordesudesarrollodeLinux.Tanenbaumeraverdaderamenteelfamosoprofesor,ynadaqueeldijeraeracuestionable.PeroestabaequivocadoconrespectoaLinux,paraLinuseraunchicotercoquenoadmitaderrotas.
Tanenbaumtambinrecalcque:'Linuxeraobsoleto'.
AhoratocabaelturnoalanuevageneracindeLinux.RespaldadoporlafuertecomunidaddeLinux,LinusrespondiaTanenbaumloqueparecasermsconveniente:
Yourjobisbeingaprofessorandresearcher:That'sonehellofagoodexcuseforsomeofthebraindamagesofminix.(LinusTorvaldstoAndrewTanenbaum)
Yeltrabajocontinu.ProntomsdeuncientodepersonasseunialcampamentodeLinux.Despuseranmiles,ydespuserancientosdemiles.Estoyanoeraunjugueteparaloshackers.RespaldadoporunapltoradeprogramasprovenientesdelproyectoGNU,Linuxestaba listoparael espectculo.Se ledio la licenciadeGNUGeneralPublicLicense,yentoncesseasegurqueelcdigofuenteseralibreparatodomundoparacopiar,estudiarymodificar.Losestudiantesylosprogramadoresdecomputadorasloobtuvieron.
Pronto,losvendedorescomercialestambinseintegraron.Linuxenserayeslibre.Loquehicieronlosvendedoresfuecompilardiversospaquetesdesoftwareyloreunieronenformatodistribuible,enunaformamsadecuadaparecidaalosotrossistemasoperativosconlosquela gente estaba familiarizada. RedHat, Caldera y otras compaas obtuvieron buenasrespuestas en el mundo entero. Mientras que stas eran aventuras comerciales,programadoresdecomputadorasdedicadoscrearonsupropiadistribucinrespaldadaporvoluntarios,elafamadoDebian.Conlasnuevasinterfacesgrficasdeusuario(GUI,comoTWM, XWindow System, KDE, GNOME) las distribuciones e Linux se volvieron muypopulares.
Mientrastanto,algunascosasasombrosassucedieronconLinux.AdemsdelasPC,Linuxfuellevadoamuchasdiferentesplataformas.LinuxfuemodificadoparaejecutarseenlasPalm Pilot de 3Com. La tecnologa de clusters permiti que un gran nmero decomputadorassecombinaranenunasolaentidaddecmputo,unacomputadoraenparalelo.Enabrilde1996,investigadoresdelLaboratorioNacionaldeLosAlamosutilizLinuxparaejecutar68PCscomounasolacomputadoradeprocesoenparaleloparasimularondasdechoqueatmicas.Peroadiferenciadeotrassupercomputadorasquecostabanunafortuna,esta en su lugar era muy barata. La supercomputadora 'casera' cost slo $150,000,incluyendoeltrabajo(laconexindelas68PCsmediantecables),casiunadcimapartedeunacomputadoracomercialdelasmismascaractersticas.Alcanzunavelocidadpicode19billones de clculos por segundo, convirtindola en la 315ava supercomputadora mspoderosadelmundo. Yademserarobustatambin.Tresmesesmstardenosehabareiniciadounasolavez.
LomejordeLinuxhoyendaeslacantidaddeseguidoresqueliderea.Cadavezqueunapiezadehardwareaparece,elkerneldeLinuxesmodificadoparaaprovecharalmximodichapieza.Porejemplo,algunassemanasdespusdelapresentacindelmicroprocesadorIntelXenon,elkerneldeLinuxfuemodificadoyestabalistoparausarlo.TambinhasidoadaptadoparausarseenprocesadoresAlpha,Mac,PowerPCyaunenpalmtops,unaproeza
quedifcilmentepuedeserigualadaporcualquierotrosistemaoperativo.Ycontinuasuviajeenelnuevomilenio,conelmismoentusiasmoqueseiniciunbuendade1991.
MientrastantoLinussiguesiendounhombresencillo.AdiferenciadeBillGates,l noesmillonario. Termin susestudiosy semud a losEstadosUnidose inici un trabajoenTransmeta Corporation. Despus de liderar una investigacin secreta y de desarrollar elproyecto,TransmetalanzelprocesadorCrusoe.Linusfueunmiembroactivodelequipode investigacin. Recientemente despos a Tove, y es el orgulloso padre de unachica,PatriciaMirandaTorvalds.Peroelsiguesiendoelprogramadormsfamosoyfavoritodelmundoalafecha.Idolatradoporlacomunidadcomputacionaldelmundoentero,Linusespormuchoelmsgrandeprogramadorenesteplaneta.
Iniciodesesinyalgunoscomandosbsicoslogin:
Variablesdeambiente
$ls$cd$cat$more$less$zless$w
$touch$mkdir$od$ddDndeobtenerinformacin.Laspginasdelmanual,Info,apropos.
RedireccionamientodeEntradaSalidaLaverdaderafilosofadeUNIX>>
kill
jobs
fg
bg
pstree
lsof
nohup
at
nice
Generalidadesdelaconfiguracinyadministracinderedes.TCP/IPRedes,sistemaDNS,parmetrosdered,Mscarasdered,subredesytodoesoArchivos/etc/init.d/network/etc/network/interfaces/etc/resolv.conf/etc/hostsifconfigifupifdownroutenmap
Tipsbsicosdeseguridadenredesyenservidores.
Particionesymontaje.Primeraregladeseguridad.
/dev/hda1on/boottypeext3(ro,noexec,nosuid,nodev,noatime)/dev/hda3on/backuptypefuseblk(rw,noexec,nosuid,nodev,allow_other,blksize=4096)/dev/hda4on/wintypefuseblk(rw,noexec,nosuid,nodev,allow_other,blksize=4096)/dev/hda5on/typeext3(rw,errors=remountro)/dev/hda6on/roottypeext3(rw)/dev/hda7on/usrtypeext3(ro,nodev,noatime)/dev/hda9on/vartypeext3(rw,nosuid,nodev)/dev/hda11on/hometypeext3(rw,noexec,nosuid,nodev)/dev/hda10on/tmptypeext3(rw,noexec,nosuid,nodev,noatime)
cerrarpuertosycolocariptableseippl.
Cuidarelsistemadearchivos
Nombresrarostouch./foormfoo
Permisosdearchivos
SUID4xxxSGID2xxxadBit1xxxparadirectorios
Nuncasedebeejecutarunprogramapara'saberquehace',dehecho,unbuenadministradordebeverificartodosycadaunosdelosprogramasyarchivosquecomponenunapiezadesoftware.Poresoesimportantequeeladministradortambinseaunbuenprogramador.EstaesunadelasgrandesdiferenciasentreWindowsyUNIX.TambinsedebeobservarqueenUNIX,unopuedecompilartodosycadaunodelospaquetesqueexistenenGNU.ElsiguienteesunguindecomandosquepuederobarseunasesindeSHELLconpermisosSUID
#!/bin/bash#GuindecomandosdeBASHpararobarseunBASHconSUIDderoot#BIN=/home/yo/binmkdirp$BINcd$BINcp/bin/bash./bash#Ahoravieneeldaochownrootbashchmod4755bash
ParaencontrartodoslosarchivosSUIDySGID
#find/\(perm004000operm002000\)typefprint
Ahorahagamosunguinparadesplegarsealaspersonasqueleshemoscanceladolacuentadeusuario(peronosehaeliminado).Esteguinsecolocareneldirectorio/usr/bino/binconpermisosdeejecucinydespussemodificarlalneadelarchivodepasswordsparaqueseejecuteenlugardelintrpretedecomandos.
#!/bin/bash##/bin/cat
CoordinaciondeSCMA08
XXexit0
Ahoraserequierequeledenpermisosdeejecucin$chmod+xno_login$mvno_login/bin
yporultimomodificarlalneadelusuarioenelarchivodecontrase~nasconelcomando$vipwquecontengaelregistrodelusuarioymodificarlojuan:x:1001:1001:,,,:/home/juan:/bin/bashporjuan:x:1001:1001:,,,:/home/juan:/bin/no_login
Softwarelibre...
El entorno de programacin UNIX La Historia de LinuxEl Inicio.Un nuevo bebe en el horizonteConfrontacin y DesarrolloInicio de sesin y algunos comandos bsicosRedireccionamiento de Entrada SalidaSistemas operativos milti-usuario, servidores y estaciones de trabajo.Generalidades de la configuracin y administracin de redes.Tips bsicos de seguridad en redes y en servidores.