50 Most Frequently Used UNIX _ Linux Commands (With Examples)

Embed Size (px)

DESCRIPTION

50 Most Frequently Used UNIX _ Linux Commands (With Examples)

Citation preview

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 1/22

    333 573Like

    Menu

    HomeFreeeBookStartHereContactAbout

    50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)byRameshNatarajanonNovember8,2010

    Tweet 391

    Thisarticleprovidespracticalexamplesfor50mostfrequentlyusedcommandsinLinux/UNIX.

    Thisisnotacomprehensivelistbyanymeans,butthisshouldgiveyouajumpstartonsomeofthecommonLinuxcommands.Bookmarkthisarticleforyourfuturereference.

    DidImissanyfrequentlyusedLinuxcommands?Leaveacommentandletmeknow.

    1.tarcommandexamples

    Createanewtararchive.

    $tarcvfarchive_name.tardirname/

    Extractfromanexistingtararchive.

    $tarxvfarchive_name.tar

    Viewanexistingtararchive.

    $tartvfarchive_name.tar

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 2/22

    Moretarexamples:TheUltimateTarCommandTutorialwith10PracticalExamples

    2.grepcommandexamples

    Searchforagivenstringinafile(caseinsensitivesearch).

    $grepi"the"demo_file

    Printthematchedline,alongwiththe3linesafterit.

    $grepA3i"example"demo_text

    Searchforagivenstringinallfilesrecursively

    $grepr"ramesh"*

    Moregrepexamples:GetaGripontheGrep!15PracticalGrepCommandExamples

    3.findcommandexamples

    Findfilesusingfilename(caseinsensitvefind)

    #findiname"MyCProgram.c"

    Executecommandsonfilesfoundbythefindcommand

    $findiname"MyCProgram.c"execmd5sum{}\;

    Findallemptyfilesinhomedirectory

    #find~empty

    Morefindexamples:Mommy,Ifoundit!15PracticalLinuxFindCommandExamples

    4.sshcommandexamples

    Logintoremotehost

    sshljsmithremotehost.example.com

    Debugsshclient

    sshvljsmithremotehost.example.com

    Displaysshclientversion

    $sshVOpenSSH_3.9p1,OpenSSL0.9.7aFeb192003

    Moresshexamples:5BasicLinuxSSHClientCommands

    5.sedcommandexamples

    WhenyoucopyaDOSfiletoUnix,youcouldfind\r\nintheendofeachline.ThisexampleconvertstheDOSfileformattoUnixfileformatusingsedcommand.

    $sed's/.$//'filename

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 3/22

    Printfilecontentinreverseorder

    $sedn'1!G;h;$p'thegeekstuff.txt

    Addlinenumberforallnonemptylinesinafile

    $sed'/./='thegeekstuff.txt|sed'N;s/\n//'

    Moresedexamples:AdvancedSedSubstitutionExamples

    6.awkcommandexamples

    Removeduplicatelinesusingawk

    $awk'!($0inarray){array[$0];print}'temp

    Printalllinesfrom/etc/passwdthathasthesameuidandgid

    $awkF':''$3==$4'passwd.txt

    Printonlyspecificfieldfromafile.

    $awk'{print$2,$5;}'employee.txt

    Moreawkexamples:8PowerfulAwkBuiltinVariablesFS,OFS,RS,ORS,NR,NF,FILENAME,FNR

    7.vimcommandexamples

    Gotothe143rdlineoffile

    $vim+143filename.txt

    Gotothefirstmatchofthespecified

    $vim+/searchtermfilename.txt

    Openthefileinreadonlymode.

    $vimR/etc/passwd

    Morevimexamples:HowToRecordandPlayinVimEditor

    8.diffcommandexamples

    Ignorewhitespacewhilecomparing.

    #diffwname_list.txtname_list_new.txt

    2c2,3JohnMDoe>JasonBourne

    Morediffexamples:Top4FileDifferenceToolsonUNIX/LinuxDiff,Colordiff,Wdiff,Vimdiff

    9.sortcommandexamples

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 4/22

    Sortafileinascendingorder

    $sortnames.txt

    Sortafileindescendingorder

    $sortrnames.txt

    Sortpasswdfileby3rdfield.

    $sortt:k3n/etc/passwd|more

    10.exportcommandexamples

    Tovieworaclerelatedenvironmentvariables.

    $export|grepORACLEdeclarexORACLE_BASE="/u01/app/oracle"declarexORACLE_HOME="/u01/app/oracle/product/10.2.0"declarexORACLE_SID="med"declarexORACLE_TERM="xterm"

    Toexportanenvironmentvariable:

    $exportORACLE_HOME=/u01/app/oracle/product/10.2.0

    11.xargscommandexamples

    Copyallimagestoexternalharddrive

    #ls*.jpg|xargsn1icp{}/externalharddrive/directory

    Searchalljpgimagesinthesystemandarchiveit.

    #find/name*.jpgtypefprint|xargstarcvzfimages.tar.gz

    DownloadalltheURLsmentionedintheurllist.txtfile

    #caturllist.txt|xargswgetc

    12.lscommandexamples

    Displayfilesizeinhumanreadableformat(e.g.KB,MBetc.,)

    $lslhrwr1rameshteamdev8.9MJun1215:27archlinux.txt.gz

    OrderFilesBasedonLastModifiedTime(InReverseOrder)Usinglsltr

    $lsltr

    VisualClassificationofFilesWithSpecialCharactersUsinglsF

    $lsF

    Morelsexamples:UnixLSCommand:15PracticalExamples

    13.pwdcommand

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 5/22

    pwdisPrintworkingdirectory.Whatelsecanbesaidaboutthegoodoldpwdwhohasbeenprintingthecurrentdirectorynameforages.

    14.cdcommandexamples

    Usecdtotogglebetweenthelasttwodirectories

    Useshoptscdspelltoautomaticallycorrectmistypeddirectorynamesoncd

    Morecdexamples:6AwesomeLinuxcdcommandHacks

    15.gzipcommandexamples

    Tocreatea*.gzcompressedfile:

    $gziptest.txt

    Touncompressa*.gzfile:

    $gzipdtest.txt.gz

    Displaycompressionratioofthecompressedfileusinggzipl

    $gzipl*.gzcompresseduncompressedratiouncompressed_name237099797575.8%asppatchrpms.txt

    16.bzip2commandexamples

    Tocreatea*.bz2compressedfile:

    $bzip2test.txt

    Touncompressa*.bz2file:

    bzip2dtest.txt.bz2

    Morebzip2examples:BZisEazy!bzip2,bzgrep,bzcmp,bzdiff,bzcat,bzless,bzmoreexamples

    17.unzipcommandexamples

    Toextracta*.zipcompressedfile:

    $unziptest.zip

    Viewthecontentsof*.zipfile(Withoutunzippingit):

    $unzipljasper.zipArchive:jasper.zipLengthDateTimeName4099511309823:50METAINF/MANIFEST.MF3216908259821:07classes_1596408259821:07classes_names1054208259821:07classes_ncomp

    18.shutdowncommandexamples

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 6/22

    Shutdownthesystemandturnthepoweroffimmediately.

    #shutdownhnow

    Shutdownthesystemafter10minutes.

    #shutdownh+10

    Rebootthesystemusingshutdowncommand.

    #shutdownrnow

    Forcethefilesystemcheckduringreboot.

    #shutdownFrnow

    19.ftpcommandexamples

    Bothftpandsecureftp(sftp)hassimilarcommands.Toconnecttoaremoteserveranddownloadmultiplefiles,dothefollowing.

    $ftpIP/hostnameftp>mget*.html

    Toviewthefilenameslocatedontheremoteserverbeforedownloading,mlsftpcommandasshownbelow.

    ftp>mls*.html/ftptest/features.html/ftptest/index.html/ftptest/othertools.html/ftptest/samplereport.html/ftptest/usage.html

    Moreftpexamples:FTPandSFTPBeginnersGuidewith10Examples

    20.crontabcommandexamples

    Viewcrontabentryforaspecificuser

    #crontabujohnl

    Scheduleacronjobevery10minutes.

    */10****/home/ramesh/checkdiskspace

    Morecrontabexamples:LinuxCrontab:15AwesomeCronJobExamples

    21.servicecommandexamples

    ServicecommandisusedtorunthesystemVinitscripts.i.eInsteadofcallingthescriptslocatedinthe/etc/init.d/directorywiththeirfullpath,youcanusetheservicecommand.

    Checkthestatusofaservice:

    #servicesshstatus

    Checkthestatusofalltheservices.

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 7/22

    servicestatusall

    Restartaservice.

    #servicesshrestart

    22.pscommandexamples

    pscommandisusedtodisplayinformationabouttheprocessesthatarerunninginthesystem.

    Whiletherearelotofargumentsthatcouldbepassedtoapscommand,followingaresomeofthecommonones.

    Toviewcurrentrunningprocesses.

    $psef|more

    Toviewcurrentrunningprocessesinatreestructure.Hoptionstandsforprocesshierarchy.

    $psefH|more

    23.freecommandexamples

    Thiscommandisusedtodisplaythefree,used,swapmemoryavailableinthesystem.

    Typicalfreecommandoutput.Theoutputisdisplayedinbytes.

    $freetotalusedfreesharedbufferscachedMem:3566408158022019861880203988902960/+buffers/cache:4732723093136Swap:400017604000176

    IfyouwanttoquicklycheckhowmanyGBofRAMyoursystemhasusethegoption.boptiondisplaysinbytes,kinkilobytes,minmegabytes.

    $freegtotalusedfreesharedbufferscachedMem:311000/+buffers/cache:02Swap:303

    Ifyouwanttoseeatotalmemory(includingtheswap),usethetswitch,whichwilldisplayatotallineasshownbelow.

    ramesh@rameshlaptop:~$freettotalusedfreesharedbufferscachedMem:3566408159214819742600204260912556/+buffers/cache:4753323091076Swap:400017604000176Total:756658415921485974436

    24.topcommandexamples

    topcommanddisplaysthetopprocessesinthesystem(bydefaultsortedbycpuusage).Tosorttopoutputbyanycolumn,PressO(uppercaseO),whichwilldisplayallthepossiblecolumnsthatyoucansortbyasshownbelow.

    CurrentSortField:Pforwindow1:Def

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 8/22

    Selectsortfieldviafieldletter,typeanyotherkeytoreturn

    a:PID=ProcessIdv:nDRT=DirtyPagescountd:UID=UserIdy:WCHAN=SleepinginFunctione:USER=UserNamez:Flags=TaskFlags........

    Todisplaysonlytheprocessesthatbelongtoaparticularuseruseuoption.Thefollowingwillshowonlythetopprocessesthatbelongstooracleuser.

    $topuoracle

    Moretopexamples:CanYouTopThis?15PracticalLinuxTopCommandExamples

    25.dfcommandexamples

    Displaysthefilesystemdiskspaceusage.Bydefaultdfkdisplaysoutputinbytes.

    $dfkFilesystem1KblocksUsedAvailableUse%Mountedon/dev/sda12953040032331042479723212%//dev/sda2120367992501715966408206044%/home

    dfhdisplaysoutputinhumanreadableform.i.esizewillbedisplayedinGBs.

    ramesh@rameshlaptop:~$dfhFilesystemSizeUsedAvailUse%Mountedon/dev/sda129G3.1G24G12%//dev/sda2115G48G62G44%/home

    UseToptiontodisplaywhattypeoffilesystem.

    ramesh@rameshlaptop:~$dfTFilesystemType1KblocksUsedAvailableUse%Mountedon/dev/sda1ext42953040032331202479721612%//dev/sda2ext4120367992501715966408206044%/home

    26.killcommandexamples

    Usekillcommandtoterminateaprocess.Firstgettheprocessidusingpsefcommand,thenusekill9tokilltherunningLinuxprocessasshownbelow.Youcanalsousekillall,pkill,xkilltoterminateaunixprocess.

    $psef|grepvimramesh72437222922:43pts/200:00:00vim

    $kill97243

    Morekillexamples:4WaystoKillaProcesskill,killall,pkill,xkill

    27.rmcommandexamples

    Getconfirmationbeforeremovingthefile.

    $rmifilename.txt

    Itisveryusefulwhilegivingshellmetacharactersinthefilenameargument.

    Printthefilenameandgetconfirmationbeforeremovingthefile.

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 9/22

    $rmifile*

    Followingexamplerecursivelyremovesallfilesanddirectoriesundertheexampledirectory.Thisalsoremovestheexampledirectoryitself.

    $rmrexample

    28.cpcommandexamples

    Copyfile1tofile2preservingthemode,ownershipandtimestamp.

    $cppfile1file2

    Copyfile1tofile2.iffile2existspromptforconfirmationbeforeoverwrittingit.

    $cpifile1file2

    29.mvcommandexamples

    Renamefile1tofile2.iffile2existspromptforconfirmationbeforeoverwrittingit.

    $mvifile1file2

    Note:mvfisjusttheopposite,whichwilloverwritefile2withoutprompting.

    mvvwillprintwhatishappeningduringfilerename,whichisusefulwhilespecifyingshellmetacharactersinthefilenameargument.

    $mvvfile1file2

    30.catcommandexamples

    Youcanviewmultiplefilesatthesametime.Followingexampleprintsthecontentoffile1followedbyfile2tostdout.

    $catfile1file2

    Whiledisplayingthefile,followingcatncommandwillprependthelinenumbertoeachlineoftheoutput.

    $catn/etc/logrotate.conf1 /var/log/btmp{2 missingok3 monthly4 create0660rootutmp5 rotate16 }

    31.mountcommandexamples

    Tomountafilesystem,youshouldfirstcreateadirectoryandmountitasshownbelow.

    #mkdir/u01

    #mount/dev/sdb1/u01

    Youcanalsoaddthistothefstabforautomaticmounting.i.eAnytimesystemisrestarted,thefilesystemwillbemounted.

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 10/22

    /dev/sdb1/u01ext2defaults02

    32.chmodcommandexamples

    chmodcommandisusedtochangethepermissionsforafileordirectory.

    Givefullaccesstouserandgroup(i.eread,writeandexecute)onaspecificfile.

    $chmodug+rwxfile.txt

    Revokeallaccessforthegroup(i.eread,writeandexecute)onaspecificfile.

    $chmodgrwxfile.txt

    Applythefilepermissionsrecursivelytoallthefilesinthesubdirectories.

    $chmodRug+rwxfile.txt

    Morechmodexamples:7ChmodCommandExamplesforBeginners

    33.chowncommandexamples

    chowncommandisusedtochangetheownerandgroupofafile.\

    Tochangeownertooracleandgrouptodbonafile.i.eChangebothownerandgroupatthesametime.

    $chownoracle:dbadbora.sh

    UseRtochangetheownershiprecursively.

    $chownRoracle:dba/home/oracle

    34.passwdcommandexamples

    Changeyourpasswordfromcommandlineusingpasswd.Thiswillpromptfortheoldpasswordfollowedbythenewpassword.

    $passwd

    Superusercanusepasswdcommandtoresetotherspassword.Thiswillnotpromptforcurrentpasswordoftheuser.

    #passwdUSERNAME

    Removepasswordforaspecificuser.Rootusercandisablepasswordforaspecificuser.Oncethepasswordisdisabled,theusercanloginwithoutenteringthepassword.

    #passwddUSERNAME

    35.mkdircommandexamples

    Followingexamplecreatesadirectorycalledtempunderyourhomedirectory.

    $mkdir~/temp

    Createnesteddirectoriesusingonemkdircommand.Ifanyofthesedirectoriesexistalready,itwillnot

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 11/22

    displayanyerror.Ifanyofthesedirectoriesdoesntexist,itwillcreatethem.

    $mkdirpdir1/dir2/dir3/dir4/

    36.ifconfigcommandexamples

    UseifconfigcommandtovieworconfigureanetworkinterfaceontheLinuxsystem.

    Viewalltheinterfacesalongwithstatus.

    $ifconfiga

    Startorstopaspecificinterfaceusingupanddowncommandasshownbelow.

    $ifconfigeth0up

    $ifconfigeth0down

    Moreifconfigexamples:Ifconfig:7ExamplesToConfigureNetworkInterface

    37.unamecommandexamples

    UnamecommanddisplaysimportantinformationaboutthesystemsuchasKernelname,Hostname,Kernelreleasenumber,Processortype,etc.,

    SampleunameoutputfromaUbuntulaptopisshownbelow.

    $unameaLinuxjohnlaptop2.6.3224generic#41UbuntuSMPThuAug1901:12:52UTC2010i686GNU/Linux

    38.whereiscommandexamples

    WhenyouwanttofindoutwhereaspecificUnixcommandexists(forexample,wheredoeslscommandexists?),youcanexecutethefollowingcommand.

    $whereislsls:/bin/ls/usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz

    Whenyouwanttosearchanexecutablefromapathotherthanthewhereisdefaultpath,youcanuseBoptionandgivepathasargumenttoit.Thissearchesfortheexecutablelsmkinthe/tmpdirectory,anddisplaysit,ifitisavailable.

    $whereisuB/tmpflsmklsmk:/tmp/lsmk

    39.whatiscommandexamples

    Whatiscommanddisplaysasinglelinedescriptionaboutacommand.

    $whatislsls (1)listdirectorycontents

    $whatisifconfigifconfig(8)configureanetworkinterface

    40.locatecommandexamples

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 12/22

    Usinglocatecommandyoucanquicklysearchforthelocationofaspecificfile(orgroupoffiles).Locatecommandusesthedatabasecreatedbyupdatedb.

    Theexamplebelowshowsallfilesinthesystemthatcontainsthewordcrontabinit.

    $locatecrontab/etc/anacrontab/etc/crontab/usr/bin/crontab/usr/share/doc/cron/examples/crontab2english.pl.gz/usr/share/man/man1/crontab.1.gz/usr/share/man/man5/anacrontab.5.gz/usr/share/man/man5/crontab.5.gz/usr/share/vim/vim72/syntax/crontab.vim

    41.mancommandexamples

    Displaythemanpageofaspecificcommand.

    $mancrontab

    Whenamanpageforacommandislocatedundermorethanonesection,youcanviewthemanpageforthatcommandfromaspecificsectionasshownbelow.

    $manSECTIONNUMBERcommandname

    Following8sectionsareavailableinthemanpage.

    1. Generalcommands2. Systemcalls3. Clibraryfunctions4. Specialfiles(usuallydevices,thosefoundin/dev)anddrivers5. Fileformatsandconventions6. Gamesandscreensavers7. Miscellaneous8. Systemadministrationcommandsanddaemons

    Forexample,whenyoudowhatiscrontab,youllnoticethatcrontabhastwomanpages(section1andsection5).Toviewsection5ofcrontabmanpage,dothefollowing.

    $whatiscrontabcrontab(1)maintaincrontabfilesforindividualusers(V3)crontab(5)tablesfordrivingcron

    $man5crontab

    42.tailcommandexamples

    Printthelast10linesofafilebydefault.

    $tailfilename.txt

    PrintNnumberoflinesfromthefilenamedfilename.txt

    $tailnNfilename.txt

    Viewthecontentofthefileinrealtimeusingtailf.Thisisusefultoviewthelogfiles,thatkeepsgrowing.ThecommandcanbeterminatedusingCTRLC.

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 13/22

    $tailflogfile

    Moretailexamples:3MethodsToViewtailfoutputofMultipleLogFilesinOneTerminal

    43.lesscommandexamples

    lessisveryefficientwhileviewinghugelogfiles,asitdoesntneedtoloadthefullfilewhileopening.

    $lesshugelogfile.log

    Oneyouopenafileusinglesscommand,followingtwokeysareveryhelpful.

    CTRL+FforwardonewindowCTRL+Bbackwardonewindow

    Morelessexamples:UnixLessCommand:10TipsforEffectiveNavigation

    44.sucommandexamples

    Switchtoadifferentuseraccountusingsucommand.Superusercanswitchtoanyotheruserwithoutenteringtheirpassword.

    $suUSERNAME

    Executeasinglecommandfromadifferentaccountname.Inthefollowingexample,johncanexecutethelscommandasrajusername.Oncethecommandisexecuted,itwillcomebacktojohnsaccount.

    [john@devserver]$surajc'ls'

    [john@devserver]$

    Logintoaspecifieduseraccount,andexecutethespecifiedshellinsteadofthedefaultshell.

    $sus'SHELLNAME'USERNAME

    45.mysqlcommandexamples

    mysqlisprobablythemostwidelyusedopensourcedatabaseonLinux.Evenifyoudontrunamysqldatabaseonyourserver,youmightendupusingthemysqlcommand(client)toconnecttoamysqldatabaserunningontheremoteserver.

    Toconnecttoaremotemysqldatabase.Thiswillpromptforapassword.

    $mysqlurootph192.168.1.2

    Toconnecttoalocalmysqldatabase.

    $mysqlurootp

    Ifyouwanttospecifythemysqlrootpasswordinthecommandlineitself,enteritimmediatelyafterp(withoutanyspace).

    46.yumcommandexamples

    Toinstallapacheusingyum.

    $yuminstallhttpd

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 14/22

    Toupgradeapacheusingyum.

    $yumupdatehttpd

    Touninstall/removeapacheusingyum.

    $yumremovehttpd

    47.rpmcommandexamples

    Toinstallapacheusingrpm.

    #rpmivhhttpd2.2.322.0.1.el5.i386.rpm

    Toupgradeapacheusingrpm.

    #rpmuvhhttpd2.2.322.0.1.el5.i386.rpm

    Touninstall/removeapacheusingrpm.

    #rpmevhttpd

    Morerpmexamples:RPMCommand:15ExamplestoInstall,Uninstall,Upgrade,QueryRPMPackages

    48.pingcommandexamples

    Pingaremotehostbysendingonly5packets.

    $pingc5gmail.com

    Morepingexamples:PingTutorial:15EffectivePingCommandExamples

    49.datecommandexamples

    Setthesystemdate:

    #dates"01/31/201023:59:53"

    Onceyouvechangedthesystemdate,youshouldsyncronizethehardwareclockwiththesystemdateasshownbelow.

    #hwclocksystohc

    #hwclocksystohcutc

    50.wgetcommandexamples

    Thequickandeffectivemethodtodownloadsoftware,music,videofrominternetisusingwgetcommand.

    $wgethttp://prdownloads.sourceforge.net/sourceforge/nagios/nagios3.2.1.tar.gz

    Downloadandstoreitwithadifferentname.

    $wgetOtaglist.ziphttp://www.vim.org/scripts/download_script.php?src_id=7701

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 15/22

    333 Tweet 391 573Like

    Morewgetexamples:TheUltimateWgetDownloadGuideWith15AwesomeExamples

    DidImissanyfrequentlyusedLinuxcommands?Leaveacommentandletmeknow.

    >Addyourcomment

    Ifyouenjoyedthisarticle,youmightalsolike..

    1. 50LinuxSysadminTutorials2. 50MostFrequentlyUsedLinuxCommands

    (WithExamples)3. Top25BestLinuxPerformanceMonitoring

    andDebuggingTools4. Mommy,Ifoundit!15PracticalLinuxFind

    CommandExamples5. Linux101Hacks2ndEditioneBook

    AwkIntroduction7AwkPrintExamplesAdvancedSedSubstitutionExamples8EssentialVimEditorNavigationFundamentals25MostFrequentlyUsedLinuxIPTablesRulesExamplesTurbochargePuTTYwith12PowerfulAddOns

    {226commentsaddone}

    PreviousComments

    maheshAugust6,2014,8:04am

    thanksalot.

    LinkadomblessingAugust20,2014,7:52am

    thanksforthis.itsreallyhelpful

    LinkdevrajbharSeptember10,2014,9:47pm

    iwanttoknowallsimplecommandoftheunix

    LinkJohnSeptember13,2014,11:25am

    MaybeitwouldbeinterestingtodifferbetweenusingLinux/Unixasanadminorasanon

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 16/22

    admin,sincesomecommandsareuselessforanonadmin

    IpersonallymissVIinthislistSHUTDOWNmaybereplacedbyINITLSisalsoaninterestingone,andWHICHdefinatelyisThenagain,basicisthisoneaswell:ECHO

    LinkchandruSeptember18,2014,11:56am

    Hi,Iamusingtoshibasatellitelaptop.Afterinstallingredhatlinux6inmylaptopethernetnotdetected.KindlyhelpMyhardareinformation:Processor:intelpentiumcpuB9602.20GHZ2100.00mhzEhternet:03:00.0ehternetcontrolleratheroscommunicationsincdevice10a0(rev10).

    LinkNicholasLeeFaganSeptember20,2014,2:26pm

    51.)Rsync

    LinkdhirenOctober7,2014,3:11am

    Multiplefilesisthereintape.iamnocheckendofthedisk.howtodumpallfilesintape..anyscript

    LinkmrutyunjayOctober9,2014,12:31am

    Ididntgotawkcommand.Itriedbutitcantworkproperly.

    LinkJimO'ReillyOctober22,2014,7:03am

    wc

    LinknnsenseNovember27,2014,8:28am

    pwdisPrintworkingdirectory.Whatelsecanbesaidaboutthegoodoldpwdwhohasbeenprintingthecurrentdirectorynameforages.CanbesaidthatpwdPshowstherealpathifyoucdintoalink..

    Example$cd/home/user$lns./Public./Pub$cdPub$pwd/home/user/Pub$pwdP/home/nnsense/Public

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 17/22

    useful,isntit??

    LinkkrupaliDecember7,2014,12:27am

    Writeashellscripttodisplayalllinesofafilefrombottomtotop.

    Canyouhelpmewiththis??

    LinkTimChaseDecember8,2014,10:43pm

    Krupali,Youcanusethefairlystandardtacutility(inDebianscoreutilspackage).Thereareplentyofotherwaystodoit,butthatsthemoststraightforward.

    LinkSanthoshKDecember26,2014,3:58am

    Krupali,Haveyoubeenabletoscripttodisplayalllinesofafilefrombottomtotop?Itriedwithnoluck..

    LinkSanthoshKDecember26,2014,8:23am

    Krupali,

    Youmaytrythis:

    #!/bin/sh

    cpfile.txttemp.txtn=`catfile.txt|wcl`

    while[$nge0]dotail1temp.txt>>result.txtsedi$dtemp.txtn=`expr$n1`donermftemp.txtcatresult.txt

    LinkPreetiShrivastavaDecember29,2014,5:31am

    ducommandisalsousedforcheckingdiskspaceusage.

    LinkEirikB.January3,2015,10:24pm

    Hereisasafealternativeto$seds/.$//filename,whichwillonlyremove\r\nattheendoflines(as.matches*any*character.):

    $perlpes/\r\n$/\n/gfilename

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 18/22

    Replacesallinstancesof\r\nwith\n

    LinkshilpaJanuary30,2015,4:38am

    thanksalot

    LinkCharlesBeatonFebruary2,2015,7:31am

    Howaboutcpio?Particularlythefind./|cpiocomboie:

    find./mountdepthprint|cpiopdm/destination_dir

    C

    LinkDGFebruary25,2015,4:01pm

    Thanks..NiceTutorial.

    LinkvietvuFebruary27,2015,2:25am

    Thelistisfine,however,Ithinkthatmanshouldbeontop.Youknowwhy

    LinkmadhuApril11,2015,12:01am

    goodstuff

    LinkkiranApril22,2015,8:08pm

    Iwantascriptwhereineedtotakethelistoffilesofparticulardateandputtheminarchieve(anyfromarchieve1to8)

    LinkAnonymousApril29,2015,12:20am

    Thanksforinfo!!!

    LinkAnonymousMay13,2015,2:52am

    thanks

    LinkAnonymousMay27,2015,7:16am

    UsefullCollection:)

    LinkYutiJuly24,2015,3:46am

    THANKYOU!

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 19/22

    Link

    PreviousComments

    LeaveaComment

    Name

    Email

    Website

    Comment

    Submit

    Notifymeoffollowupcommentsviaemail

    Nextpost:LinuxmodprobeCommandExamplestoView,Install,RemoveModules

    Previouspost:LinuxStringsCommandExamples(SearchTextinUNIXBinaryFiles)

    RSS|Email|Twitter|Facebook|Google+

    Search

    EBOOKS

    Linux101Hacks2ndEditioneBookPracticalExamplestoBuildaStrongFoundationinLinuxBash101HackseBookTakeControlofYourBashCommandLineandShellScriptingSedandAwk101HackseBookEnhanceYourUNIX/LinuxLifewithSedandAwkVim101HackseBookPracticalExamplesforBecomingFastandProductiveinVimEditorNagiosCore3eBookMonitorEverything,BeProactive,andSleepWell

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 20/22

    Bethefirstofyourfriendstolikethis

    TheGeekStuff12,225likes

    LikePage Share

    POPULARPOSTS

    12AmazingandEssentialLinuxBooksToEnrichYourBrainandLibrary50UNIX/LinuxSysadminTutorials50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)HowToBeProductiveandGetThingsDoneUsingGTD30ThingsToDoWhenyouareBoredandhaveaComputerLinuxDirectoryStructure(FileSystemStructure)ExplainedwithExamplesLinuxCrontab:15AwesomeCronJobExamplesGetaGripontheGrep!15PracticalGrepCommandExamplesUnixLSCommand:15PracticalExamples15ExamplesToMasterLinuxCommandLineHistoryTop10OpenSourceBugTrackingSystemViandVimMacroTutorial:HowToRecordandPlayMommy,Ifoundit!15PracticalLinuxFindCommandExamples15AwesomeGmailTipsandTricks15AwesomeGoogleSearchTipsandTricksRAID0,RAID1,RAID5,RAID10ExplainedwithDiagramsCanYouTopThis?15PracticalLinuxTopCommandExamplesTop5BestSystemMonitoringToolsTop5BestLinuxOSDistributionsHowToMonitorRemoteLinuxHostusingNagios3.0AwkIntroductionTutorial7AwkPrintExamplesHowtoBackupLinux?15rsyncCommandExamplesTheUltimateWgetDownloadGuideWith15AwesomeExamplesTop5BestLinuxTextEditorsPacketAnalyzer:15TCPDUMPCommandExamplesTheUltimateBashArrayTutorialwith15Examples3StepstoPerformSSHLoginWithoutPasswordUsingsshkeygen&sshcopyidUnixSedTutorial:AdvancedSedSubstitutionExamplesUNIX/Linux:10NetstatCommandExamplesTheUltimateGuideforCreatingStrongPasswords6StepstoSecureYourHomeWirelessNetworkTurbochargePuTTYwith12PowerfulAddOns

    CATEGORIES

    LinuxTutorialsVimEditor

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 21/22

    SedScriptingAwkScriptingBashShellScriptingNagiosMonitoringOpenSSHIPTablesFirewallApacheWebServerMySQLDatabasePerlProgrammingGoogleTutorialsUbuntuTutorialsPostgreSQLDBHelloWorldExamplesCProgrammingC++ProgrammingDELLServerTutorialsOracleDatabaseVMwareTutorials

    Ramesh Natarajan

    Follow

    AboutTheGeekStuff

    MynameisRameshNatarajan.Iwillbepostinginstructionguides,howto,troubleshootingtipsandtricksonLinux,database,hardware,securityandweb.Myfocusistowritearticlesthatwilleitherteachyouorhelpyouresolveaproblem.ReadmoreaboutRameshNatarajanandtheblog.

    ContactUs

    EmailMe:UsethisContactFormtogetintouchmewithyourcomments,questionsorsuggestionsaboutthissite.Youcanalsosimplydropmealinetosayhello!.

    FollowusonGoogle+

    FollowusonTwitter

    BecomeafanonFacebook

    SupportUs

  • 06/09/2015 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)

    http://www.thegeekstuff.com/2010/11/50linuxcommands/ 22/22

    Supportthisblogbypurchasingoneofmyebooks.

    Bash101HackseBook

    SedandAwk101HackseBook

    Vim101HackseBook

    NagiosCore3eBook

    Copyright20082015RameshNatarajan.Allrightsreserved|TermsofService