Linux Basics - 4techbees.files.wordpress.com · 6/2/2018  · Ø Major Distributors for Unix...

14
Linux Basics Basics: Ø Unix is a proprietary commercial opera4ng system developed by Ken Thompson. Ø Linux is a free, open source opera4ng system developed by Linus Torvalds Ø Linux/Unix is 4mesharing, scalable, portable and mul4-tasking opera4ng system. Ø Major Distributors for Unix opera4ng system are AIX,SOLARIS and HP-UX. Ø There are many flavors of Linux opera4ng system in the market but for server versions organiza4ons typically use REDHAT and pay them for the support. Kernel: Ø In Linux/Unix kernel is the heart of opera4ng system which performs task scheduling, file management and handles communica4ons in response to system calls. Shell: Ø Shell is an interface between the user and kernel. Ø To Know the current shell we can use below commands. echo $SHELL echo $0

Transcript of Linux Basics - 4techbees.files.wordpress.com · 6/2/2018  · Ø Major Distributors for Unix...

LinuxBasicsBasics:Ø  Unixisaproprietarycommercialopera4ngsystemdevelopedbyKenThompson.Ø  Linuxisafree,opensourceopera4ngsystemdevelopedbyLinusTorvaldsØ  Linux/Unixis4mesharing,scalable,portableandmul4-taskingopera4ngsystem.Ø  MajorDistributorsforUnixopera4ngsystemareAIX,SOLARISandHP-UX.Ø  TherearemanyflavorsofLinuxopera4ngsysteminthemarketbutforserver

versionsorganiza4onstypicallyuseREDHATandpaythemforthesupport.Kernel:Ø  InLinux/Unixkernelistheheartofopera4ngsystemwhichperformstask

scheduling,filemanagementandhandlescommunica4onsinresponsetosystemcalls.

Shell:Ø  Shellisaninterfacebetweentheuserandkernel.Ø  ToKnowthecurrentshellwecanusebelowcommands.

echo$SHELLecho$0

LinuxBasicsØ  /etc/shellswilllistalltheshellswhichareavailableonthemachineØ  Belowarethedifferentshellsavailableinlinux/unix:

§  BourneShell:Oldestshellandthereisnoop4ontoeditpreviouscommandsortocontrolbackgroundjobs.

§  KornShell:ThisisbasedonBourneshellwithenhancementtoeditpreviouscommands.Wecanrunkshellusingkshorpdshfromthecurrentshell.TonavigatethroughthecommandweusehtomoveleWandltomoveright

§  CShell:TheCshellsyntaxistakenfromClanguageanditissuchausefultoolwhoarefamiliarwithC.Wecanruncshellusingcshfromthecurrentshell.

§  BashShell:BourneAgainstshellisacombina4onoffeaturesfromBourneshellandCshell.Ithasacommand-lineeditorthatallowstheuseofthecursorkeysinamore"userfriendly"mannerthantheKornshell.ItalsohasausefulhelpfacilityallowingyoutogetalistofcommandsbytypingthefirstfewleZersfollowedbythe"TAB"key.ItisthedefaultshellonmostLinuxdistribu4onsandunlessotherwisespecifiedistheshellusedforthefutureexamples.

Ø  Alltheshellshave$promptexceptcshellwith%prompt.

LinuxBasicsFileSystem:Ø  Filesystemisthemethodsanddatastructuresthatanopera4ngsystemusesto

keeptrackoffilesonadiskorpar44onsothatdataretrievalisfast,easyandsecure.

Ø  Disk/Par44oninlinuxcontainssuperblock,inode,datablock,directoryblockandindirectblock.§  Superblock:Itcontainsinforma4onaboutfilesystemasawhole.§  inode:Itcontainsinforma4onaboutafileexceptitsname.§  Directory:containsfilenameandinodenumber.§  Indirectblock:Usedaspointerstotheaddi4onalblocksallocatedwhenfilegrowsin

size.Ø  InordertocreatethefilessystemfirstdiskneedtobeformaZedbyalloca4ng

cylindersandpar44oningitthenweini4atethedisk/par44onwiththefilesystem.Ø  Toiden4fythefilesystemofapar44on:

$df–TinLinuxMountinunix.

LinuxBasicsØ  Linuxsupportsseveraltypesoffilesystems.Belowarethemostimportantones:

•  Minix:Oldest,Presumedtobethemostreliable,butwithlimitedfeaturesandcapabili4es.Maximumfilesizewas64MBandmaximumfilenamelengthwas14characters.

•  Xia:Amodifiedversionofminixfilesystemwhichsupportsbiggerfilesystem.Maximumfilesizeas2GBandmaximumlengthforfilenameis248characters.

•  UFS:IsalsocalledastheBerkeleyFastFileSystem,FFS.Maximumfilesizeis8ZBaswellasthemaximumvolumewithafilelengthof255characters.Fordirectorysearching,theinforma4onisstoredinatable.NewerUFSsupportsDirhash.Dirhashmakesahashofthedirectoriestoperformfastersearchesthanthenormallinearsearchdonewithatable.DirhashisstoredinRAMwhichisfasterthanaccessingthehashfromdisk.

•  Ext:Na4vefilesystemwhichisrarelyusedinnewinstalla4ons.ItwaswriZenbyremycardtoaddress2limita4onsofMinix.Extsupportedfilesofsize2GB,filenamesupto255charactersandfilesystemofsize2GB.Exthadonlyone4mestampanduseoflinkedlistsforfreespacewhichledtofragmenta4onandpoorperformance.

•  Ext2:isthedefaultfilesystemforlinuxun4lext3camealong.Ext2s4llisafavouredfilesystemforflashandUSBdrivesduetolackofjournaling.Itsupportsfilesizesupto2TBandfilesystemupto32TBdependingontheblocksize.Thedirectoryandfilestructureisnotindexed,sosearchinginadirectorywithlargenumberoffilescanbe4meconsuming.Filesanddirectoriesarestoredwithininodes.

LinuxBasics•  Ext3:Ext3filesystemwhichhasheabilityforanin-placeupgradefromext2and

supportsthesizelimita4onasext2.ext3supportsjournalingwhichallowsafilesystemtorecoverunwriZendatafromimpropershutdown.Onlineresizingcanbeperformedforspaceaddi4ons.

•  ext4:ext4uses48-bitaddressingsystemwhichallowsamaximumfilesizeof16TBandfilesystemsizeof1Exabyte.FilesstoredonanEXT4filesystemarestoredinExtents.Extentsreducesfragmenta4onandimprovesperformance.Bitmapsareusedtotrackusedandunusedblocks.ext4supportsmul4-blockalloca4on,delayedalloca4on,onlinefragmenta4onandpersistentprealloca4on.

•  ISO9660:isthestandardfilesystemforCD-ROMs.OnfreeBSDitiscalledascd9660andhsfs(HighSierraFileSystem)insolaris.

•  SwapFileSystem:Swapfilesystemistheloca4on/sonadiskthatareusedforvirtualmemorybyUNIX.

Ø  CreaIngaFilesystem:FirstdiskneedstoformaZedusingfdisk(withop4onsn,p,star4ng#ofcylindertoending#ofcylinderanwtosavethepar44on).Secondweusemke2fstocreatefilesystem(mke2fs/dev/sda1forext2,mke2fs–j/dev/sa1forext3andmke2fs–text4/dev/sda1).

Ø  TomountaparIIons/CDweuse:TomountaCDwemusemount-oloop-t1so9660/dev/sr0/media/

LinuxBasicsØ  Files:Ingeneral,everythinginUNIXandLinuxisafile,althoughsomeofthesefiles

areabitspecial.Mostfiles,orregularfilesastheyarecalled,justcontainnormaldataliketext,programsorimages.Specialfilesinclude•  Directories:filethatcontainlistsofotherfiles.•  IOfiles:areusedforinputandoutputdevicesandareheldinthe/devdirectory•  Links:arepointerfilesusedtomakeagivenfileordirectoryvisibleinadifferentpartof

thefiletree.•  Domainsockets:communica4onsocketsthatprovideinter-processnetworking•  Namedpipes:abitlikesocketsbuttheyprovideaneasierwayforinterprocesses

communica4on.•  Filenamescanbeupto256characterslong,butarebestkeptreasonablyshorttomake

themmanageable.Ifyouusestandardextensionslike.exeor.txt,theneveryonewillknowwhatafiledoes

Ø  Directories:Filesareorganizedintodirectoriestomakeiteasiertofindthings,andtokeepcommonfilesinacentralloca4on.Thelowestleveldirectoryistherootdirectory,denotedbya/(forwardslash).Anumberofsub-directorieswillexistbelowtheroot,Commonorstandardsubdirectoriesareshownasbelow:

LinuxBasics

LinuxBasicsØ  Tologintomachine:

•  InrealworldalltheserversarelocatedindatacentersandweneedtologintotheremoteserverusingSSH.

•  PuZyismostcommonSSHu4lityusedtoconnecttoremoteserver.•  Wehavetoprovidetheport#andservernametoconnecttotheserver.Wecanalso

savethesessioninforma4onforfuturelogins.

LinuxBasics•  Oncethesessionopensitpromptsorusernameandpassword

•  FromtheabovescreenshotyoucanobserveusingpuZywegetacommandline

interface.InordertogetagraphicaluserinterfaceortorunaGUItoolfrompuZywehavetoenablex11underSSHonleWcategorypane.

LinuxBasics•  Oncethesessionopenswehavetoexportthedisplaytowindows(local)machineip-

addressandopentheu4litytoprojectasaGUI.Rememberwehavetoinstallx-windowssoWware'slikeexceed,x-MingorVNC-clientonthelocalwindowsmachine.

LinuxBasicsWhyLinux/Unixoverwindowsforservers:1.Stability

–  Linuxsystemsarewellknownfortheirabilitytorunforyearswithoutfailure;infact,manyLinuxusershaveneverseenacrash.That'sgreatforusersofeverykind,butit'spar4cularlyvaluableforsmallandmedium-sizedbusinesses,forwhichdown4mecanhavedisastrousconsequences.

–  LinuxalsohandlesalargenumberofprocessesrunningatoncemuchbeZerthanWindowsdoes--that'ssomething,infact,thattendstodegradeWindows'stabilityquickly.

–  Thenthere'stheneedforreboo4ng.WhereasinWindowsconfigura4onchangestypicallyrequireareboot--causinginevitabledown4me--there'sgenerallynoneedtorestartLinux.AlmostallLinuxconfigura4onchangescanbedonewhilethesystemisrunningandwithoutaffec4ngunrelatedservices.

–  Similarly,whereasWindowsserversmustoWenbedefragmentedfrequently,that'sallbuteliminatedonLinux.Letyourcompe4torsenduretheplen4fuldown4methatinevitablygoeshand-in-handwithWindows;trustyLinuxwillkeepyouupandrunningandservingyourcustomersaroundtheclock.

LinuxBasics2.Security

–  Linuxisalsoinnatelymoresecurethanwindowis,whetherontheserver,thedesktoporinanembeddedenvironmentThat'sduelargelytothefactthatLinux,whichisbasedonUnix,wasdesignedfromthestarttobeamul4useropera4ngsystem.Onlytheadministrator,orrootuser,hasadministra4veprivileges,andfewerusersandapplica4onshavepermissiontoaccessthekerneloreachother.Thatkeepseverythingmodularandprotected.

–  Ofcourse,LinuxalsogetsaZackedlessfrequentlybyvirusesandmalware,andvulnerabili4estendbefoundandfixedmorequicklybyitslegionsofdevelopersandusers.Eventhesix-year-oldkernelbugthatwasrecentlyfixed,forinstance--anextremelyrareinstanceintheLinuxworld--hadneverbeenexploited.

–  Internally,meanwhile,usersofaWindowssystemcansome4meshidefilesfromthesystemadministrator.OnLinux,however,thesysadminalwayshasaclearviewofthefilesystemandisalwaysincontrol.

3.HardwareWhereasWindowstypicallyrequiresfrequenthardwareupgradestoaccommodateitsever-increasingresourcedemands,Linuxisslim,trim,flexibleandscalable,anditperformsadmirablyonjustaboutanycomputer,regardlessofprocessorormachinearchitecture.Linuxcanalsobeeasilyreconfiguredtoincludeonlytheservicesneededforyourbusiness'spurposes,thusfurtherreducingmemoryrequirements,improvingperformanceandkeepingthingsevensimpler.

LinuxBasics4.TCO

–  There'snobea4ngLinux'stotalcostofownership,sincethesoWwareisgenerallyfree.EvenanenterpriseversionpurchasedwithcorporatesupportwillbecheaperoverallthanWindowsorotherproprietarysoWware,whichgenerallyinvolveuser-basedlicensingandahostofexpensiveadd-ons,especiallyforsecurity.

–  Samegoesformostofthetoolsandapplica4onsthatmightbeusedonlinuxserver.TheoverallTCOsimplycan'tbebeat.

5.Freedom–  WithLinux,thereisnocommercialvendortryingtolockyouintocertainproductsor

protocols.Instead,you'refreetomixandmatchandchoosewhatworksbestforyourbusiness.

–  Inshort,withallthemanyadvantagesLinuxprovidesintheserverrealm,it'snowondergovernments,organiza4onsandmajorcompaniesaroundtheworld--includingAmazonandGoogle--relyontheopensourceopera4ngsystemintheirownproduc4onsystems.

LinuxBasics