Free Unix Tools (ssh, bash, etc) under Windows

heyw 2010-05-18

TheCygwintoolsareportsofthepopularGNUdevelopmenttoolsforWindows9x/ME/NT/2000.TheyrunthankstotheCygwinlibrarywhichprovidestheUNIXsystemcallsandenvironmenttheseprogramsexpect.ForexampleyoufindthepopularCommandlineSecureShellTools(SSH)tocreateasecureterminalemulationfromWindowstoUnixsystems.

Thefollowingpackagesareavailablewiththecurrentrelease:

ashautoconfautomakebashbinutilsbisonbyaccbzip2clearcpiocryptcvscygrunsrvcygwindejagnudiffexpectfilefileutilsfindutilsflexgawkgccgdbgdbmgettextghostscriptgperfgrepgroffgzipinetutilsircjbigkitjpeglesslibpngloginlynxm4makemanmingwmtmuttncftpncursesnewlib-manopenglopensshopensslpatchpcreperlpoptpostgresqlpythonreadlineregexrxvtsedsh-utilssquidssmtptartcltktcshtermcaptetex-betatexinfotextutilstifftimeunzipvimw32apiwgetwhichxpmxpm-noxzipzlib

Installation

Downloadthe"setup.exe"ProgramfromCygwin(http://www.cygwin.com/setup.exe)

Run"setup.exe"fromyourdownloaddirectory.

Thiswillthendownloadthelistofavailablepackages,andoffertoinstallthemforyou.Thereareanumberofoptionswithinsetuptocontrolinstallationdetails.

Choose"DownloadfromInternettoCurrentDirectory"fromthesetupProgram

Theselectedpackagesarenowdownloadedtoyourlocaldrive.

Choose"InstallfromCurrentDirectory"fromthesetupProgram

Wheninstalling,youwillhavetospecify:

-Installrootdirectory(e.g.D:\cygwin)

-DefaultTextFileType("DOS"or"Unix")

-InstallFor("All"or"JustMe")

ConfigurationTips

MakesureyouhavesettheHOMEenvironmentvariable(e.g.C:\Home\Zahn)

Checkandaddyourmountswith

mount

D:\Cygwin\binon/usr/bintypesystem(binmode)

D:\Cygwin\libon/usr/libtypesystem(binmode)

D:\Cygwinon/typesystem(binmode)

c:on/cygdrive/ctypeuser(binmode,noumount)

d:on/cygdrive/dtypeuser(binmode,noumount)

e:on/cygdrive/etypeuser(binmode,noumount)

Ifyouneedadditionalmountpointscreatethedirectoriesandmounttheme.g.

mountc:/uxhome/home/zahn

Checktheautomaticallycreatedmountpoints

Thesetupprogramwillsetuptheneededmountpointsautomatically.YoucanfindthemintheWindowsregistryunder

HKEY_CURRENT_USER\Software\Cygnus\Cygwin\mountsv2

HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus\Cygwin\mountsv2

HowtouseDeviceFilesfortar?

ThereisnoneedtocreateaPOSIX/devdirectoryasitissimulatedwithinCygwinautomatically.Itsupportsthefollowingdevices:/dev/null,/dev/zero,/dev/tty,/dev/ttyX,/dev/ptmx,/dev/comX(theserialports),/dev/windows(thewindowsmessagequeue),/dev/randomand/dev/urandom.Thesedevicescannotbeseenwiththecommandls/devalthoughcommandssuchasls/dev/ttyworkfine.

TheWin32devicenameforapartitionisthedriveletterwithleading\\.\,sothefloppywouldbe\\.\A:,thefirstpartitiontypically\\.\C:.Completedrives(exceptfloppiesandCD-ROMSwhicharesupportedaspartitionsonly)arenamed\\.\PHYSICALDRIVEx.Thexisthedrivenumberwhichyoucancheckinthediskmanager.Eachdrivelinehasprependedthetext"Diskx".

ToaccesstapedrivestheWin32filename\\.\TAPExisused.Forexamplethefirstinstalledtapedeviceisnamed\\.\tape0.

Thenamingconventionissimple:ThenameofthePOSIXdevicehastobeginwith/dev/andtherestisasyoulike.Theonlyexceptionaretapedevices.Toidentifyifthetapedeviceisusedasarewindorano-rewinddevicethenamemustnotbeginwithn(rewind)orhastobeginwithn(no-rewind).

Someexamples:

mount-b//./A:/dev/fd0#mountfloppyasrawblockspecial

mount-b//./tape0/dev/st0#mount1.tapeasrewinddevice

mount-b//./tape0/dev/nst0#...andastheno-rewinddevice

Notetheusageofthe-boption.Itisbesttoincludethe-boptionwhenmountingthesedevicestoensurethatallfileI/Oisin"binarymode".Enter-soptiontoaddmountpointtosystem-wideregistrylocation.

Nowyoucanusetarasfollows:

tarxvf/dev/st0<dir>

Createandcopy.bashrcto$HOME

TheBASHshellcanbeconfiguredwiththeconfigurationfile$HOME/.bashrc(e.g)

#Aliases

aliasmore=less

aliasup='cd..'

aliasll='ls-la'

aliasls='ls-F'

aliasps='ps-Wl'

aliashome='cd$HOME'

aliaswhich='type-path'

aliasunix2dos='recodelat1:ibmpc'

aliasdos2unix='recodeibmpc:lat1'

aliash='history'

#MakeBash8bitclean

setmeta-flagon

setconvert-metaoff

setoutput-metaon

setcompletion-ignore-caseon

#SetPrompt

PS1="`tputsmso``whoami`@\h>`tputrmso`"

exportPS1

PS2=">"

exportPS2

StartBASHandenjoytheUnixToolslikeSSH,SCPetc.

zahn@SMARAGD>sshdbhost.akadia.com

WesuggesttosettheTERMvariableforprograms(e.g.vi)whichuseacorrectterminalemulationtothefollowingvalues:

Linux:TERM=linux;exportTERM

Sun:TERM=ansi;exportTERM

Example

Thefollowingscreenshotsshowsasecureterminalemulation(SSH)fromWindowstoUnixusingCygwin'sbashshell.Thebashshell,likemanyotherUnixutilitiesisportedtoWindows.

http://www.akadia.com/services/cygwin_tools.html

相关推荐