Click here to load reader

Linux Basic Commands - · PDF fileBasic Linux Commands • File Handling • Text Processing • System Administration • Process Management • Archival • Network • File Systems

  • View
    259

  • Download
    8

Embed Size (px)

Text of Linux Basic Commands - · PDF fileBasic Linux Commands • File Handling • Text...

  • LinuxBasicCommands

    [email protected]

  • BasicLinuxCommands FileHandling TextProcessing SystemAdministration ProcessManagement Archival Network FileSystems AdvancedCommands

  • Sourcestolearncommands??

    Primaryman(manual)pages. manshowsallinformationaboutthe

    command helpshowstheavailableoptions

    forthatcommand SecondaryBooksandInternet

  • FileHandlingcommands mkdirmakedirectories

    Usage:mkdir[OPTION]DIRECTORY...eg.mkdirprabhat

    lslistdirectorycontentsUsage:ls[OPTION]...[FILE]...eg.ls,lsl,lsprabhat

    cdchangesdirectoriesUsage:cd[DIRECTORY]eg.cdprabhat

  • FileHandling(contd...)

    pwdprintnameofcurrentworkingdirectoryUsage:pwd

    vimViImproved,aprogrammerstexteditorUsage:vim[OPTION][file]...eg.vimfile1.txt

  • cpcopyfilesanddirectoriesUsage:cp[OPTION]...SOURCEDESTeg.cpsample.txtsample_copy.txtcpsample_copy.txttarget_dir

    mvmove(rename)filesUsage:mv[OPTION]...SOURCEDESTeg.mvsource.txttarget_dirmvold.txtnew.txt

    FileHandling(contd...)

  • FileHandling(contd...)

    rmremovefilesordirectoriesUsage:rm[OPTION]...FILE...eg.rmfile1.txt,rmrfsome_dir

    findsearchforfilesinadirectoryhierarchyUsage:find[OPTION][path][pattern]eg.findfile1.txt,findnamefile1.txt

    historyprintsrecentlyusedcommandsUsage:history

  • Pattern

    A Pattern is an expression that describes a set of strings which is used to give a concise description of a set, without having to list all elements.

    eg. ab*cd matches anything that starts with ab and ends with cd etc. ls *.txt prints all text files

  • TextProcessing

    catconcatenatefilesandprintonthestandardoutputUsage:cat[OPTION][FILE]...eg.catfile1.txtfile2.txt

    catnfile1.txt

    echodisplayalineoftextUsage:echo[OPTION][string]...eg.echoIloveIndiaecho$HOME

  • TextProcessing(contd...)

    grepprintlinesmatchingapatternUsage:grep[OPTION]PATTERN[FILE]...eg.grepiapplesample.txt

    wcprintthenumberofnewlines,words,andbytesinfilesUsage:wc[OPTION]...[FILE]...eg.wcfile1.txtwcLfile1.txt

  • TextProcessing(contd...)

    sortsortlinesoftextfilesUsage:sort[OPTION]...[FILE]...eg.sortfile1.txtsortrfile1.txt

  • LinuxFilePermissions 3typesoffilepermissionsread,write,execute 10bitformatfrom'lsl'command12345678910filetypeownergroupotherseg.drwxrwrmeansownerhasallthreepermissions,grouphasreadandwrite,othershaveonlyread

    permission readpermission4,write2,execute1eg.rwxrwr=764673=rwrwxwx

  • SystemAdministration

    chmodchangefileaccesspermissionsUsage:chmod[OPTION][MODE][FILE]eg.chmod744calculate.sh

    chownchangefileownerandgroupUsage:chown[OPTION]...OWNER[:[GROUP]]FILE...eg.chownremomyfile.txt

  • SystemAdministration(contd...)

    suchangeuserIDorbecomesuperuserUsage:su[OPTION][LOGIN]eg.suremo,supasswdupdateausersauthenticationtokens(s)Usage:passwd[OPTION]eg.passwdwhoshowwhoisloggedonUsage:who[OPTION]eg.who,whob,whoq

  • psreportasnapshotofthecurrentprocessesUsage:ps[OPTION]eg.ps,psel

    killtokillaprocess(usingsignalmechanism)Usage:kill[OPTION]pideg.kill92275

    ProcessManagement

  • tartoarchiveafileUsage:tar[OPTION]DESTSOURCEeg.tarcvf/home/archive.tar/home/originaltarxvf/home/archive.tar

    zippackageandcompress(archive)filesUsage:zip[OPTION]DESTSOURSEeg.ziporiginal.ziporiginal

    unziplist,testandextractcompressedfilesinaZIParchiveUsage:unzipfilename

    eg.unziporiginal.zip

    Archival

  • Network sshSSHclient(remoteloginprogram)

    sshisaprogramforloggingintoaremotemachineandforexecutingcommandsonaremotemachine

    Usage:ssh[options][user]@hostname

    [email protected]

    scpsecurecopy(remotefilecopyprogram)scpcopiesfilesbetweenhostsonanetwork

    Usage:scp[options][[user]@host1:file1][[user]@host2:file2][email protected]:~/Desktop/

  • FileSystems fdiskpartitionmanipulator

    eg.sudofdiskl

    mountmountafilesystemUsage:mountttypedevicedireg.mount/dev/sda5/media/target

    umountunmountfilesystemsUsage:umount[OPTIONS]dir|device...eg.umount/media/target

  • FileSystems(contd...) duestimatefilespaceusage

    Usage:du[OPTION]...[FILE]...eg.du

    dfreportfilesystemdiskspaceusageUsage:df[OPTION]...[FILE]...eg.df

    quotadisplaydiskusageandlimitsUsage:quota[OPTION]eg.quotav

  • AdvancedCommands rebootrebootthesystem

    Usage:reboot[OPTION]eg.reboot

    poweroffpoweroffthesystemUsage:poweroff[OPTION]eg.poweroff

  • Suggested Material

    TheUNIXProgrammingEnvironmentbyKernighanandPike(PrenticeHall)

    YourUNIX:TheUltimateGuidebySumitabhaDas

  • ThankYou

  • Editorcommands kateKDEAdvancedTextEditor

    Usage:kate[options][file(s)]eg.katefile1.txtfile2.txt

    vimViImproved,aprogrammerstexteditorUsage:vim[OPTION][file]...eg.vihello.c

    geditAtextEditor.Usedtocreateandeditfiles.Usage:gedit[OPTION][FILE]...eg.gedit

  • ProcessManagement(contd...)

    bgmakeaforegroundprocesstoruninbackgroundUsage:type'ctrl+z'andthen'bg'

    fgtomakebackgroundprocessasforegroundprocessUsage:fg[jobid]

    jobsdisplaysthenamesandidsofbackgroundjobsUsage:jobs

  • AdvancedCommands(contd...)

    sedstreameditorforfilteringandtransformingtextUsage:sed[OPTION][inputfile]...eg.sed's/love/hate/g'loveletter.txt

    awkpatternscanningandprocessinglanguageeg.awkF:'{print$1}'sample_awk.txt

  • findsearchforfilesinadirectoryhierarchyUsage:find[OPTION][path][pattern]eg.findnamefile1.txt

    locatefindorlocateafileUsage:locate[OPTION]...FILE...eg.locatefile1.txt