dos - linux

Upload: francisian

Post on 05-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 dos - linux

    1/3

    EnteringCommandsACTION LINUX DOS COMMENTSGetcommandhelp. man help,command/? mansystemiswell-developedandmostappshaveamanfile.Findrelatedcommands. apropos NoDOSequivalent.Flipthroughenteredcommands. Arrows^andv Arrows^andvShowcommandhistory. history doskey/hSetacommandalias. aliasname=command doskeyname=command Use~/.bashrctosetpermanentlyin*nix.Clearthescreen. clear,ctrl-l clsTrapctrl-breakortrapsignals. trap breakonStartingandQuittingACTION LINUX DOS COMMENTSStartWindowsorX-Windows. startx winRebootsystem. shutdown-rnow rebootExittheshell. exit,exit0 exit,exit0Getoperatingsystemorshellversion. uname-a,cat/etc/issue verWorkingwithDisksACTION LINUX DOS COMMENTSCheckandrepairdrivefilesystem. fsck,debugfs scandisk,defragShowdiskusage. du-s chdiskTooltopartitionaharddrive. fdisk fdiskMountadrivelettertoafolder/directoryonyourharddrive. mount substX:

    C:\directory\pathFormatadrivefilesystem. mke2fs formatSettingtheEnvironmentACTION LINUX DOS COMMENTSListenvironmentvariables. set,env setSetanenvironmentvariable. exportvariable=value,setenv,orvariable=valuesetvariable=valueShowthecontentsofanenvironmentvariable. echo$variable echo%variable%Displaytextonscreen. echotext echotextDisplaythesystemsearchpath. echo$PATH PATHAppendadirectorytothesystemsearchpath. PATH=$PATH:/dir PATH%PATH%;C:\DIR Settingthepathallowsyoutoruncommandswithoutthinkingaboutwheretheirexecutablefileis.

    Setthestyleofthecommandprompt. exportPS1='\h(\u)\W>' PROMPT$p$gMuchmorecomplexityispossibleinbothflavorsofOS,here.GettingSystemInfoACTION LINUX DOS COMMENTSShowandsetthesystemdateandtime. date date,timeShowfreememoryonsystem. free,top memListinformationaboutrunningprocesses. ps-aux tasklistPrintcomputer'sname. hostname hostname,netname hostnameisDNS-related,whereastheWindowsnetnamecommandshowsnetbiosinfo.Showsysteminfo. lsdev,procinfo msd LsdevandprocinfodonotworkonLinuxVPSssometimesduetothewaydisksareprovisioned.WorkingwithFilesandDirectoriesACTION LINUX DOS COMMENTS

    Changedirectory. cd cdStoredirectoriesforreference. cd-,pushd/path/to/target,popdpushd,popd PushdandpopdareavailablefornewerWindowsversions.Listdirectorycontentswithsomedetail. ls-l(orusels-lF)(-aallfiles) dir The"bare"directorylistcommandsareinherentlydifferentindisplaycharacteristics.Listdirectorycontentsincompactmode. ls dir/wListdirectorycontents,oldestfilesfirst. ls-tr dir*.*/o-dListfilesandsize. ls-ls dir*.*/v/os NoticeyouarestringingtogetherargsinLinuxafterthedash,butthatyouhavetoputinadditionalslashesa

  • 7/31/2019 dos - linux

    2/3

    ndargsinDOS.Listsizeofdirectorycontents. du-h|sort-rn,du-hsc*--block-size=M (treesize) Duordiskusageiscommon,buttheswitcheswillbedifferentsodoa"mandu"tofindoutmoreinyour*nix.TreesizeisanexcellentGUIversionofduforWindows.Listdirectorycontentsrecursively. ls-R dir/sListincludinghiddenfiles. ls-a dir/aaCreateasemi-graphical"tree"viewoffoldersandsub-folders. tree treeUsetreewithmoretogetpage-by-pageoutput,andspace-barthroughthepages.I.e.:$tree|moreMakeanewdirectory. mkdir mkdir,mdCreateafileordirectorylink. ln (assign,subst) Neitherassignnorsubstarereallymuchlikeln.Removeadirectory. rmdir rmdir,rdDisplaycurrentlocation. pwd chdirRemoveafile. rm-iv del,erase,rmdir/sRemovedirectoryanditscontents. rm-R deltree DeltreeisWin95.Copyafile. cp-piv copy OfcourseyoucanjustcpafileinLinux,aswell.Copyadirectoryandallitssubcontents. cp-R xcopyRenameormoveafile. mv-iv rename,moveShowthecontentsofafile. cat typeShowthecontentsofafile,onepageatatime. more moreSortdataalphabeticallyornumerically. sort sort

    Findastringinafile. grep find,findstrComparetwofilesandshowdifferences.Alsoseecomm,cmp,mgdiffandtkdiff.diff comp,fcSetorchangefilepermissions. chmod attrib DOShashiddenswitch;usemvto.somenametomakeafilehiddenin*nix.Printafile. lpr printLinemodeeditor ed edlinEditatextfile. [editor]filename-whereeditorcanbenano,pico,vi,emacsetc. editfilename.txt In*nix,editorsareareligionbecausetheareusedsoheavilyforsystemsadministrationtasks.PicowastheeditorthatcamewiththePinemailer,andnanoisastandalonepicovariant.Manyswearbysimpleviorcomplexemacs,though.BackupandRestore

    ACTION LINUX DOS COMMENTSBackuporRestorefiles. tar-cvf,tar-xvf,mdir,mcopy,ditto,cpiobackup,restoreBackupfilestoafolder. tar-cvf/path/to/storagefiles backupfilesX:\Restorefilesfromafolder. tar-xvf/path/to/storagefiles restoreX:\filesCompressoruncompressfilesandfolders. tar,zip,gzip,bzip pkzipNote,tarjustconcatenatesfilestogetherforeasymanipulation,andisoftenusedbeforecompression.BatchandShellScriptingACTION LINUX DOS COMMENTSCallanotherscriptfromwithinabatchfileorshellscript. sourcesomescript,.somescript,shsomescript callcommand/c(orcmd)somescript

    SchedulingACTION LINUX DOS COMMENTSScheduleacommandorscripttorunonaschedule. crontab-l,crontab-eatNetworkCommandsACTION LINUX DOS COMMENTSSendicmppacketstoanetworkhost. ping pingShowroutesandrouterhopstogivennetworkdestination. traceroutetracertDisplayorconfigurenetworkinterfaces. ifconfig ipconfig,winipc

  • 7/31/2019 dos - linux

    3/3

    fg YoucannotconfigurethenetworkfromthecommandlineinWindows,likeyoucanwithifconfigin*nix.UseControlPanel.Getnetbiosordnsinfoforthehost. nslookup,dig nbtstat NetBIOSisaWindowsandDOSaffair.Printthecurrentroutingtable. route-n routeprintListstartupbackgroundservicesordaemons. chkconfig--list|greponnetstart

    servicesome-servicestart|stop netstart|stopsome-serviceShowmountedorconnectedsharesandfilesystems. df netshare,netuseCommunicationsACTION LINUX DOS COMMENTSSendamessengerpopupmessagetoaWindowsPC. smbclient-Mwin-hostnamenetsendwin-hostname"somemessage"Sendmessagetoanother*nixuser. talkWorkingwithUsersACTION LINUX DOS COMMENTSListwhoisloggedin. whoListhowmanyusersarecurrentlyloggedin. who|wc-lShowthecurrentuseraccount. whoami set ThereisawhoamicommandforWindowsavailableintheResourceKit.Or,youcanusesettolisttheenvironmentvariables,ofwhichtheusernameisone.Showwhoisloggedinandwhattheyaredoing. w netsessionShowalistofauser'sprocesses. ps-uaccount_name (TaskManager)