You are on page 1of 28

InstallingLinuxSoftware Introduction

You'llfrequentlyneedtoinstalladditionalsoftwareonyourLinuxserverthatyoudidn'tthinkyou'd needwhenyoufirstinstalledtheoperatingsystem.Thiscouldbebecauseofnewbusinessrequirements foradditionalpackagesortheneedtoinstallnewadministrativetoolstomakeyourjobeasier. WhenLinuxdeveloperscreatetheirsoftwaretheytypicallybundlealltheexecutableanddatafilesinto asinglefilethatisoftencalleda"package"file.Packagefileshavedifferentformatsandcontain differentcontrolfilesthatdeterminewheretherestofthefilesshouldbeplaced,thepermissionsthey shouldhaveandalistofprerequisitepackagesthatarerequiredforthepackagetofunctioncorrectly. Someofthisinformationmayalsobestoredinadatabaseonyoursystembythepackagemanagement softwareusedtoinstallthesoftwareandisusedtospeedupsomeoftheadministrativefunctionsofthe packagemanager. Redhat,CentosandFedoraLinuxsoftwareisprimarilyavailableinRedHatPackageManager(RPM) files.RegularRPMpackagefilesareusedforinstallationsinwhichthekernel,ormasterprogram, hasn'tbeencustomizedinanyway.Thisistheusualscenarioformostdepartmentalservers.Source RPMsareusedwhenthekernelhasbeencustomizedtoaddordropsupportselectivelyforvarious devicesorfeaturesforthesakeofperformanceorfunctionality.Theprocedureforinstallingsource RPMsinvolvesrecompilingsourcecodetofittheneedsofthesekernelcustomizations.Thismakeslife easierforthesoftwaredeveloperwhowrotethepackageasheorshenowhasonlytocreateasingle packagetosupportalltypesofcustomizations.Bothpackagetypesusestandardizedcommandsfor installingthesoftwarecontainedinsidemakingRPMsrelativelyeasytouse. DebianandUbuntuversionsofLinuxusetheDebianPackageformatinwhichthefilenamesallend with".deb".ItisforthisreasonthattheyarefrequentlycalledDEBfiles. SoftwaredeveloperswhowanttouseauniversallyrecognizablefileformatacrossallflavorsofLinux alsowillmaketheirproductsavailableasTARpackages.TARpackagesaregenerallymoredifficultto workwiththanRPMpackagesbecausethearchivedfileswithinthemmayormaynotneedtobe compiledandthecommandstoinstallthesoftwaremayvaryfrompackagetopackage.Instructionsare usuallycontainedwithinafileinsidetheTARpackagetohelpguidetheinstallation. ThePerlprogramminglanguageisoftenusedbyLinuxsoftwaredeveloperstocreatetheirprograms. Perlreliesonthepresenceofcertainlibraries,or"modules",toworkcorrectlyandmanyLinux distributionsinstallPerlwithonlythemostcommonlyusedones.Therewillbetimeswhenyouwillbe requiredtoinstalladditionalprerequisitePerlmodulespriortotheinstallationofyourpackages. KnowledgeofhowtoinstallPerlmodulesisavaluablecomponentofaLinuxsystemsadministrators' skillset. ThischapterfocusesontheRPMandDEBformats,whichareusedbyamajorityofinstalled distributions.TherearesmallersectionsonTARpackagesandPerlmodulesneartheendtocoverthese lessfrequentlyused,butimportantsoftwareinstallationtools.

WheretoGetCommonlyUsedPackages
Therearethreecommonlyusedsourcesforpackages;distributionCDs;packagesmanuallydownloaded viaabrowser,FileTransferProtocol(FTP)client,orthewgetutility;andautomateddownloads.Each ofthesemethodsisintroducedhere,butiscoveredingreaterdetailinsectionstofollow.

PackagesonYourInstallationCDs
InstallingfromyourdistributionCDsisusuallyeasierthanhavingtodownloadfilesfromaremote Website,buttheyareneveruptodateforverylong.Wediscussusingthismethodinmoredetaillater.

ManuallyDownloadedPackages
ThetwomostcommonwaysofgettingpackagesarebymanuallyusingFTPoraWebbrowser.Table6 1listssomecommondownloadsitesthatcanbeused.RemembertomatchtheRPMtothedistribution andversionofLinuxyoursystemisrunning.

Table61PopularPackageDownloadSites
Distribution http://www.redhat.com/ Redhat http://www.rpmfind.net/ ftp://download.fedora.redhat.com/pub/fedora/linux/core/ Fedora Debian Ubuntu http://download.fedora.redhat.com/pub/fedora/linux/core/http://www.rpmfind.net/ http://packages.debian.org http://packages.ubuntu.com Location

Note:WithFedorayoucanalsodownloadpackagesfromthedownload.fedora.redhat.comsite.Start yoursearchinthe/pub/fedora/linux/core/directoryandmovedownthedirectorytree.Ifyou'renewto FTP,don'tworry,it'sexplainedlater.

AutomatedPackageDownload
Thedisadvantageofmanualdownloadsisthatthepackagesoftenwon'tinstallunlesscertain prerequisitepackageshavebeeninstalledbeforehand.Thiscanleadtothedownloadandinstallationof severalpackageswhichcanbecometedious. AllthemajorLinuxdistributionshaveautomateddownloadandupdateutilities.Forexample,Fedora usesyumandUbuntuandDebianuseapt.Theseareallcoveredingreaterdetailinsectionstofollow.

HowtoDownloadSoftware
OneofthemostuniversallyperformedtasksbyLinuxsystemsadministratorsisthedownloadingof software.Itisusuallyverysimpletodoandthemostcommonlyusedmethodsarecoveredinthis section.

GettingSoftwareUsingWebBasedFTP
TherearenumerousWebsitesthatprovidelinkstosoftwareyoucandownload.Themethodologytoget thesoftwareisusuallythesameforall: BrowsethedesiredWebsiteuntilyoufindthelinktothesoftwarepackageyouneed. Clickonthelinkforthedesiredsoftwarepackage. Savethefiletoyourharddrive Somewebbrowsers,suchasFirefox,willautomaticallydownloadthefiletoyourdesktop,butwhereis thedesktop?InLinux,yourdesktopisusuallyasubdirectorynamedDesktoplocatedinyourhomeor ~directory.Hereweseethattherootuser'sdesktopalreadycontainsadownloadedRPMfile.
[root@bigboy tmp]# cd ~/Desktop/ [root@bigboy Desktop]# ls ElectricFence-2.2.2-20.2.i386.rpm [root@bigboy Desktop]# pwd /root/Desktop [root@bigboy Desktop]#

GettingRPMsUsingCommandLineAnonymousFTP
TheWebbasedmethodabovetransparentlyusesanonymousFileTransferProtocol(FTP).Anonymous FTPallowsyoutologinanddownloadfilesfromaFTPserverusingtheusernameanonymousorthe shorterusernameftpandapasswordthatmatchesyouremailaddress.Thiswayanyonecanaccessthe data.Let'sillustratethiswithanexampleofusinganonymousFTPtodownloadtheSSHpackagefrom download.fedora.redhat.com: 1)FirstweissuetheFTPcommandtargetingdownload.fedora.redhat.comatthecommandline.
[root@bigboy tmp]# ftp download.fedora.redhat.com Trying 66.187.232.35... Connected to download.fedora.redhat.com (66.187.232.35). 220 Fedora FTP server ready. All transfers are logged. Name (download.fedora.redhat.com:root): anonymous 331 Please specify the password. Password: 230 Login successful. Have fun. Using binary mode to transfer files. ftp> pwd 257 "/" ftp> ls 227 Entering Passive Mode (66,187,232,35,57,155) 150 Here comes the directory listing. drwxr-xr-x 3 ftp ftp 4096 Oct 29 15:59 pub 226 Directory send OK.

ftp>

2)Afterwe'veloggedin,wecanusethehelpcommandtoseewhatoptionswehaveatourdisposal.
ftp> help Commands may be abbreviated. ! $ account append ascii bell binary bye case ccc cd cdup chmod clear close cprotect ftp> cr delete debug dir disconnect form get glob hash help idle image lcd ls macdef mdelete Commands are: mdir mget mkdir mls mode modtime mput newer nmap nlist ntrans open passive private prompt protect proxy sendport put pwd quit quote recv reget rstatus rhelp rename reset restart rmdir runique safe send site size status struct system sunique tenex trace type user umask verbose ?

Thecommandsyou'llmostlikelyusearelistedinTable62:

Table62FTPCommands
Command binary cd dir exit get lcd ls mget mput passive put Description Copyfilesinbinarymode ChangedirectoryontheFTPserver Listthenamesofthefilesinthecurrentremotedirectory Byebye GetafilefromtheFTPserver Changethedirectoryonthelocalmachine Sameasdir Sameasget,butyoucanusewildcardslike"*" Sameasput,butyoucanusewildcardslike"*" Makethefiletransferpassivemode PutafilefromthelocalmachineontotheFTPserver

pwd

Givethedirectorynameonthelocalmachine

3)ByusingtheWebbrowsingfeatureontheWebsiteaheadoftime,IknowthattheFedoraCore2 RPMsarelocatedinthepub/fedora/linux/core/2/i386/os/Fedora/RPMS/directoryandwillusethecd commandtochangemydirectorytothere.Wecanusethelscommandtogetalistingoffilesinthis directory.


ftp> cd pub/fedora/linux/core/2/i386/os/Fedora/RPMS/ 250 Directory successfully changed. ftp> ls open* 227 Entering Passive Mode (66,187,232,35,58,3) 150 Here comes the directory listing. ... ... -rw-r--r-... ... 184281 Oct 28 23:29 openssh-3.6.1p2-34.i386.rpm ... ... 226 Directory send OK. ftp>

4)Nextwegetthefileweneedandplaceitinthelocaldirectory/usr/rpm.Thehashcommandwill print"#"hashsignsonthescreenduringthedownload.
ftp> hash Hash mark printing on (1024 bytes/hash mark). ftp> lcd /usr/rpm Local directory now /usr/rpm ftp> get openssh-3.6.1p2-34.i386.rpm local: openssh-3.6.1p2-34.i386.rpm remote: openssh-3.6.1p2-34.i386.rpm 227 Entering Passive Mode (66,187,232,35,58,25) 150 Opening BINARY mode data connection for openssh-3.6.1p2-34.i386.rpm (184281 bytes). ################################################################################# ################################################################################## ################ 226 File send OK. 184281 bytes received in 3.41 secs (53 Kbytes/sec) ftp>

Note:YoucanalsousewildcardstodownloadtheRPMsyouneedusingthemgetcommand.You'llbe promptedforeachofthematchingRPMfiles.Inthenextexample,wejustabortedthisdownloadby typingn.


ftp> mget openssh-3.6* mget openssh-3.6.1p2-34.i386.rpm? n ftp>

5)FinallyweusetheexitcommandtoleaveFTP.
ftp> exit 221 Goodbye. root@bigboy tmp]#

GettingSoftwareUsingwget
ThewgetcommandcanbeusedtodownloadfilesquicklywhenyoualreadyknowtheURLatwhich theRPMislocated.ThisisespeciallyconvenientifyouareloggedintoyourLinuxboxfromanother machinerunningaWebbrowser.YoucanbrowsethedownloadsitefortheRPMyouneed,rightclick onthedesiredlinkandselectcopyshortcut(Windows)orCopyLinkLocation(Linux).Afteryouhave donethis,youcanthenselectyourSSH/telnet/LinuxTerminalloginwindowandtypeinthecommand wgetURL.HereisanexampledownloadingaDHCPupdatefromFedora.
[root@bigboy tmp]# wget http://linux.stanford.edu/pub/mirrors/fedora/linux/core/2/i386/os/Fedora/RPMS/dhcp -3.0pl2-6.16.i386.rpm --17:38:36-ftp://linux.stanford.edu/pub/mirrors/fedora/linux/core/2/i386/os/Fedora/RPMS/dhcp3.0pl2-6.16.i386.rpm => `dhcp-3.0pl2-6.16.i386.rpm.5' Resolving linux.stanford.edu... done. Connecting to linux.stanford.edu[171.66.2.18]:21... connected. Logging in as anonymous ... Logged in! ==> SYST ... done. ==> PWD ... done. ==> TYPE I ... done. ==> CWD /pub/mirrors/fedora/linux/core/2/i386/os/Fedora/RPMS ... done. ==> PASV ... done. ==> RETR dhcp-3.0pl2-6.16.i386.rpm ... done. Length: 529,890 (unauthoritative) 100%[===============================>] 529,890 889.12K/s ETA 00:00

17:38:36 (889.12 KB/s) - `dhcp-3.0pl2-6.16.i386.rpm.5' saved [529890] [root@bigboy tmp]#

InstallingSoftwareFromRPMFiles
TheFedora,RedhatandCentosversionsofLinuxrelyheavilyupontheuseofsoftwarepackagesinthe RPMformat.Thissectioncoverssomeofthemostimportanttopicsrequiredforyoutomastertheir use.

HowToInstallRPMsManually
TherearegenerallytwowaystoinstallRPMfilesmanually.Thefirstmethodisbyusingafile previouslydownloadedtoyourharddrive,andtheotheristoinstalltheRPMfromsomesortof removablemediasuchasaCDROMdrive.

UsingDownloadedFiles
DownloadtheRPMs(whichusuallyhaveafileextensionendingwith.rpm)intoatemporarydirectory, suchas/tmp.ThenextstepistoissuetherpmUvhcommandtoinstallthepackage.

TheUqualifierisusedforupdatinganRPMtothelatestversion,thehqualifiergivesalistofhash# charactersduringtheinstallationandthevqualifierprintsverbosestatusmessageswhilethecommand isrun.HereisanexampleofatypicalRPMinstallationcommandtoinstalltheMySQLserverpackage:


[root@bigboy tmp]# rpm -Uvh mysql-server-3.23.58-9.i386.rpm Preparing... ####################### [100%] 1:mysql-server ####################### [100%] [root@bigboy tmp]#

UsingCDROMs
TheunderlyingstepstoinstallRPMsfromCDsaresimilartothoseusedwheninstallingfromyour harddisk.ThemaindifferenceisthatyouhavetoaccessyourCDROMdrivebymountingitfirstto themnt/cdromdirectory.YourRPMswillthenbelocatedintheCDROM'sFedora/RPMssubdirectory. Theprocedureisasfollows: 1)InserttheCDROM,checkthefilesinthe/mnt/cdrom/Fedora/RPMSdirectoryandtheninstallthe RPM.
[root@bigboy tmp]# mount /mnt/cdrom [root@bigboy tmp]# cd /mnt/cdrom/Fedora/RPMS [root@bigboy RPMS]# ls filename* filename.rpm [root@bigboy RPMS]# rpm -Uvh filename.rpm Preparing... ####################### [100%] 1: filename ####################### [100%] [root@bigboy RPMS]#

2)Whenfinished,ejecttheCDROM
[root@bigboy RPMS]# cd /tmp [root@bigboy tmp]# eject cdrom [root@bigboy tmp]#

Note:Youcanusetherpmcommand'saidswitchtomakeitsearchtheCDROMforanyotherRPM dependenciesandinstallthemautomatically.

HowtoInstallSourceRPMs
Sometimesthepackagesyouwanttoinstallneedtobecompiledinordertomatchyourkernelversion. ThisrequiresyoutousesourceRPMfiles: DownloadthesourceRPMsorlocatethemonyourCDcollection.Theyusuallyhaveafile extensionendingwith(.src.rpm) Runthefollowingcommandsasroot: CompilingandinstallingsourceRPMswithFedoracanbedonesimplywiththerpmbuildcommand
[root@bigboy tmp]# rpmbuild --rebuild filename.src.rpm

Hereisanexampleinwhichweinstallthetacacspluspackage.
[root@bigboy rpm]# rpmbuild --rebuild tac_plus-4.0.3-2.src.rpm Installing tac_plus-4.0.3-2.src.rpm Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.61594 + umask 022 + cd /usr/src/redhat/BUILD + cd /usr/src/redhat/BUILD + rm -rf tac_plus-4.0.3 + /usr/bin/gzip -dc /usr/src/redhat/SOURCES/tac_plus-4.0.3.tgz + tar -xvvf ... ... ... + umask 022 + cd /usr/src/redhat/BUILD + rm -rf tac_plus-4.0.3 + exit 0 [root@bigboy rpm]#

ThecompiledRPMfilecannowbefoundinoneofthearchitecturesubdirectoriesunder /usr/src/redhat/RPMSdirectory.Forexample,ifyoucompiledani386architectureversionoftheRPM itwillplacedinthei386subdirectory. YouwillthenhavetoinstallthecompiledRPMsfoundintheirrespectivesubdirectoriesasyou normallywould.

RPMInstallationErrors
SometimestheinstallationofRPMsoftwaredoesn'tgoaccordingtoplanandyouneedtotake correctiveactions.Thissectionshowsyouhowtorecoverfromsomeofthemostcommonerrorsyou'll encounter.

FailedDependencies
SometimesRPMinstallationswillfailgivingFaileddependencieserrorswhichreallymeanthata prerequisiteRPMneedstobeinstalled.Inthenextexamplewe'reattemptingtoinstalltheMySQL databaseserverapplication,whichfailsbecausethemysqlMySQLclientRPM,onwhichitdepends, needstobeinstalledbeforehand:
[root@bigboy tmp]# rpm -Uvh mysql-server-3.23.58-9.i386.rpm error: Failed dependencies: libmysqlclient.so.10 is needed by mysql-server-3.23.58-9 mysql = 3.23.58 is needed by mysql-server-3.23.58-9 [root@bigboy tmp]#

InstallingtheMySQLclientalsofailsbecauseitrequirestheperlDBDMySQLpackage.
[root@bigboy tmp]# rpm -Uvh mysql-3.23.58-9.i386.rpm error: Failed dependencies: perl-DBD-MySQL is needed by mysql-3.23.58-9

[root@bigboy tmp]# rpm -Uvh perl-DBD-MySQL-2.9003-4.i386.rpm error: Failed dependencies: libmysqlclient.so.10 is needed by perl-DBD-MySQL-2.9003-4 [root@bigboy tmp]#

Strangelyenough,theinstallationoftheperlDBDMySQLpackagefailsbecauseitneedsthemysql clientpackage.Togetaroundthisproblemyoucanruntherpmcommandwiththenodepsoptionto disabledependencychecks.InthenextexampleweinstalltheMySQLclientignoringdependencies, followedbysuccessfulinstallationofperlDBDMySQLandmysqlserver.


[root@bigboy tmp]# rpm -Uvh --nodeps mysql-3.23.58-9.i386.rpm Preparing... ####################### [100%] 1:mysql ####################### [100%] [root@bigboy tmp]# rpm -Uvh perl-DBD-MySQL-2.9003-4.i386.rpm Preparing... ####################### [100%] 1:perl-DBD-MySQL ####################### [100%] [root@bigboy tmp]# rpm -Uvh mysql-server-3.23.58-9.i386.rpm Preparing... ####################### [100%] 1:mysql-server ####################### [100%] [root@bigboy tmp]#

Note:IfalltheinstallationRPMsarelocatedinthesamedirectory,therpmcommandcan automaticallyinstallalltheprerequisiteRPMsusingtheaidoption.Oneoftheadvantagesofusing theyumfacilityisthatyoudon'thavetoworryaboutthisdependencyprocessasmuchbecausethe dependencyRPMsarealwaysdownloadedandinstalledautomaticallyalso.

SignatureKeys
FedoradigitallysignsallitsRPMfiles,soit'sbesttoimporttheirpublicencryptionkeybeforehandso thattheRPMinstallationprogramwillbeabletoverifythevalidityoftheRPMfile. ThisisusuallydoneautomaticallyinnewerversionsofFedora,butwillneedtobedonemanuallyin legacyversions.Themanualmethodusestherpmcommandasseeninthenextexample,butlocatethe keyfilesfirstastheirlocationscanvarybetweenFedoradistributions.Itisagoodideatoimportboth theRedHatandFedorakeys:
[root@bigboy tmp]# locate RPM-GPG-KEY /usr/share/rhn/RPM-GPG-KEY /usr/share/rhn/RPM-GPG-KEY-fedora [root@bigboy tmp]# rpm --import /usr/share/rhn/RPM-GPG-KEY [root@bigboy tmp]# rpm --import /usr/share/rhn/RPM-GPG-KEY-fedora [root@bigboy tmp]#

Ifyoudon'tinstallthekeysyou'llgetaDSAsignaturewarningthatalertsyoutothefactthattheRPM filemightbebogus:
[root@bigboy tmp]# rpm -Uvh dhcp-3.0pl2-6.16.i386.rpm warning: dhcp-3.0pl2-6.16.i386.rpm: V3 DSA signature: NOKEY, key ID 4f2a6fd2 Preparing... #################################### [100%] 1:dhcp #################################### [100%] [root@bigboy tmp]#

Itisalwaysgoodtoinstallthekeyfiles.Iftheyarenotthere,theRPMswillinstallwithonlyawarning message.IftheRPM'sdigitalsignaturedoesn'tmatchthatinthekeyfile,therpminstallationprogram alsoalertsyouandfailstoinstalltheRPMpackageatall:


[root@bigboy tmp]# rpm -Uvh dhcp-3.0pl2-6.16.i386.rpm error: dhcp-3.0pl2-6.16.i386.rpm: V3 DSA signature: BAD, key ID 4f2a6fd2 error: dhcp-3.0pl2-6.16.i386.rpm cannot be installed [root@bigboy tmp]#

Signaturesarethereforeusefulbecausetheyhelpprotectyouagainsttamperedandotherwisecorrupted RPMsbeinginstalled.

HowtoListInstalledRPMs
Therpmqacommandwilllistallthepackagesinstalledonyoursystem
[root@bigboy tmp]# rpm -qa perl-Storable-1.0.14-15 smpeg-gtv-0.4.4-9 e2fsprogs-1.27-9 libstdc++-3.2-7 audiofile-0.2.3-3 ... ... ... [root@bigboy tmp]#

Youcanalsopipetheoutputofthiscommandthroughthegrepcommandifyouareinterestedinonlya specificpackage.Inthisexamplewearelookingforallpackagescontainingthestringsshinthename, regardlessofcase(imeansignorecase)


[root@bigboy tmp]# rpm -qa | grep -i ssh openssh-server-3.4p1-2 openssh-clients-3.4p1-2 openssh-askpass-gnome-3.4p1-2 openssh-3.4p1-2 openssh-askpass-3.4p1-2 [root@bigboy tmp]#

Note:Youcouldusetherpmqpackagenamecommandtofindaninstalledpackagebecauseitis muchfasterthanusinggrepandtheqaswitch,butyouhavetohaveanexactpackagematch.Ifyouare notsureofthepackagenameanditscapitalization,thelattermethodisprobablymoresuitable.

ListingFilesAssociatedwithRPMs
Sometimesyou'llfindyourselfinstallingsoftwarethatterminateswithanerrorrequestingthepresence ofaparticularfile.Inmanycasestheinstallationprogramdoesn'tstatetheRPMpackageinwhichthe filecanbefound.Itisthereforeimportanttobeabletodeterminetheoriginofcertainfiles,bylisting thecontentsforRPMsinwhichyoususpectthefilesmightreside.

ListingFilesforAlreadyInstalledRPMs
Thiscanbeusefulifyouhavetoduplicateaworkingserverthatisalreadyinaproductionenvironment. Sometimestheinstallationofanapplicationfailsonthenewserverduetothelackofafilethatresides ontheoldone.InthiscaseyouneedtoknowwhichRPMontheoldservercontainsthefile. YoucanusetheqlqualifiertolistallthefilesassociatedwithaninstalledRPM.Inthisexamplewe testtomakesurethattheNTPpackageisinstalledusingtheqqualifier,andthenweusetheql qualifiertogetthefilelisting.
[root@bigboy tmp]# rpm -q ntp ntp-4.1.2-0.rc1.2 [root@bigboy tmp]# rpm -ql ntp /etc/ntp /etc/ntp.conf /etc/ntp/drift /etc/ntp/keys ... ... ... /usr/share/doc/ntp-4.1.2/rdebug.htm /usr/share/doc/ntp-4.1.2/refclock.htm /usr/share/doc/ntp-4.1.2/release.htm /usr/share/doc/ntp-4.1.2/tickadj.htm [root@bigboy tmp]#

ListingFilesinRPMFiles
SometimesyoumakeaguessanddownloadwhatyouthinkistheRPMwiththemissingfile.Youcan usetheqplqualifiertolistallthefilesinanRPMarchivetomakesurebeforeinstallingit:
[root@bigboy updates]# rpm -qpl dhcp-3.0pl1-23.i386.rpm /etc/rc.d/init.d/dhcpd /etc/rc.d/init.d/dhcrelay /etc/sysconfig/dhcpd /etc/sysconfig/dhcrelay ... ... ... /usr/share/man/man8/dhcrelay.8.gz /var/lib/dhcp /var/lib/dhcp/dhcpd.leases [root@bigboy updates]#

ListingtheRPMtoWhichaFileBelongs
YoumightneedtoknowtheRPMthatwasusedtoinstallaparticularfile.Thisisusefulwhenyouhave asuspicionaboutthefunctionofafilebutarenotentirelysure.Forexample,theMySQLRPMuses the/etc/my.cnffileasitsconfigurationfile,notafilenamed/etc/mysql.confasyou'dnormallyexpect. Thefollowingexampleconfirmstheoriginofthe/etc/my.cnffile.

[root@zippy tmp]# rpm -qf /etc/my.cnf mysql-3.23.58-9 [root@zippy tmp]#

UninstallingRPMs
Therpmecommandwilleraseaninstalledpackage.Thepackagenamegivenmustmatchthatlistedin therpmqacommandbecausetheversionofthepackageisimportant.
[root@bigboy tmp]# rpm -e package-name

WhichRPMsWillStartUpAtBootTime?
ThebestwaytoviewandconfigurewhichRPMswillstartatboottimeisbyusingthechkconfig commandwiththelistswitch.AmoredetailedexplanationwillbeprovidedinChapter7,"TheLinux BootProcess",whichcoverstheLinuxbootprocess.

AutomaticUpdateswithyum
TheyumautomaticRPMupdateprogramcomesasastandardfeatureofFedoraCore.Ithasanumber ofvaluablefeatures: YoucanconfiguretheURLsofdownloadsitescontainingtheRPMrepositoriesyouneed.This providestheaddedadvantageofyouchoosingthemostreliablesitesinyourpartoftheglobe. yummakesmultipleattemptstodownloadRPMsbeforefailing. yumautomaticallyfiguresoutnotonlytheRPMspackagesthatneedupdating,butalsoallthe supportingRPMs.Ittheninstallsthemall. Note:Updatingpackagescouldcauseprogramswrittenbyyoutostopfunctioningespeciallyifthey relyontheolderversion'sfeaturesorsyntax.

Configuringyum
TheconfigurationparametersthataffectallpackagesandallyumserverURLsarestoredinthe[main] sectionofthe/etc/yum.conffile.Yougenerallydon'tneedtoeditthisfile,butitcanbeusefulinlisting packagesthatyoudon'twantyumtoupdate.
# # File: /etc/yum.conf # [main] exclude=kernel perl

Inthisexamplethekernelandperlpackagesareexcluded.

Configuring/etc/yum.repos.dRepositoryFiles
The/etc/yum.repos.ddirectoryhasfilesdefiningwhereyumshouldlookontheInternettofindthe latestLinuxupdates.Formostcommontasksyouwontneedtomodifythesefilesatall.Ifyouwantto knowhowthesefilesaffectyoursystem,thencontinuereading!TheconfigurationsforeachRPM repositoryarelocatedinindividualconfigurationfileswiththe.repofileextension.Thisdirectorywill bepopulatedwithfilesforyourLinuxdistribution'smostimportantrepositories.Youcanalsoaddyour owncustomfilesforrepositoriescontainingnonstandardRPMpackages.Thesefileswillhavethe followingformat:
[repositoryid] name=Some name for this repository baseurl=url://path/to/repository/

The[repositoryid]isanidentifierthatisuniquetoallfilesinthedirectoryandcanonlybeoneword longandisoftengivenanamethatreflectsthefunctionoftherepository.Forexample,youmayhavea fedoraupdates.repofilethatcontainsa[updates],and[updatessource]sectionsthatrefertoURLsfor updatesofregularRPMsandsourceRPMs.Youcancreateyourownrepositoryfilesusingpopular repositorysites.TheeasiestwaytodeterminetheexactURLstouseasthebaseurlparameteristogoto thehttp://fedora.redhat.com/download/mirrors.htmlWebsitetogetalistingofalternativedownload sites.BrowsethelistedsitestofindthecorrectlocationsoftheRPMfilesinthe/updatesor/fedora versionURLbranches.MakesurethatbaseurlpointstoaURLwitha/repodatasubdirectorybeneath itasthissubdirectorycontainsfileswithinstructionsforyumtouseindoingitsupdates.Becareful, thissubdirectorycanbelocatedwithintheRPMdirectoryoronelevelabovethem.Alsorememberto makethe[repositoryid]inyour.repofileuniquetoallotherfiles. Note:yumacceptstheuseofvariablesintheconfigurationfile.The$releasevervariablereferstothe currentversionofFedoraCorerunningonyourserverandthe$basearchvariablemapstothebase architectureofyourserverwhichisdeterminedautomatically.Hereisanexampleoftheuseofthese variables.
[repository-name] name=Fedora Core $releasever - $basearch - Base baseurl=http://url.com/fedora/core/$releasever/$basearch/os/

Note:ItisprobablybesttoselectyumupdatesitesthatuseHTTPinsteadofFTP.Thereareanumber ofreasonsforthis.FTPfirewallrulesaremoredifficulttoimplementthanHTTP,outboundHTTP accesstotheInternetisoftenalreadyallowedinoffices,andwebserversarelesslikelytohave connectionlimitsimposedonthem,unlikeFTPservers,whichoftenhavelimitsonthenumberofuser logins.Note:YoucanlistmultipleURLsinabaseurlstatementlikethisandyumwilltrythemall.If youusemultiplebaseurlstatementsineachsectionthenyummayactstrangely,frequentlyonly selectingthelastoneinthelist.


baseurl=url://server1/path/to/files/ url://server2/path/to/files/ url://server3/path/to/files/

Note:Youcanalsoplaceallyour[repositoryid]sectionsintheyum.conffile.Thiswasthe

methodologyusedinsomeolderversionsofyum. Note:TheyumutilitycanbeconfiguredtomatchthedownloadedRPMsagainstchecksumfilestohelp protectagainstfilecorruptionandmaliciousforgeries.Thisissetusingthegpgcheckvariableinthe .repofiles.Checksaredonewhenthevalueissetto1,whensetto0,theyaredisabled.Hereisan example:


# # File: example.repo # gpgcheck=1 gpgkey=http://URL/example.key

RepositorieswillsometimesprovideyouwiththeURLfortheirchecksumfilesanditisagoodideato takeadvantageofthem.Thisisavaluablefeature.

HowtoAutomateyum
Olderversionsofyumcouldbeconfiguredtoruninthebackgroundasadaemonthatwassimple namedyumthatusedaunifiedyum.conffileforallitsconfigurationdata.Newerversionsusetheyum updatesddaemoninstead.Thisusesthe/etc/yum/yumupdatesd.confconfigurationfilewhichgoverns updatefrequency,thetypesoffilestobedownloadedandwhethertheyshouldbeautomatically installedusingtheyumcommand. Togetyumstarted,selectthecommandsthatmatchyourOSversion: 1.IfusinganewerversionofFedora/Redhat,makesuretheyumupdatesdpackageisinstalled.
[root@bigboy tmp]# yum y install yum-updatesd

2.Usethechkconfigcommandtogetyumconfiguredtostartatboot:
[root@bigboy tmp]# chkconfig yum-updatesd on [root@bigboy tmp]# chkconfig yum on

3.Usetheservicecommandtoinstructthe/etc/init.dyumscripttostart/stopyumafterbooting
[root@bigboy tmp]# service yum-updatesd start [root@bigboy tmp]# service yum-updatesd stop [root@bigboy tmp]# service yum start [root@bigboy tmp]# service yum stop

Note:Updatingpackagescouldcauseprogramswrittenbyyoutostopfunctioningespeciallyifthey relyontheolderversion'sfeaturesorsyntax.Theyumdaemonwilldoupdatesautomatically;theyum updatesddaemonwon'tdothisunlesstheyumupdatesd.conffilehasbeenupdatedasshownhere:


# # File: /etc/yum/yum-updatesd.conf # [main] do_update = yes

CreatingYourOwnyumServer
Anobviousadvantageofusingyumisthatyoucanuseittoupdateayumserveratyourofficewiththe samedirectorystructureofthemirrordownloadsitesontheFedoraWebsite.Thefullsetofstepstodo thisisbeyondthescopeofthisbook,buttherearesomefactorsyoushouldconsiderbeforedoingthis. AsmalldesktopPCwithaboutfivetosixgigabytesoffreediskspaceperdistributionshouldbe sufficienttostartwithforadedicatedsmallbusinessyumserver.LargeRPMsareabouttwentyfive megabytesinsize,andtheyareupdatedinfrequently,soyournetworkloadshouldbeminimalon averagewithanupdateonceortwiceaweekperserver.Inlargeserverfarmsyoumaywanttousea morerobustsystemthatcanhandlemanymoreclients,butbeforedoingso,gettrenddataforits networkloadtohelpyourfinaldecision.TheconfigurationoftheMRTGgraphingtooliscoveredin Chapter22,"MonitoringServerPerformance". Whenestablished,youcanthenconfigureallyourFedoraserverstousethislocalyumserverforall updateswhichwillsignificantlyreduceyourInternetcongestionandtheassociatedbandwidthcosts. yumclientscanaccesstheyumserverusingeitherFTPorHTTPrequests.Ifyouneedhelpinsetting theseup,Chapter15,"LinuxFTPServerSetup",discussesLinuxFTPserversandChapter20,"The ApacheWebServer",coverstheApacheWebserverforHTTPrequests. Note:WhensettingupanHTTPbasedyumserver,you'llneedtoenabletheviewingofdirectory structuressothatitwillbeeasyforsomeonetousehisorherWebbrowsertonavigatedownthe directoriestodoublecheckthelocationoftheyumfiles.

HowtoAutomateyum
AsofFedoraCore6theyumdaemonhasbeennamedyum-updatesd,whereasinthepastitwas justcalledyum.Togetyumstarted,selectthecommandsthatmatchyourOSversion: 1)Usethechkconfigcommandtogetyumconfiguredtostartatboot:
[root@bigboy tmp]# chkconfig yum-updatesd on [root@bigboy tmp]# chkconfig yum on

2)Usetheservicecommandtoinstructthe/etc/init.d yumscripttostart/stopyumafterbooting
[root@bigboy tmp]# service yum-updatesd start [root@bigboy tmp]# service yum-updatesd stop [root@bigboy tmp]# service yum start [root@bigboy tmp]# service yum stop

KeepingYourSystemcurrentwithYum
YoucanmaketheinstalledRPMpackagesonyoursystemuptodatewiththelatestpatchesusingthe yumupdatecommand.Whenusedwithoutlistinganypackagesafterwards,yumwillattempttoupdate themall.TheyumupdatepackagenamecommandupdatesonlyaparticularRPMpackage.

ItisalwaysadvisabletouseyumafterinstallingLinuxtomakesurethelatestversionsofsoftwareare installedforthesakeofimprovedsecurityandfunctionality.Hereisanexampleofoutputofwhatto expectwithyumupdatingyoursystem.


[root@bigboy tmp]# yum update Gathering header information file(s) from server(s) Server: Fedora Core 2 - i386 - Base Server: Fedora Core 2 - i386 - Released Updates Finding updated packages Downloading needed headers Resolving dependencies Dependencies resolved I will do the following: [install: kernel 2.4.22-1.2166.nptl.i686] [update: samba-client 3.0.2-7.FC1.i386] [update: binutils 2.14.90.0.6-4.i386] ... ... ... Is this ok [y/N]: y Getting samba-client-3.0.2-7.FC1.i386.rpm samba-client-3.0.2-7.FC1. 100% |=========================| 128 kB 05:01 ... ... ... Running test transaction: Test transaction complete, Success! glibc-common 100 % done 1/127 glibc 100 % done 2/127 Stopping sshd:[ OK ] Starting sshd:[ OK ] bash 100 % done 3/127 mozilla-nspr 100 % done 4/127 sed 100 % done 5/127 ... ... ... Completing update for pango - 65/127 Completing update for samba-client - 66/127 Completing update for binutils - 67/127 ... ... ... Completing update for XFree86-font-utils - 127/127 Kernel Updated/Installed, checking for bootloader Grub found - making this kernel the default Installed: kernel 2.4.22-1.2166.nptl.i686 Updated: pango 1.2.5-4.i386 samba-client 3.0.2-7.FC1.i386 binutils 2.14.90.0.64.i386 XFree86-Mesa-libGLU 4.3.0-55.i386 initscripts [root@bigboy tmp]#

Note:Ifyoudon'twanttobepromptedtoinstallthefilesusetheyumwiththeyswitch.

ExampleofayumPackageInstallation
Hereisasampleinstallationofanindividualpackageusingyum.InthiscasetheRPMinstalledisthe netsnmputilspackage:
[root@bigboy tmp]# yum -y install net-snmp-utils Repository updates-released already added, not adding again Repository base already added, not adding again Setting up Install Process Setting up Repo: base repomd.xml 100% |=========================| 1.1 kB 00:00 Setting up Repo: updates-released repomd.xml 100% |=========================| 951 B 00:00 Reading repository metadata in from local files base : ############################################ 2622/2622 primary.xml.gz 100% |=========================| 88 kB 00:00 MD Read : ################################################## 229/229 updates-re: ################################################## 229/229 Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Package net-snmp-utils.i386 0:5.1.2-11 set to be installed --> Running transaction check Dependencies Resolved Transaction Listing: Install: net-snmp-utils.i386 0:5.1.2-11 Downloading Packages: net-snmp-utils-5.1.2-11.i 100% |===================| 6.2 MB Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: net-snmp-utils 100 % done 1/1 Installed: net-snmp-utils.i386 0:5.1.2-11 Complete! [root@bigboy tmp]#

00:48

RememberTheFollowingYumFacts
yumdoesitsupdatesusingTCPport80forhttp://updateURLsandusespassiveFTPforftp:// updateURLsin/etc/yum.conf.Thiswillhaveimportanceforyourfirewallrules. Moredetailsonconfiguringyumcanbeobtainedbyrunningthemanyum.confcommand. yumrunsautomaticallyeachday.Thecronfileislocatedin/etc/cron.daily/. Don'tlimityourselftothedefaultyum.confURLsbecausetheycanbecomeoverloadedwith requestsandmakeyumperformpoorly.

InstallingSoftwareFromDEBFiles
UnliketheRedhat,FedoraandCentosversionsofLinuxthatuseRPMpackages,theDebianand UbuntuversionsofLinuxrelyonpackagesintheDEBformat.Thissectioncoverssomeofthemost importanttopicsrequiredforyoutomastertheiruse.

HowToInstallDEBsManually
TherearegenerallytwowaystoinstallDEBfilesmanually.Thefirstmethodisbyusingafile previouslydownloadedtoyourharddrive,andtheotheristoinstalltheDEBfromsomesortof removablemediasuchasaCDROMdrive.

UsingDownloadedFiles
DownloadtheDEBs(whichusuallyhaveafileextensionendingwith.deb)intoatemporarydirectory, suchas/tmp.Thenextstepistoissuethedpkginstallcommandtoinstallthepackage.Hereisan exampleofatypicalDEBinstallationcommandtoinstallthendiswrapperutilitiespackage:
root@u-bigboy:~# dpkg --install ndiswrapper-utils_1.8-0ubuntu2_i386.deb Selecting previously deselected package ndiswrapper-utils. (Reading database ... 70221 files and directories currently installed.) Unpacking ndiswrapper-utils (from ndiswrapper-utils_1.8-0ubuntu2_i386.deb) ... Setting up ndiswrapper-utils (1.8-0ubuntu2) ... root@u-bigboy:~#

UsingCDROMs
InstallingDEBfilesfromCDROMissimilartothatwithFedora/Redhat.Thedifferenceisthatthe CDROMdevicenameis/media/cdrom.ThefollowingprocedureinstallsthendiswrapperDEBthathad previouslybeencopiedtoadisk.: 1.InserttheCDROM,checkthefilesinthe/media/cdromdirectoryandtheninstalltheDEB.
root@u-bigboy:/tmp# mount /media/cdrom -o unhide mount: block device /dev/hdc is write-protected, mounting read-only root@u-bigboy:/tmp# cd /media/cdrom root@u-bigboy:/media/cdrom# ls ndiswrapper-utils_1.8-ubuntu2_i386.deb root@u-bigboy:/media/cdrom# dpkg --install ndiswrapper-utils_1.8-ubuntu2_i386.deb Selecting previously deselected package ndiswrapper-utils. (Reading database ... 70221 files and directories currently installed.) Unpacking ndiswrapper-utils (from ndiswrapper-utils_1.8-0ubuntu2_i386.deb) ... Setting up ndiswrapper-utils (1.8-0ubuntu2) ... root@u-bigboy:~#

2.Whenfinished,ejecttheCDROM
root@u-bigboy:/media/cdrom# cd /tmp root@u-bigboy:/tmp# umount /media/cdrom root@u-bigboy:/tmp# eject cdrom root@u-bigboy:/tmp#

Note:UnliketheFedoraCD/DVDsets,UbuntuLinuxisdistributedonasingleCD/DVD.The Ubuntuinstallationprocessdownloadsanyadditionalpackagesitmayneedondemandfromthe Internet.ItisforthisreasonthatyoumayfinditeasiertoinstallUbuntusoftwareusingtheAPTutility whichautomaticallydownloadandinstallmostofthepackagesyoudesire.TheAPTutilityiscovered inafollowingsection.

DEBInstallationErrors
SometimestheinstallationofDEBsoftwaredoesn'tgoaccordingtoplanandyouneedtotake correctiveactions.Thissectionshowsyouhowtorecoverfromsomeofthemostcommonerrorsyou'll encounter.

FailedDependencies
Asshouldbeexpected,packagesoftenrelyontheexistenceofotherpreviouslyinstalledpackages.This willsometimesresultindpkginstallationsfailingwithdependencyproblemserrorswhichreallymean thataprerequisiteDEBneedstobeinstalled.Inthenextexamplewe'retryingtoinstallthemrtg contribpackage,butitneedsthemrtgpackagetobeinstalledfirstbeforehand.
root@u-bigboy:/tmp# dpkg --install mrtg-contrib_2.12.2-1_all.deb Selecting previously deselected package mrtg-contrib. (Reading database ... 70759 files and directories currently installed.) Unpacking mrtg-contrib (from mrtg-contrib_2.12.2-1_all.deb) ... dpkg: dependency problems prevent configuration of mrtg-contrib: mrtg-contrib depends on mrtg (= 2.12.2-1); however: Package mrtg is not installed. dpkg: error processing mrtg-contrib (--install): dependency problems - leaving unconfigured Errors were encountered while processing: mrtg-contrib root@u-bigboy:/tmp#

Afterinstallingthemrtgpackage,mrtgcontribwasinstalledcorrectly.Youcanautomaticallyinstall prerequisitepackagesusingtheAPTutility.Thiswillbecoveredlaterinthechapter.

HowtoListInstalledDEBs
Thedpkglistcommandwilllistallthepackagesinstalledonyoursystem
root@u-bigboy:~# dpkg --list Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-===================-===================-================================ ii ssh 4.1p1-7ubuntu4 Secure shell client and server ... ... ... root@u-bigboy:~#

Theoutputwillbeinsixcolumns.Thefourthcolumnliststhenameofthepackage,thefifthstatesthe packageversion,andthesixthandlastprovidesadescription. Thefirstthreecolumnsareeachonlyasinglecharacterwideandprovideveryspecificinformation aboutthepackageasoutlinedinTable63.

Table63ColumnFormattingforthedpkgcommand
Desired State (Col.1) u i r p h n i c u f h h Current State (Col.2) Error State (Col.3) Unknown:Thepackagehasneverbeeninstalled Installed:Aprivilegeduserhasrequestedtheinstallationofthe package Remove:Aprivilegeduserhasrequestedtheremovalofthe package.Configurationfilesforthepackagemostlikelyremain. Purge:Apreviouslyinstalledpackagehasbeenremoved. Configurationfilesforthepackagehaveprobablybeenremoved. Hold:Aprivilegeduserhasrequestedthatthepackageremainat itscurrentversionwithnoautomaticupgrades. NotInstalled:Thepackageisnotinstalled Installed:Thepackageisinstalled ConfigurationFilesExist:Packagewasinstalled,butthe configurationfilesexist. Unpacked:Fileshavebeenunpacked,butnotinstalled Failed:Configurationofthepackagehasfailed. Halt:Thepackageinstallationfailedtocomplete EnforcedHold:Packageupgradeisonholdbecauseanother dependentpackagewithauserdefinedholdrequiresthispackage toremainnotupgraded. Reinstallation:Thepackageisbrokenandrequiresa reinstallation. Thepackageisbothbrokenandonenforcedhold.

Description

r x

Youcanspecifythedesiredpackageinwhichyouareinterestedafterthelistoptiontogetalisting

specifictothatpackage.Hereweseeasinglelistingfortheopensshserverpackageusingthismethod.
root@u-bigboy:~# dpkg --list openssh-server Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-===================-=========================================================== ii openssh-server 4.2p1-7ubuntu3 Secure shell server, an rshd replacement root@u-bigboy:~#

Youcanalsopipetheoutputofthiscommandthroughthegrepcommandifyouareinterestedinonlya specificpackage.Inthisexamplewearelookingforallpackagescontainingthestringdhcpinthe name.


root@u-bigboy:~# dpkg --list | grep dhcp ii dhcp3-client 3.0.2-1ubuntu6 DHCP Client ii dhcp3-common 3.0.2-1ubuntu6 Common files - dhcp3* packages root@u-bigboy:~#

ListingFilesAssociatedwithDEBs
Sometimesyou'llfindyourselfinstallingsoftwarethatterminateswithanerrorrequestingthepresence ofaparticularfile.Inmanycasestheinstallationprogramdoesn'tstatetheDEBpackageinwhichthe filecanbefound.Itisthereforeimportanttobeabletodeterminetheoriginofcertainfiles,bylisting thecontentsforDEBsinwhichyoususpectthefilesmightreside.

ListingFilesforPreviouslyInstalledDEBs
Asstatedpreviously,listingthefilesfoundinapackagecanbeveryuseful.Withdpkg,thelistiles optioncanprovidethisinformationeasily.Herewelistthefilespresentintheopensshserverpackage.
root@u-bigboy:~# dpkg --listfiles openssh-server ... ... ... /var/run/sshd /usr/lib/sftp-server /usr/share/doc/openssh-server root@u-bigboy:~#

ListingFilesinDEBFiles
Downloadsitesoftenhavepackageswithdifferentfunctions,butsimilarnames.Itisgoodtobeableto listthecontentsofaDEBpackagetoverifyyouhavethecorrectone.Thiscanbedonewiththe contentsoptionfordpkgascanbeseeninthisexample.
root@u-bigboy:/tmp# dpkg --contents openssh-server_4.2p1-7ubuntu3_i386.deb ... ... ...

-rw-r--r-- root/root -rw-r--r-- root/root server.8.gz drwxr-xr-x root/root drwxr-xr-x root/root drwxr-xr-x root/root drwxr-xr-x root/root drwxr-xr-x root/root ... ... ... root@u-bigboy:/tmp#

10444 2006-05-17 17:43:19 ./usr/share/man/man8/sshd.8.gz 1169 2006-05-17 17:43:19 ./usr/share/man/man8/sftp0 0 0 0 0 2006-05-17 2006-05-17 2006-05-17 2006-05-17 2006-05-17 17:43:24 17:43:24 17:43:19 17:43:19 17:43:19 ./usr/share/doc/ ./usr/share/doc/openssh-client/ ./var/ ./var/run/ ./var/run/sshd/

ListingtheDEBPackagetoWhichaFileBelongs
Searchingfortheownershipofaparticularfileisalsosimplewhenusingthesearchoptionwithdpkg. Inthisexample,weseethatthe/etc/syslog.conffileisapartofthesysklogdpackage.
root@u-bigboy:~# dpkg --search /etc/syslog.conf sysklogd: /etc/syslog.conf root@u-bigboy:~#

UninstallingDEBs
Thedpkgremovecommandwilleraseaninstalledpackageasseeninthisexample.
root@u-bigboy:~# dpkg --remove ndiswrapper-utils (Reading database ... 70241 files and directories currently installed.) Removing ndiswrapper-utils ... root@u-bigboy:~#

WhichDEBsWillStartUpAtBootTime?
YoucanviewandconfigurewhichDEBswillstartatboottimeisbyusingtheupdate-rc.d command.AmoredetailedexplanationwillbeprovidedinChapter7,"TheLinuxBootProcess".

AutomaticDEBUpdateswithaptget
LikeFedora,Debian/UbuntuLinuxhasitsownpackageupdateapplicationthatwillautomatically retrievepackagesfromanetworkbasedrepository.ItiscalledtheAdvancedPackageTool(APT)andit isthemostcommonlyusedcommandisaptgetwhichwe'llcoverinmoredetaillater

ConfiguringAPT
APTusesthe/etc/apt/sources.listfiletoinstructyourserverastowheretofindtherequiredpackages onyournetwork.ThedefaultfilelocationsinthisfilerefertoafewtrustedAPTdownloadwebsiteson theInternet.

ItisimportanttoperiodicallyresynchronizetheAPTpackageindexfilesfromthesourceslistedin the/etc/apt/sources.listfile.Thisupdatesyoursystemwithlistingsofthemostcurrentpackage versions.Thiscanbedonewiththeaptgetupdatecommandasseenhere:


root@u-bigboy:/tmp# apt-get update Get:1 http://security.ubuntu.com dapper-security Release.gpg [189B] Get:2 http://us.archive.ubuntu.com dapper Release.gpg [189B] Get:3 http://us.archive.ubuntu.com dapper-updates Release.gpg [189B] ... ... ... Fetched 184kB in 2s (66.1kB/s) Reading package lists... Done root@u-bigboy:/tmp#

Note:IfyouinstallUbuntuwithoutInternetaccess,onlyabarebonessetofpackageswillbeinstalled andtheURLentriesinthe/etc/apt/sources.listfilewillbecommentedout,buttherequiredpackages willbeflaggedforeventualinstallationinthedpkgdatabase.WhenyougetInternetaccess,uncomment theURLentriesandupgradeyourinstallationwiththeaptgetcommandwhichwillupdateyoursystem withthefullcomplementofrequiredpackagesdownloadedfromtheWeb. YoucanalsocreateanAPTserveronyourownnetworkifyoudon'twantallyourDebian/Ubuntu serverstohaveInternetaccess.You'llhavetoupdateyoursources.listfileaccordingly,butthefull configurationstepsarebeyondthescopeofthisbook.

KeepingYourSystemcurrentwithAPT
Theaptgetutilitycanbeusedtosimultaneouslyupgradeallthepackagesonyoursystemwiththe upgradeoption.Whenusedwithoutlistinganypackagesafterwards,aptgetwillattempttoupdatethem all.TheaptgetupgradepackagenamecommandupdatesonlyaparticularDEBpackage. ItisalwaysadvisabletouseaptgetafterinstallingLinuxtomakesurethelatestversionsofsoftware areinstalledforthesakeofimprovedsecurityandfunctionality.Hereisanexampleofoutputofwhatto expect;theyflagcausesaptgettoassume"yes"astheanswertoallpromptsandallowsittorunnon interactively:
root@u-bigboy:/tmp# apt-get -y upgrade Reading package lists... Done Building dependency tree... Done The following packages have been kept back: linux-image-386 The following packages will be upgraded: capplets-data desktop-file-utils eog gdm gnome-about ... ... ... Setting up libgtk2.0-bin (2.8.18-0ubuntu1) ... Updating the IM modules list for GTK+-2.4.0...done. Updating the gdk-pixbuf loaders list for GTK+-2.4.0...done. root@u-bigboy:/tmp#

ExampleofanaptgetPackageInstallation
Hereisasampleinstallationofanindividualpackageusingyum.InthiscasetheRPMinstalledisthe apacheWebserverpackage:
[root@ root@u-bigboy:/tmp# apt-get -y install apache Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: apache-common apache2-utils libapr0 libpcre3 Suggested packages: apache-doc apache-ssl apache-perl The following NEW packages will be installed: apache apache-common apache2-utils libapr0 libpcre3 ... ... ... Creating config file /etc/apache/httpd.conf with new version Creating config file /etc/apache/srm.conf with new version Creating config file /etc/apache/access.conf with new version Creating config file /etc/apache/modules.conf with new version * Starting apache 1.3 web server... ...done. root@u-bigboy:/tmp#

RememberTheFollowingAPTFacts
TheAPTutility'ssources.listfileprimarilylistsURLsusingTCPport80(http://)foritsupdates Thiswillhaveimportanceforyourfirewallrules. Moredetailsonconfiguringyumcanbeobtainedbyrunningthemansources.listandtheman aptgetcommands.

InstallingSoftwareUsingtarFiles
Anotherpopularsoftwareinstallationfileformatisthetarfile,whichcanfrequentlybeobtainedfrom theWebsitesofsoftwaredevelopers,andonlinesoftwarelibrariessuchaswww.sourceforge.net. TheLinuxtarcommandisusedtoarchivefilesandtypicallyhavea.tarfileextensioninthefilename. Thesefilesarealsofrequentlycompressedinthegzipformat,andwhentheydo,theirfileextensions willendwith.tar.gzor.tgz.Thecommandstoextractthedatafromeithertypearesimilar.Whenatar fileisuncompressed,thecommandtoextractthedataistarxvffilename.tar.Whenthearchiveis compressed,thecommandtouseistarxzvffilename.tar.gz. Thetarfileinstallationprocessusuallyrequiresyoufirsttouncompressandextractthecontentsofthe archiveinalocalsubdirectory,whichfrequentlyhasthesamenameasthetarfile.Thesubdirectory willusuallycontainafilecalledREADMEorINSTALL,whichoutlinesallthecustomizedstepsto installthesoftware.

Herearetheinitialstepstotaketoinstalltarbasedsoftware: 1)Issuethetarcommandtoextractthefiles.
[root@bigboy tmp]# tar -xvzf linux-software-1.3.1.tar.gz linux-software-1.3.1/ linux-software-1.3.1/plugins-scripts/ ... ... ... linux-software-1.3.1/linux-software-plugins.spec [root@bigboy tmp]#

Thiscreatesasubdirectorywiththeinstallationfilesinside.
[root@bigboy tmp]# ls linux-software-1.3.1 linux-software-1.3.1.tar.gz [root@bigboy tmp]#

2)UsethecdcommandtoenterthesubdirectoryandfollowthedirectionslistedintheINSTALLand READMEfiles:
[root@bigboy tmp]# cd linux-software-1.3.1 [root@bigboy linux-software-1.3.1]# ls COPYING install-sh missing depcomp LEGAL mkinstalldirs FAQ lib linux-software.spec Helper.pm Makefile.am linux-software.spec.in INSTALL Makefile.in NEWS [root@bigboy linux-software-1.3.1]# plugins plugins-scripts README REQUIREMENTS subst.in

Softwareinstallationwithtarfilescanbefrustrating,frequentlyrequiringtheinstallationofother supportingtarfiles,eachwithitsowncustomizedinstallationcommands.RPMs,withthesingle standardizedcommandformat,areusuallyeasiertouseandmaybethebettermethodtousefornewer Linuxusers.

InstallingPerlModules
Evenifyoudon'tknowhowtoprograminPerl,youmayfindyourselfhavingtoinstallPerlmodulesto getsomeofyoursoftwarepackagestowork. ModulescanbeinstalledmanuallybydownloadingtheTARfilesfromwww.cpan.org,theprimaryPerl modulesite.Thedisadvantageisthatthismethoddoesn'tautomaticallyinstallanyprerequisitemodules youmayneed.Anotherdisadvantage,thoughsmallisthattheperlmodulenamesusuallyhaveadouble colon(::)intheirnames,buttheinstallationTARfileinwhichthismoduleresideswon'thavethe colonsinitsname.Forexampleversion1.74oftheMail::Toolsmodulehasthefilename MailTools-1.74.tar.gz. Modulescanalsobeinstalledautomaticallyusingtheperlcommand.Wewillcoverbothmethodsin thissection.

ManualInstallationofPerlModules
MostofthecommonlyusedPerlmodulescanbedownloadedfromtheCPANwebsite.Theinstallation stepsarestraightforward. 1.BrowsetheCPANwebsite,identifythemodulepackageyouneedandthendownloaditusinga utilitysuchaswget.
[root@bigboy tmp]# wget http://www.cpan.org/authors/id/M/MA/MARKOV/MailTools1.74.tar.gz --15:07:36-- http://www.cpan.org/authors/id/M/MA/MARKOV/MailTools-1.74.tar.gz => `MailTools-1.74.tar.gz' Resolving www.cpan.org... 66.39.76.93 Connecting to www.cpan.org|66.39.76.93|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 47,783 (47K) [application/x-tar] 100%[===================================>] 47,783 100.88K/s

15:07:38 (100.51 KB/s) - `MailTools-1.74.tar.gz' saved [47783/47783] [root@bigboy tmp]#

2.Extractthefilefromthepackagewiththetarcommand.
[root@bigboy tmp]# tar -xzvf MailTools-1.74.tar.gz MailTools-1.74/ MailTools-1.74/t/ ... ... ... MailTools-1.74/ChangeLog MailTools-1.74/MANIFEST [root@bigboy tmp]#

3.EnterthenewlycreateddirectorywiththesamenameastheTARfile,andinstallthemodulewith thefollowingcommands. perlMakefile.PL make maketest


[root@bigboy tmp]# cd MailTools-1.74 [root@bigboy MailTools-1.74]# perl Makefile.PL Checking for Net::SMTP...ok Checking for Net::Domain...ok Checking for IO::Handle...ok Checking if your kit is complete... Looks good Writing Makefile for Mail [root@bigboy MailTools-1.74]# make cp Mail/Cap.pm blib/lib/Mail/Cap.pm cp Mail/Mailer/rfc822.pm blib/lib/Mail/Mailer/rfc822.pm ... ... ...

Manifying blib/man3/Mail::Util.3pm Manifying blib/man3/Mail::Address.3pm [root@bigboy MailTools-1.74]# make test PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/extract.....ok ... ... ... All tests successful. Files=7, Tests=95, 2 wallclock secs ( 1.28 cusr + 0.29 csys = 1.57 CPU) [root@bigboy MailTools-1.74]#

YourPerlmoduleinstallationshouldnowbecomplete. Note:TheoutputoftheperlMakefile.PLcommandwilltellyouwhetherthereareanyotherrequired modules.Youcaneitherinstallthemallmanually,runningtheriskofhavingtoinstallmore prerequisitemodulesfortheseprerequisitemodules,oryoucanuseautomatedupdateswhichwillbe coverednext.

AutomaticInstallationofPerlModules
Modulescanbeinstalledautomaticallyusingtheperlutilitybutyoumustfirstinstalltheprerequisite ncftp and perl-CPANpackagetodownloadthepackagesfromCPAN.
[root@bigboy tmp]# yum -y install ncftp perl-CPAN

AfterthepackageinstalledyoucanusethefollowingperlcommandtoentertheCPANutility.
perl -MCPAN -e shell

Thefirsttimeitisrun,Perlwillpromptyouforanumberofconfigurationoptions.Inmostcasesthe defaultswillbesufficient.Aftertheinitialsetupiscompleteyouwillhaveacpan>commandprompt
cpan>

Installationofmodulescanthenbedonewiththeinstallcommandfollowedbythenameofthemodule. InthisexampleweinstalltheMail::AuditmoduleusingtheCPANutility.
[root@bigboy tmp]# perl -MCPAN -e shell Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.7602) ReadLine support available (try 'install Bundle::CPAN') cpan> install Mail::Audit CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://archive.progeny.com/CPAN/authors/01mailrc.txt.gz ... ...

... Installing /usr/share/man/man3/Mail::Audit::MAPS.3pm Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-threadmulti/perllocal.pod /usr/bin/make install -- OK cpan> exit Terminal does not support GetHistory. Lockfile removed. [root@bigboy tmp]#

TheexitcommandallowsyoutoreturntotheLinuxcommandpromptandyourPerlmoduleshouldbe fullyinstalled.

UpdatingYourPerlModules
Upgradingorupdatingyourmodulestothelatestversioncanalsobedoneusingtheperlcommandline utilitylikethis.
[root@bigboy tmp]# perl -MCPAN -we 'CPAN::Shell->install(CPAN::Shell->r)'

Thisisasimpleprocess,butmakesureyouhaveinternetconnectivityfirst.

Conclusion
Thisisjustthebeginning.IfthesoftwareyouinstallisintendedtomakeyourLinuxmachine permanentlyrunanapplicationsuchasaWebserver,mailserver,oranyothertypeofserveryouhave toknowhowtogetthesoftwareactivatedwhenthesystemreboots.ThisiscoveredinChapter7,"The LinuxBootProcess".Subsequentchapterscovertheuse,configuration,testing,andtroubleshootingof manyofthemostpopularLinuxserverapplicationsusedtoday.

You might also like