Professional Documents
Culture Documents
CygwinenvironmentprovidesWindowsuserswithUnixlikecommandlinetools.Toaccess
thesetools,CygwinBashShellisrecommended(availableinStartMenu/Programs/Cygwin).
Thescreenshotoftheshellispresentedbelow,togetherwithsomebasiccommands.
/Basicusage
Intheprompt,Cygwindisplaysusernameandthecomputername(greens000000@s000000),
followedbythecurrentdirectory(yellow/cygdrive/d/Ogo1.2,or~for"home"directory).
The$ characterisapartoftheprompt
Tochangedirectory,youcanusecd commandwiththetargetdirectoryparameter.Thetarget
directorycanbeexpressedinaDOSlikemanner(d:/ord:/Ogo1.2).NotethatdrivesinCygwin
aretreatedasdirectories,andtheusageofforwardslashinplaceoftheDOSbackslash
(d:/Ogo1.2insteadofd:\Ogo1.2).
InsteadofDOSlikedirectoryspecification,youcanusecanonicCygwindirectoryspecification,
whichmapsallsystemdrivestosubdirectoriesinthedirectory/cygdrive/ .I.e.DOSC:drive
canbeaccessedinCygwinby/cygdrive/c ,D:as/cygdrive/d ,etc.
Todisplaythecontentsofthecurrentdirectory,youcanusels ordir commands.lsla will
providemoredetails,includingfileaccesspermissions,sizeandmodificationdate.
TorunWindowsExplorerinthecurrentCygwindirectory,youcantype
$explorer.
Notethe'dot'attheendoftheline.Dotmeans'currentdirectory',whiledoubledot'.. 'means
parentdirectory.
AusefulBashfeatureisautomaticfilenamecompletion.Ifyoustarttypingafilename(asin
thescreenshot,westarttypingcdgtk tochangetogtkwavedirectory),andpresstheTabkey,
Cygwinwillautomaticallycompletethenamewiththefilenamefromthecurrentdirectory.If
therearemorethanonefileswiththesamebeginningofthename,doubleTabwilldisplaya
listofpossiblecompletions.
/Programsearchpath
ThewayCygwinlooksforaprogramtoexecutewhenyoutypetheprogramname(e.g.
directoriesspecifiedintheenvironmentvariable$PATH .
Tosee,whichprogramwillbeexecuted,usewhich command:
$whichexplorer
/cygdrive/c/WINNT/explorer
Ifyouarehavingproblemsexecutingaprogram,e.g.
$fooa1
foo:Commandnotfound
tryexaminingthevalueofthePATHvariable
$echo$PATH
/usr/local/bin:/usr/bin:/bin:/cygdrive/c/PROGRA~1/Borland/CBUILD~1/Projects/Bpl:
/cygdrive/c/PROGRA~1/Borland/CBUILD~1/Bin:/cygdrive/c/WINNT/system32:/cygdrive/c
/WINNT:/cygdrive/c/WINNT/System32/Wbem:/cygdrive/c/matlab6p1/bin/win32:/cygdrive
/c/ProgramFiles/Hummingbird/Connectivity/7.10/Accessories/:/cygdrive/d/ogo1.2/l
cc/lccdir:/cygdrive/c/PROGRA~1/Borland/CBUILD~1/Projects/Bpl:/cygdrive/c/PROGRA~
1/Borland/CBUILD~1/Bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/cygdrive/c/
WINNT/System32/Wbem:/cygdrive/c/matlab6p1/bin/win32:/cygdrive/c/ProgramFiles/Hu
mmingbird/Connectivity/7.10/Accessories/
andcheckiftheprogramyou'retryingtoexecuteisinanyofthedirectoriesnamedthere.Note
thattheCygwinrootdirectory'/'iswhereyouinstalledcygwin,e.g.c:\cygwin.E.g./usr/bin in
thedefaultinstallationisinfactc:\cygwin\usr\bin
Notethatbydefaultthecurrentdirectory(. )isNOTinthePATH.Thereforeifyouwanttocall
anexecutableinthecurrentdirectory,youneedtospecifythepathtoit,i.e.insteadof
$foo
use
$./foo
/Addingnewdirectoriestosearchpath
Toaddanewdirectorytothepathuse
$PATH=/cygdrive/c/new/directory/with/executables:$PATH
ThiswillhoweveronlybesetforthecurrentBashsession,soifyoucloseBashwindow,this
changewillbelost.
Toaddadirectorytothepathpermanently,addittotheWindowsPATHvariable:inStart
Menu/Settings/ControlPanel/System/Advanced/EnvironmentVariables,EditthevariablePATH,
andaddc:\new\directory\with\executables ,separatedbythecolon fromtheotherpath
components.
Note,thatwhileinBashyouuseCygwindirectorynotation(/cygdrive/c/),inWindowsyouhave
touseDOSnotation(C:\)
/Missingprograms
Ifyou'remissingaprogramwhichshouldbeapartofCygwininstallation,youCygwin
installationmaybeincomplete.
ViatheCygwinwebsiteyoucansearch,whichpackagecontainstheprogramyouneedand
thenusethesetupprogramtoaddthispackagetoyourinstallation.
Lastmodified:SunFeb2318:38:33EST2003byD.M.Gawlowski