Sunteți pe pagina 1din 41

2009

RAHULGUPTA

[ REDHATLINUXRHEL5SERVER ]
INTHISFILEIWILLTELLYOUALLABOUTLINUXBASICCOMMANDSANDSERVERS 1

INDEX

1. 2. 3. 4. 5. HistoryofLinux LINUXPRINCIPLE LinuxDirectoryStructure INSTALLATION LinuxBasicCommands a. Directorycommands b. FileCommands c.

6.

Hi storyo f Linu x
In1969,FourprogrammerKenThompson,DennisRitchie,RuddCanady&DougMcElroymadea programinBelllabswhichdoesnothaveanynameinyear1969. Brian Kernighan checked that program & found it is very good so]ware for client & networking purpose.HegavethenameUnixtothisprogramon1stJanuary1970(epochbme).FirstOperabngSystem. ThatbmethatprogramwaswrideninAssemblylanguage. In1972,aprogrammerDennisRitchiestartedconverbngthisprograminClanguage.(Alsocalled founderofClanguage). 1973UnixinClanguage. 1980 Berkeley So]ware Development (a part of research program of Berkeley University) launchesopenBSD(asmallprogramwrideninasingleoppy). PaulAllen&BillGatesaretheemployeeofBellLabs. In 1981, they both started Microso] with 9 more candidates & they gave a programme named Xenix(1980)butitwasopped. In1981LaunchedMSDOS1.0 In1984UNIXopensource In1985FirstGraphicalBasedOSWin2.0 In 1991, Linus Benedict Torvalds, Btech Iind year Computer Science, 23 years old student of UniversityofHelensiki(Finland)madeKernel(25thAugust1991). In1994RedHatCompany(collecbonofLinuxSets)cameintoexistence. 96.8%serversofLinuxbll2009.

LINU X PRINCIPLE
1. 2. 3. 4. 5. Everythingisale. Small,singlepurposeprogrammers. AbilitytoChainprogrammerstogethertoperformcomplextasks. Avoidcapbveuserinterfaces. Congurabondatastoredintext.

Linu xDi re ctory Stru cture


1. /home 2. /bin 3. /usr/bin 4. /sbin,/usr/sbin 5./usr/local/bin 6./etc 7./boot 8./root 9./mnt,/media 10./dev 11./var,/svr 12./proc,/sys 13./lib/usr/share Usershome(allusersfolders) Commands(userexecutable&Scripts) Commands(userexecutable&Scripts) rootprivilegedcommand commandswhichwemakeforouruse. SystemCongurabonles LinuxKernel&Bootableles root(Admin)Data formounbnganyexternaldevices devices(hdd,CDRom,PenDrive) Serverdata SystemInformabon Librarylesstored

INSTALLATION
HereIwilltellyouinstallabonrelatedrequirementsandles.(notwholeinstallabon). Linuxusesext2&ext3lesystem. BootloaderoflinuxGRUB(GrantUniedBootLoader)new&LILO(LinuxLoader)old. BootfromCDorDVD Therearemanytypesofmethodofinstallinglinux 1. SimpleGraphicalmethoditwillaskforaEnter 2. Textbased inthisyouhavetowritelinuxtextorlinuxaskmethod(fromthisyoucanalso installfromNFS) MinimumrequirementforGraphicalinstallabonx86processor,256MBRAM. ParbbonCreatedatthebmeofinstallabon Partition Name File System Used for Minimu m Siz e / ext3 linuxlesystem 6000MBor6GB /boot ext3 Linuxboobngles&kernel 75or100MB /home ext3 Linuxusersentry Itsuponyou /swap Swap Usesasvirtualram DoubleofRAM Linuxcansupportmaximum63harddiskIDE&15SATAHarddisk. InLinux7userscanloginatthesamebme. IstUser Atl+Ctrl+F1 nd th II toVI user Alt+Ctrl+F2toF6 Graphicaluser Alt+Ctrl+F7

LINUXBOOTPROCESS

Linu xBasi cCo mm and s

Directorycommands:
1. 2. 3. 4. #mkdir #cd #cd.. #rmdir Forcreabngdirectory. changedirectory. tocomeoutfromworkingdirectory. toremovedirectory

FileCommands:
1. 2. 3. 4. 5. #touch<lename> #cat>lename #cat #catle1>>le2 #catnlename createsablankle. createsaleandforsavingthisle(ctrl+D) toseethecontentofthele. tomovele1maderinle2 toseehowmanylinesarewrideninthatle.

Commandsfordeleb ng:
1. 2. 3. 4. #rmlename #rmi #rmr #rmf deletesale. deletesle/folderininteracbvemode(askingmode) deletesdirectory. deletesles/foldersforcefully.

HelpCommands:
1. 2. 3. 4. 5. 6. #whabs<command> #man<command> #info<command> #<command>help #which<command> #cd/usr/share/doc Theseallarethehelpcommands.Printsallrelatedtags aboutthatcommand.

Rename&Move:
1. #mv<oldle><newle> 2. #mv<lename><wherewehavetomovethele> (Rename) (Move)

Lisb ngCommands:
1. 2. 3. 4. 5. #ls #lsl(ll) #lsa #ls??? #lsm* lisbngles/folders longlisbngofles/folderswithwholeinformabon listsallles/folders(hiddenalso) allles/foldersnamedwith3characters les&directoriesstartedwithlederm.

Copy:
1. 2. 3. 4.

#cp<source><desbnabon> copieslesfromsourcetodesbnabon #cpi<source><desbnabon> copieslesfromsourcetodesbnaboninaskingmode #cpi*<desbnabon> copiescurrentworkingdirectoryalldatatodesbnabon. #cpr<directoryname><desbnabon>copiesdirectoryfromsourcetodesbnabon

Editorsinlinux:
1. 2. 3. 4. 5. 6. nano vi vim gvim gedit Emacs Theseeditorsareusedinconsolemode.

Theseeditorsareusedingraphicalmode.

VIeditor/VIMeditor: Therearethreemodesinvieditors 1. exmode (defaultmode,bypressingescapekey,thismodeisusedforsavingandexit) 2. Insertmode (bypressinginsertorIkey,thismodeisusedforedibng) 3. Replacemode (thismodeisusedforreplacingtextwriden,byagainpressinginsertorrkey) Forsavingdocumentcomeonescmodeandwrite: w q Forsetnglinenumbersindocumentcomeonescmodeandwrite: se nu Forcomingonanyspeciclinepresslineno.andthenG (ex102thenG) ForgoingattheendofpagepressG Forgoingatthetopofpagepressgg Vimeditorisnotinstalleddefaultwhenyouinstalllinux,youhavetoinstallvimeditor.Itisthe enhancedversionofvieditor. #vim/vilename Pressvtocometovisualmode,herewecanselectthemaderwhichwewanttocopy,pressyy tocopy(ystandsforyank).Pressptopastethatmader. Pressddtodeleteaparbcularlinewherecursoris. NanoEditor: Nanoisacommandbasededitor,earlierusedwhenadvancededitorswerenotcameintobeing. Whenyouopenaalewiththiseditor,youwillndallrelatedhelpofthiscommand.

SOM EBAS ICCOMMA NDS

1. #powerof 2. #haltnp 3. #init0 4. #init6 5. #reboot 6. #startx 7. #init5 8. #history 9. #historyc Switchfromcommandtographic. Restartssystemfromcommandmodetographicmode. Toseehistoryofrecentcommands. Toclearthehistoryofrecentcommands Tocreatelogoscripts. Tocreatelogonscripts. Toseethecalendarofthatmonth&year. Startsbasiccalculator. Toknowbywhichuserweloggedon Tocreateuser Togivepasswordtouser. Tolockauseraccount. Tounlockauseraccount. Toremovepasswordforauser. Switchdirectlytousershomedirectorywith. Toseethetoptenlinesofale. Toseetop16linesofale. Toseethebodomtenlinesofale. Toseebodom16linesofale. Toopenapdfle(onlyongraphicalterminal) Shortleinazformat. Shortleindicbonaryformat. Shortleinzaformat. Translateleinallcapitalleders. Wordcount(lforline,wforword,cforcharacter) ThesecommandsareusedtoRestartcomputer. Thesecommandsareusedtoturnocomputer.

10. #cat>/etc/issue 11. #cat>/etc/motd

12. #calyyyyormmyyyy 13. #bc

14. #whoiamor#w

15. #adduser<username> 16. #passwd<username> 17. #usermodL<username> 18. #usermodL<username> 19. #passwdd<username> 20. #cd~

21. #head<lename>

22. #headn16<lename> 23. #tail<lename>

24. #tailn16<lename> 25. #evince<lename.pdf> 26. #sort<lename> 27. #sortd<lename> 28. #sortr<lename>

29. #cat<lename>|trazAZ 30. #wc(l/w/c)<lename>

10

31. #dile1le2 32. #blkid Toseedierencebetweensamelookingles. Toseedeviceid(exhda1,sdb). Toformatdeviceinfatformat. Tocheckspellinginale. Toopennetworkcongurabonongraphicterminal TochecktheIP&MACaddressofNIC. ToassigntemporaryIP Toenablenetworkcard. Todisablenetworkcard. ToassignpermanentIP,herewe havetoeditale.

33. #mkfs.vfatI/dev/deviceid 34. #aspellc<lename> 35. #neat 36. #ifcong

37. #ifcongeth0<ipaddress> 38. #ifupeth0

39. #ifdowneth0

40. #vi/etc/syscong/networkscripts/ifcfgeth0

41. #vi/etc/syscong/networking/devices/ifcfgeth0 42. #ethtooleth0 43. ##dfh<parbbon>

Tocheckgraphicallywhethercableisconnectedornot. Tocheckthefreespaceofaparbbon. Tocheckconnecbvity(c2forseeingtwolines,alisbng) Forlookingtheexactwordspelling. Tosetdate. Tochecktheprocessingstatus. Tokilltheserviceno.9. Fulldetailsofallprocessing&theirID.(kkill,hhelp) Todownloadthewebsitehomepage. Toopenwebsiteincommandline. Startsanewsubterminal. TosendmailinaNISorsinglePCbetweenuser&root Tocheckhowmuchparbbonisused. Itwilllinktheleinhomenamerahulwithrahul(inroot) Itwillcreatealenamedraghavingno.1to1000. Toseekernelname. Kernelrelease. Wholeinformabonaboutkernel. Searcheslein/. Searchesforleshavingpermission775. Searchesforlesof512k

44. #ping(c2,a)<ipaddress> 45. #look<word>

46. #datemmddhhmmyy 47. #ps

48. #kill9PID 49. #top

50. #wget<website> 51. #elinks<website> 52. #xterm 53. #mud

54. #duh<parbbon>

55. #ln/home/rahul/rahul 56. #seq11000>/home/rag 57. #uname 58. #unamer 59. #unamea

60. #nd/name<lename> 61. #ndperm775 62. #ndsize512k

11

63. #ndname*.htm 64. #zcat<lename.gz> Searchesleshavingextension.htm. Toseethecontentofcompressle. Toon/oanyservicepermanently. Listofdriversrunning. Detailsaboutrunningdriver Toupdatekernel. Showstemporaryles. Itwilldisplayfullinformabonaboutthatleordirectory. Itwillsetthefulluserpermissiononwwdirectory. TomountCDROM. Tomountanyexternaldevice. Tomountfatparbbon. Todeleteuser. Toaddagroup. Todeletegroup. Toseehistoryofcommands(a]erexecubnghistoryc) Toremovehistoryofcommands Setuserexpirabon. Toseeuserdetailedinformabon. Tosetwarningperiodforuser. Tocheckwhetheritisleorfolder. Itwillshowtherstcolumnofpasswdle. Itwilladdusertogroup. Toseetheidofuser. Toaddnetworkuseringroup. Itwillgivetheoutputofcommandinlenamestages.out. Toseealepagewise. Tondaparbcularwordorstringinale. Toseethelinenumberinwhichthatwordis. Itwilltakethebackupoflesasasinglele. Showhowmanyles&theirnameinthebackuple. Restorethebackup.

65. #chkcongon/o<service> 66. #lsmod 67. #modinfo

68. #sysctlnkernel 69. #tmpwatch

70. #ge|acl<lename>

71. #se|aclmu:<user>:rwx/ww 72. #mount/dev/cdrom/mnt

73. #mount/dev/devicename/mnt 74. #mounttvfat/dev/parbbon/mnt 75. #userdel<username> 76. #groupadd<name> 77. #groupdel<name> 78. #cat.bash_history

79. #cat>.bash_history

80. #chageEYYYYMMDD<user> 81. #chagel<username> 82. #chageW1<username> 83. #le<le/directoryname> 84. #cutf1d:/etc/passwd

85. #usermodG<group><user> 86. #idusername

87. #adduserg<group><user> 88. #command|teestages.out 89. #less<lename>

90. #grep<word><lename>

91. #grepn<word><lename> 92. #tarcvf<name><lesname> 93. #tartvf<name> 94. #tarxvf<name>

12

95. #gzip<lename> 96. #bzip2<lename> Itwillcompressale. Itwillcompressale. Itwilldecompressale. Itwilldecompressale. Itwilltakecontrolofremotepc(askforpassword) Tosendanyleinnetwork. Tosendanydirectoryinnetwork. forconverbngext2toext3

97. #gunzip<lename>.gz 98. #bunzip2<lename>.b2z 99. #ssh<ipofremotePC>

100.#scp/root/proxy.exe10.0.0.1:/root 101.#scprv<source><desbnabon> 102.#tunetofsj/dev/parbbon

RPM(RedH atPacka geMana ger )


xmms1.2.109.i386.rpm

PackageNameVersionTypeofExtension
architecture

#rpm<opbons><packagename> #rpmivh<packagename> aid force nodebs (installpackagealongwithdependencies) (forcefully) (toremovepackagealongwithdependencies) (Touninstallpackage) (upgradethepackage) (Showwhetherpackageisinstallornot)

#rpme<packagename> U

#rpmq<packagename> qa qc qd qi qs ql

(queriesallinstalledrpmpackages) (listsonlythecongurabonlesstoredinthequeriedpackage) (listsonlythedocumentabonlesstoredinthequeriedrpm) (displayswholeinformabonaboutthequeriedrpm) (displaysthestatesoflesinthequeriedrpm) (displaysalllesrelatedtothequeriedrpm)

13

BREAKINGPA SS WORD& PASS WORDSECU RITY


Bre aki ng root passw ord: WhensystemasktoselectOS,herepresse. ChoosethesecondopbonKernel/vmlinuz2.6.i8,againpresse. Write1atthelastoftheline, Thenpressesckeyandthenb. Nowsystemwillrebootandstopsonsingleusermode sh# heretypepasswd,thenenter typenewpassword nowreboot&giverootandnewpassword. Passw ord Sec urit y (adding passw ord ong rub a] e r i nstall ab on): {ongraphicalterminal} #grubmd5crypt Password: Conrmpassword: (Hereyouseesomedigits,copythosedigits) Noweditlegrub.conf #vi/boot/grub/grub.conf Hereyouseealinewherewridenhiddenmenu,comeunderthatlineandtype Passwordmd5{pastethosedigits} Savele. Nowyourpasswordcannotbebrokenonstartup.

14

PERM ISS IONS

__________ owner group lename


f/dUsergroupothers

r=4(22)
read

w=2(21)
write

x=1(20)
execute

For di rect ory m ax im um pe rm i ssi on=777 For l e sm axi mum permi ssi on=666 To gi ve userfull pe rmi ssi on #chmod777lename Defaul t pe rmi ssi on for l e=644 Defaul t pe rmi ssi on for di re ct ory=755 To see t he i nte rnal pe rm issi on #umask(maxper.umask=defaultpermission) #umask000(fullpermissionforall) #umask777(denyforall) To change the ow ne r of le s or direct ory #chown<username>le/directoryname To change g roup of l es & di rect ory #chgrp<groupname>le/directoryname EveryuserhasitsownUID(UserIdenbcabon) EverygrouphasitsownGID(GroupIdenbcabon) IfUIDmatches(i.e.loginuser&owner)userpermissionisapplicable. IfGIDmatches(i.e.loginuser&group)grouppermissionisapplicable. Ifnothingmatchesotherpermissionisapplicable.

15

TocheckUID/GID #cat/etc/passwd (UIDforroot=0,UIDforuserstartsfrom500)

Fi le s w he reUI D & GI D i nformab on sav e d /etc/passwd /etc/shadow /etc/group (UID) (UIDinencryptedform) (GID)

/etc/gshadow (GIDinencryptedform)

BASH SHE LLP ROGRA MM ING


Bythiswecanmakeascriptofanyserverandrunatbmewewantit. #mkdir~/bin #cd/root/bin #vitest.sh(typethefollowinginthele) #!/bin/bash mkdir/repo cd/repo(writecommandinasequenceofitsuse) :wq #chmodu+xtest.sh(togiveexecutablepermissiontole) #test.sh(torunthatle) Todisplaythecontentonthescreen #echowhatisyouripaddress$(ifcong) #aliasR=ifcong #echowhatisyouripaddress$(R)

16

RU NLEV EL(INIT)
Toeditorseeinitlevel #vi/etc/inidab 0=shutdown 1=singleusermode 2=mulbusermodewithoutNFSsupport 3=fullmulbusermode 4=notused 5=Graphical(x11) 6=reboot Ifoursystembootsongraphicalandwewantthatoursystembootoninit3default,wechangethe followingline Id:5:initdefault(herewechange5with3)

Looping commandf ormaki nguser s


#forUSERinname1name2name3name4name5 >do >useradd$USER >echoredhat|passwdstdin$USER >done Nowitwillcreateveusersnamedname1,name2,name3,name4,name5withpasswordredhat.

CRONTA B
#crontabeuusername */1**** Savele. #servicecrondrestart (nowwhenuserloginon2ndterminalitwillgetmessagehelloa]erevery1min.) #crontabluusername(toseehowmanycrontabarerunningforuser) #crontabruusername(deletesthecrontab) echoHello>/dev/dy2(min,hour,date,month,day)

17

PARTIT IONS

Creabngnew/homeparbbon
#fdiskl (forcheckingtheposibonofharddiskparbbons) #fdisk/dev/hda (toassignwholeharddisk) IDE0 PrimaryMaster hda PrimarySlave hdb IDE1 SecondaryMaster hdc SecondrySlave hdd :n (nforcreabngnewparbbon,enter) Againenter Nowgivethesize(ex10000M) :w (wforsave,dfordelete) #partprobe(orrestart) Nowtoformatthisparbbon #mkfs.ext3/dev/hda7 (whateverparbbonyouhavemade) Nowtomountthisparbbon,makeafolder(ex/home) #mount/dev/hda7/home (butthisistemporarymounbng) Forpermanentmounbng #vi/etc/fstab (nowdothefollowingentryinthele) /dev/hda7 /home ext3 default 12 Savethele. (nowifyouhavepermanentlymountedtheparbbonandnowyouwanttodeleteparbbonrstlyremove theentryfromfstab,otherwiseyoursystemwillbedump)

18

CreabngSwapParbbon
Firstlyifthereisswapparbboninyoursystem,stopswap #freem (tocheckswapisworking) #swapons (tocheckswapisonwhichparbbon)

Firstremovetheentryofswapfromfstab #fdisk/dev/hda (deleteswapandreboot) Nowcreate :n :l :t (forseeingtheswapcode) (togivecode)

Parbbonno:5 Hexcode:82(forswap) :w(save) #partprobe #mkswap/dev/hda5 (tomakeparbbonswap) #swapona/dev/hda5 #e2label/dev/hda5hda5swap Nowinfstab LABEL=hda5swap :wq(save) Nowrebootyoursystemandyouwillndanewswapparbbon. swap swap defaults 00 (togivelabeltoparbbon)

19

RAID
Raidareoftwotypes 1. So]wareRaid 2. HardwareRaid Herewewilllearntoimplementso]wareRaid(Raid1,Raid5) MD(Metadisk)(whenmanyharddiskmakesadisk) Firstcreate4(exhad7,8,9,10)parbbonofequalsize. Now, for R aidlevel5 (m inim umt hre e harddi sk) #mdadmC/dev/md0n3/dev/had{8,9,10}l5 raidlevel5) To form at t he m d0 #mkfs.ext3/dev/md0 Now m ountm d0 i n a fol de r #mkdir/raid #mount/dev/md0/raid To chec kt he st at us of rai d de vic e s #mdadmD/dev/md0 #cat/proc/mdstat To m ak e any parb b on fault y #mdadmf/dev/md0/dev/hda10 To rem ove t he parb b on from rai d #mdadmr/dev/md0/dev/hda10 To add new parb b oni n rai d array #mdadma/dev/md0/dev/hda7 (bythiscommandwehavesuccessfullycreated

20

To st op the rai d #mdadmS/dev/md0 Beforestopping,wehavetounmountraid To acb v at e rai d #mdadmA/dev/md0/dev/had{7,8,9} (mountbeforeacbvabng) NowforRAIDlev el1(Mirroring) (minimumtwoharddiskrequired) #mdadmC/dev/md0chunk=64level=1raiddevices=2/dev/had{6,7} Nowformat&mountsameasabove.

LV M{LOGICA LVOLUME MA NA GER}


InLVM,parbbonsspacearemergedlogicallynotphysically. Makeparbbonsofsamesize(100mb2parbbons) Fi rstc re ate P hysic al Vol ume (PV) #pvcreate/dev/hda5/dev/hda6or #pvcreate/dev/hda{5,6} #pvdisplay Nowc re ate Vol um e Group #vgcreatevg0/dev/had{5,6} #vgdisplay Now we wi ll cre at el ogic al v ol ume #lvcreateL+50M/dev/vg0nlv0 (itwillcreatealogicalvolumeof50Mb{52Mb}) (200mb) (toseewhetherpviscreatedsuccessfully)

(toseewhethervgiscreatedsuccessfully)

21

To e xte nd t he l ogi calv ol um e #lvextendL+25M/dev/vg0/lv0 To re duce t he l og ic al v ol um e #lvreduceL25M/dev/vg0/lv0 (itwillreducethelogicalvolumeto25Mb) (itwillextendthelogicalvolumetoapprox.80Mb)

USERQUOTA
Firstlyeditle/etc/fstabforaddingquotaforusers #vi/etc/fstab LABEL=home Savethele #mountOremount/home #quotacheckcu/home #quotaon/home Now,addtwousersandeditleforuser #edquotauser(editthisle) or #setquotauser5125124050/home Itwillsetquotafortheuserthathecanonlyuse512kbofhomeparbbonspace. #quotao/home (tostopquota) (remounthomeparbbons) (tocheckwhetherquotaisappliedornot) (tostartthequota) /home ext3 defaults,usrquota 00

22

PRINTE RC OMMA NDS


ThesecommandsarecalledCUPS(CommonUnixPrinbngSystem) 1. #systemcongprinter 2. #lpstat ToinibalizePrintergraphically Tocheckthestatusofprinter Tocanceltheprinbng Tochecktheprinbngqueuestatus ChangenormaltexttoPostScript Changespostscripttopdf Sendsprinbng

3. #lprm<jobid> 4. #lpq

5. #a2ps 6. #ps2pdf

7. #lpr<lename><Printer>

SOM EIMP ORTANT F ILES & C OMMA NDS


1. #vi.bashrc aliasc=clear aliasm=mkdir savethele bytypingtheabovewordsitwillcreateshortcutforclearandmkdir(c&m) buta]eredibnglerstlogout&againlogin. 2. #vi/var/log/messages (showsauditmessages) 3. #vi.exrc :senu Savethele A]ersavingleyouwillndlinenumbersalreadywridenineveryleyouopenforedibng. 4. Forreplacingmanywordsinale(forexifwehavemadeale,inthatlemanybmesdogword iswridenandwewanttoreplaceworddogwithcat) Openlewithvieditorandonesc.Modetype (wehavetocreatethisle) (writethisinthele) (Thisishiddenle&usedtocreateshortcutsforcommands)

23

:%s/dog/cat/g 5. #seds/dog/cat/glename 6. $su (showlewithreplacedword) (onuser,askforrootpasswordandactasroot) (movesdirectlytouseranditsdirectory) (Showallles&directoryintreeorder) (historyofcommandswhichyouhaveexecuted)

7. #suusername 8. #lsR

9. #vi.bash_history 10. #vi/boot/grub.conf bmeout:50 savethele.

(herewecanchangetheOSselecbonbme)

SUDO
Bythiswecangiveuserpermissiontorunaparbcularcommandorcanrunallrootprivilegedcommand. #vi/etc/sudoers (inthislewehavetoeditthele&writetheusernameunderthefollowingline)

## Al l ow root t o runanyc omm andsanyw he re root ALL= (ALL ) use r ALL= (ALL ) ALL ALL

(herewritetheusernametowhomyouwanttogivepermissiontorunrootprivilegedcommand) (NoteeditthislecarefullyotherwiseyourOScouldbecorrupt) Nowloginwiththatuser $sudo<rootprivilegedcommand> Password (giveuserpassword)

24

25

YUM(YELLOWDOGM ODIFIE R)SERV ER


WhenweinstallRPMitwillaskfordependenciesbutwhenweinstallanypackagewiththehelpofyumit willinstallalldependenciesbydefault. FormakingYUMwehaveto 1. Createafoldernamedre po 2. MountCDROM(#m ount / dev /c drom /m nt) 3. CopyServer,Cluster,ClusterStorage,VTfromDVD/CDofRHEL5 (# c pR v f Se rve r Cl ust erCl ust e rSt orage VT /v ar/ re po) 4. Pasteitinfoldernamedre po 5. Deleterepodatanamedfolderfromallthefourfolders. 6. Createalenamedbase.repo #v i /et c/ y um. re pos. d/ base . re po [base] name=base baseurl=le:///var/repo/Server enabled=1 gpgcheck=0 [Cluster] name=Cluster baseurl=le:///var/repo/Cluster enabled=1 gpgcheck=0 [ClusterStorage] name=ClusterStorage baseurl=le:///var/repo/ClusterStorage enabled=1 gpgcheck=0 [VT] name=VT baseurl=le:///var/repo/VT enabled=1 gpgcheck=0

(savethele)

26

7. Editalenamedrheldebuginfo.repo #v i /et c/ y um. re pos. d/ rhel de bugi nfo. re po (Inthisleenabled&gpgcheckmustbe0) 8. Now,editthisle #v i /et c/ y um. c onf (Herealsoenabled&gpgcheckmustbe0) 9. Now,editlastle #v i /et c/ y um /pl ugi nc onf. d/ rhnpl ug in.c onf (Herealsoenabled&gpgcheckmustbe0) 10. Nowwehavetogrouplestocreaterepodata 11. Installstandaloneservice # rpm iv h /m nt / Se rve r/c re at e re po0 .4.42. fc6. noarc h.rpm 12. #c re at e re pog /m nt / Se rve r/ re podat a/c om psrhel5 serv erc ore. xm l /v ar/ repo/ Serve r 13. #c re at e re pog /m nt /C lust e r/ re podata/c om psrhel5c l ust e r. xm l /v ar/ repo/C l ust e r 14. #c re at e re pog /m nt /C lust e rSt orage / re podata/ c om psrhel5c l uste r st. xm l /v ar/ repo/C l ust e rSt orag e 15. #c re at e re pog /m nt / VT/ re podata/c omps rhel5v t. xml / v ar/ re po/ VT 16. #y umcl e an all 17. #y uml ist all 18. Nowinstallpackagefromcommand #y umi nst al l< pac k ag e nam e> 19. Touninstallpackage #y um re m ov e < pack ag e nam e > 20. Nowongraphicsyouwillndadd/removeprogramandallpackagesaretheretoinstall.

27

SQUIDSE RVE R(Pr oxyinLINUX)


Squidservercontrolsclientscomputersaccesstotheinternet. Itblockstheusersfromaccessingundesirablewebsitesandhidestheinternalidenbtyof thenetwork. ItimprovesperformancebystoringWebPageslocally. Itisgenerallyusedtoshareinternetfromonemachinetoseveralclients. SquidserveriswidelyusedasProxyserverbecauseitprovidesmanyfeatures&isanopen source. Pac k ag e s re qui re d: Squid2.6.STABLE64.el5.i386.rpm Port N um be r: 3128(default) Con g urab on Fil e: /etc/squid/squid.conf Servic e / Daem on: squid Forsquidyoursystemmusthavetwolancardoneforinternetline&otherforyourprivate network. 1. #yuminstallsquid* or

#rpmivhSquid2.6.STABLE64.el5.i386.rpm 2. Editle #vi/etc/squid/squid.conf (inthislesetlineno.&remove#anddofollowingchanges) Line no. 73 hdp_port3128 Line no. 993 Cache_dirufs/var/spool/squid10016256

28

Line no. 1079 access_log/var/log/squid/access.logsquid Line no. 1087 Cache_log/var/log/Squid/cache.log Line no. 1097 Cache_store_log/var/log/squid/squid.log Line no. 2522 aclour_networksscr192.168.1.0192.168.2.0/24 (herechangewithyournetworkrange) Line no. 2523 hdp_accessallowour_networks Line no. 2778 cache_mgrrahulguptamd1988@gmail.com(changewithyouremailaddressorname) bydoingthesecongurabonyourinternet Now forA cce ssl ist Line no. 2409 (thereyouwillndtypedaclC ONN ECT met hod C ONNEC T,typeunderthatline) acl<anyname>url_regex<Websitesyouwanttoblockorinibals,downloadings> (aclxyzurl_regexorkutmp3downloadingwww.gmail.com) hdp_accessdeny<abovename>(xyz) aclxyzurl_regexwww.google.com hdp_accessallowxyz hdp_accessdenyall (savethele) (Onlythiswebsiteyouwantyourclienttoaccess) or

3. #servicesquidrestart/reload 4. #netstattulpn|grep3128 5. #vi/var/log/squid/access.log 6. NowonclientPC (tocheckwhethersquidisworkingornot) (toseetherecordofwebsiteopenedbyclient)

Re dhatFireFoxeditmenupreferencesconnecbonsetngManualProxysetngProxy ServerIP__________Portno.3128check(usethisproxyforallprotocols) On Wi ndows: InternetexplorerToolsInternetOpbonsconnecbonsLanSetngcheck (useaproxyforthislan)GiveIP&Portno.OK.

29

DHCP( DYNAMICH OST C ONF IGURAT IONPROT OC OL) SERVER


ItprovidesIPaddressautomabcallytotheclientswhichrequestforanIPaddress. CentralizedIPmanagement DHCPpreventsIPaddressconictsandhelpsconservetheuseofclientIPaddresson thenetwork. DHCPreducesthecomplexityandamountofadministrabveworkbyassigningTCP/IP congurabonisupdatedautomabcally. Pac k ag e s: dhcp* Port num be rs: 67Bootp,68DHCP Con g urab on l e: /etc/dhcpd.conf Servic e / Daem on: dhcpd 1. Installdhcppackage #y umi nst al l dhc p* # rpm iv h dhc p* 2. Copydhcpcongurabonle #c p / usr/ share/ doc / dhc p3.0. 1/ dhc pd.c onf.sam pl e / etc /dhcpd.c onf

30

3. Editthisle #v i /et c/ dhc pd. c onf Subnet192.168.1.0 Opbondomainname example.com 192.168.1.1; netmask255.255.255.0

Opbondomainnameservers rangedynamicbootp

192.168.1.10192.168.1.20;

hardwareethernet __:__:__:__:__:__ xedaddress 192.168.1.16 (savele)

In this le we have to give our network range, domain name & its IP (opbonal), range of IP providedbyDHCPandifwewanttoxanyaddressforspecicuserwecanreserveIPforthat withthehelpofMACaddress. 4. # se rvic e dhc pd re st art 5. Now on client set the TCP/IP setng on obtain an IP address automabcally & obtain DNS serveraddressautomabcally.

31

DNS (DOMAINNA MESYSTEM)


HostleprovidesresolubonofhostnamestoIPaddress.Itcanonlyresolvethenamesprovide inthelocalhostle.Itcannotbeusedascentraldatabase.Youcanaddthename&Ipaddress in/etc/hostsle. #vi/etc/hosts #Donotremovethefollowinglineorvariousprograms 127.0.0.0 192.168.1.1 localhost.localdomain rahul.com localhost server (savethele)

DNS
ProvidesresolubonofnamestoIPaddressandresolubonofIPaddresstonames,denesa hierarchicalnamespacewhereeachlevelofanamespaceisseparatedbya.. ZoneZoneisastoragedatabasewhichcontainsallzonesrecords. Forward l ook upz one:UsedtoresolvehostnametoIPaddress.ItmaintainshosttoIP mappinginformabon. Ty pe s of R ec ords: SOARecord: NSRecord: Arecord: CNAMERecord: PTRRecord: MXRecord: Therstrecordinanyzonele. IdenbestheDNSServerforeachzone. ResolvesahostnametoIPaddress. Resolvesanaliasnametoahostname. ResolvesIPaddressforhostname. Usedbymailserver.

Re qui re d Pac k ag e s: bindchroot9.2.42.i386.rpm binddevel9.2.42.i386.rpm bindlibs9.2.42.i386.rpm bind* bindubls9.2.42.i386.rpm bind9.2.42.i386.rpm cachingnameserver7.33.noarch.rpm systemcongbind P ort num be r:53DNS Se rv ic e/ Dae m on:named

32

1. Installbind #y umi nst al l bi nd* # rpm iv h bind* #y umi nst al lc ac hing * # rpm iv h cachi ng * # yum i nst all sy st emc on g bi nd* # rpm iv h syste mc on g bi nd* 2. Copythele

#c p / usr/share / doc / bi nd9.3. 3/ sam pl e/ v ar/ nam e d/ nam e d. root /v ar/ nam e d/ chroot /v ar/name d 3. Nowongraphicalterminal (checkthatinnetworktabtheremustbeyoursIPaddressinDNStab) # sy st emc on gbi nd Nowawindowcomesthererig ht clic k on DN S se rve r addz onei nte rne t ok forw ardl ook upz one ok rahul. c om (g iv et he dom ai n nam e )(ok ) Nowrig ht cl ick on dom ai n nam e (ra hul.c om) addIP v4 addre ss (A ) ww w. rahul.c om (full dom ai n nam e) t he n IP v 4addre ss (192.168 .1 .. ) 4. # se rvic e nam e d re st art 5. Forreverselookupzone255 R. CI nt e rnet R ev e rse IP v4z one R .C. add NS (N am e Serv er) Se rv e r Dom ai n N am e: ww w. rahul. c om (sav e) 6. # se rvic e nam e d re st art 7. TocheckwhetheryourDNSserverisworking #hostwww.rahul.com #host192.168.1.1 (forwardlookupzone) (Reverselookupzone)

#digwww.rahul.com/192.168.1.1 #nslookupwww.rahul.com/192.168.1.1 8. On client PC add your IP in DNS tab in TCP/IP setngs and ping the domain name, if it completes successfully, means your forward lookup zone is working and ping a <ip address>,ifitgivesdomainnameitmeansreverselookupzoneisworking.(onwindows)

33

NFS SE RVE R
Sharingofles&foldersbetweenLinux. Pac k ag e s: portmap4.063.i386.rpm nfsubls1.0.64.6.i386.rpm Port N um be r: 2049nfsd 111portmap Con g urab on Fil e: /etc/exports Servic e: portmap nfs Dae m ons: nfsd 1. Createafolderandmakelesorpastelesyouwanttosharefrominnetwork.(ex./var/dump) 2. Editleforsharing #vi/etc/exports /var/dump *(rw) /var/rahul 192.168.1.15(ro) (savethele) (inrstline,wehaveshare/var/dumpforallusersinanetworkwithread&writepermission&in second line, wehaveshared /var/rahulonlyforthe PChavingIPaddress192.168.1.15withread onlypermission) 3. #servicenfsrestart 4. #serviceportmaprestart 5. #showmounte (TocheckNFSServeranditsshareddirectoryfromServeritself)

6. #showmounte<IPaddressofServer>(TocheckNFSServeranditsshareddocfromclient) 7. CLIENT EN D: FortakingNFSserverservicewehavetomountdirectoryfromservertoclient #mounttnfs<serverIP>:/var/dump/mnt #cd/mnt (hereyouwillndallthesharedmaterial) #cd/net #cd/IPofNFSServer

34

8. ForinstallabonfromNFS,copywholeDVD/CDinafolderandshareit. 9. Boot from CD on another client computer, write linux askmethod, here it will ask to select the installabonmedia,selectNFS,nowitwillaskto giveIPforyourclientcomputer,giveIP,Nowit will ask for Name of NFS Server: <Give IP of NFS Server>, and directory : <Give the path>. Now yoursystemwillinstallveryquicklywiththehelpofNFSserver.

SAM BASE RVE R


SambaisawayaLinuxComputercommunicatewithSMB(ServerMessageBox)andCIFS. With Samba, you can make your Linux computer a part of Microso] based network. ComputerswithvariousMicroso]Operabngsystemscancommunicatewitheachotherusing theserver. MessageBlock(SMB)protocol.WhenaMicroso]basedOSshareslesorprintersonaTCP/IP network,itusestheCIFS(CommonInternetFileSystem). Con g urab on Fil e s: /etc/samba/smb.conf 1. #yuminstallsamba* #rpmivhsamba* 2. Now,editle #vi/etc/samba/smb.conf (Installsambapackage) Servic e: smb

(atlastofle,pressingGcopythefollowinglineandpastethelinesandthenremove;infontof theline.) [MyShare] comment= path= validusers= public=no writable=no printable=no savethele. 3. #servicesmbrestart 4. TocreateSambausers #useradd<username> #smbpasswda<username> 5. Tochecksambaisconguredofnot (Sharename) (anycomment) (heregivethepathwhichyouwanttoshare) (Heregivesambausers) (Heregivethepermissionyouwanttogive)

35

#testparm 6. Sambausersentrycanbendin/etc/samba/smbpasswd 7. Onc li e ntc om pute rs:onrun:\\<IPaddressofsambaserver> Nowitwillaskforsambausergiveusernameandpassword.

NIS SE RVE R
NISserverisjustlikeAcbveDirectoryServicesinWindows.NISserverneedNFSserver,soitisnecessary toinstallNFSserverbeforeNIS. 1. Setthehostname #hostnamerahul.com 2. Setthedomainname #domainnamerahul.com 3. Installthepackage #yuminstallypserv* #rpmivhypserv* 4. Nowcreateasmanyasuseryouwanttocreate.Share/homeinNFSserver. #vi/etc/exports /home *(rw,sync) (savethele)

5. #servicenfsrestart #serviceportmaprestart #serviceypservrestart 6. #cd/usr/lib/yp 7. #./ypinitm 8. On Cli e nt: #setup(hereawindowwillbeopen,heremark*inNISopbon,itwillaskfordomain&IPOK) 9. #vi/etc/auto.master /home /etc/auto.misc (savethele) (inthisleitwillaskforhostname,addhostname,thenctrl+D)

10. #vi/etc/auto.misc * rw,so],intr serverIP:/home/& (savethele)

11.#serviceautofsrestart

36

(Nowyouclientisready,loginwiththeuserthatyouhavecreatedonServerandmakeleyou willndthatleonServer.)

APACHE( WE B)S ERVE R


ApacheServerisusedforhosbngwebsiteforInternet/Intranet.Bythisserverwecanalso authenbcateonlylimiteduserstoaccesswebsite.ForthisserveryoumusthaveDNSserver conguredoraddyourIPandservernameinhostsle. Pac k ag e s: hdpd* 1. Installpackageforhdp. #yuminstallhdp* #rpmivhhdp* 2. Nowmakeawebpage. #vi/var/www/html/rahul.html

(forsinglewebpage,forvirtualhosbngmakeanotherpageinanotherlocabon,) 3. NowwhenweentertheDNSaddress,apacheserverwelcomescreencomes,ifwewantto addourownhomepagewehavetoeditale. #vi/etc/hdpd/conf/hdpd.conf (atlastofthele) (change*withIPaddress)

</virtualHost*:80> Documentroot/var/www/html Servernamewww.rahul.com </virtualHost> 4. #servicehdpdrestart

(savethele)

5. NowwhenyouentertheDomainname(www.rahul.com)itwillopenyourwebpage) 6. AUTHE NTI CATI ON: openthesameleandattheendofle,typethefollowing <Directory AuthUserle AuthName AuthType Require </Directory> 7. Adduserforhdp #useraddrahul #htpasswdc/etc/hdpd/conf/htpasswdrahul /var/www/html> /etc/hdpd/conf/htpasswd WebAuthenbcabon Basic ValidUser

(savethele)

37

(itcreatesanewlehtpasswdandadduserrahulinit) Foraddingmoreuser #htpasswd/etc/hdpd/conf/htpasswd<username> 8. Vi rt ual H osb ng Firstcopytheabovefourlines <Virtualhost*:80> Documentroot/var/www Servernamewww.yahoo.com </Virtualhost> (change*withIPaddressatbothplace) (againstartservice)

Cometothelinesabovetheselines #NameVirtualHost*:80 (remove*and#change*withIPaddressofthesystem)

SENDMA IL
Pac k ag e s: send* 1. # rpm iv h ai d se nd* #y umi nst al l se nd* 2. # vi / etc/ se ndm ai l.m c Lineno.116 deamon_opbons(Port=smtp,addr=127.0.0.0,name=mta)dnl(adddnl#atthebeginning) savethele. 3. #m4/etc/mail/sendmail.mc>/etc/mail/sendmail.cf 4. #servicesendmailrestart 5. MA IL: #mailroot@localhost.localdomain Con g urab on Fil e: /etc/sendmail.mc

38

XENSE RVE R( VIRTUA LIZAT ION)


PA RA VI RTU ALIZ ATIO N Forvirtualizabon,firstwehavetocongureNFSserver. 1. Installpackages #yuminstallsystemcongkickstart* #yuminstallvirtmanager* 2. NowcopywholeDVDinafolder&shareitinNFS&alsosharethatfolderinwhichkickstartleis saved. 3. #systemcongkickstart (heremakeakickstartle,selectinstallabonbyNFSgiveNFSIP&Directoryandsaveit) 4. Alsomakeaparbbonhaving10GBspaceandformatthatparbbon(donotmount). 5. Now,rebootandselecttheXenLinux 6. Nowongraphicalconsole #virtmanager NewforwardparavirtualizabonforwardInstallmediaURL:nfs:<IPaddressofNFS>:/<path> &kickstartURL:nfs:<IPaddressofNFS>:<pathwherekickstartlesaved>nextNormalDisk /dev/<newparbboncreatedbyyou>nextnish. 7. YourvirtualLinuxmachineisreadytoinstallwiththehelpofNFS.

39

FTP
Re qui re d Pac k ag e Vsftpd* 1. # rpm iv h v s] pd* #y umi nst al lv s] pd* 2. #v i/ etc /v s] pd/v s] pd.c onf Wehavetoremove#infrontofthefollowinglines. Line no. 12: anonymous=defaultuser

(FTPusestwousersanonymous&FTPanonymoushasnopassword) Line no. 15: local_enable=yes (LocalusercanloginthroughFTP) Line no. 18: write_enable=yes (writepermissionisenabledtoFTP) Line no. 27: anon_upload_enable=yes (anonymoususercanuploadles) Line no. 31: anon_mkdir_write_enable=yes (anonymoususercancreatedirectory) Line no. 35: dirmessageenable=yes Line no. 85: Ftpd_banner=welcometoFTP 3. # se rvic ev s] pd restart 4. Cli ente nd: ]p<ServerIP> >cdpub >get<lename> >put<lename> (download) (upload)

40

>bye (exit)

41

S-ar putea să vă placă și