Cygwin environment provides Windows users with Unix-like command-line tools. To access these tools, Cygwin Bash Shell is recommended (available in Start Menu/Programs/Cygwin). The screenshot of the shell is presented below, together with some basic commands.

Basic usage

In the prompt, Cygwin displays username and the computer name (green sstuijk@ICS-NB069), followed by the current directory (yellow /cygdrive/d/mmips, or ~ for "home" directory). The $ character is a part of the prompt

To change directory, you can use cd command with the target directory parameter. The target directory can be expressed in a DOS-like manner (d:/ or d:/mmips). Note that drives in Cygwin are treated as directories, and the usage of forward slash in place of the DOS backslash (d:/mmips instead of d:\mmips). Instead of DOS-like directory specification, you can use canonic Cygwin directory specification, which maps all system drives to subdirectories in the directory /cygdrive/. I.e. DOS C: drive can be accessed in Cygwin by /cygdrive/c, D: as /cygdrive/d, etc.

To display the contents of the current directory, you can use ls or dir commands. ls -la will provide more details, including file access permissions, size and modification date. To run Windows Explorer in the current Cygwin directory, you can type

explorer .
Note the 'dot' at the end of the line. Dot means 'current directory', while double dot '..' means parent directory.

A useful Bash feature is automatic filename completion. If you start typing a filename (as in the screenshot, we start typing cd gtk to change to gtkwave directory), and press the Tab key, Cygwin will automatically complete the name with the filename from the current directory. If there are more than one files with the same beginning of the name, double Tab will display a list of possible completions.

Program search path

The way Cygwin looks for a program to execute when you type the program name (e.g. explorer) is similar to DOS: it looks for the executable file explorer or explorer.exe in all directories specified in the environment variable $PATH. To see, which program will be executed, use which command:
which explorer
The answer is:
If you are having problems executing a program, e.g.
foo -a 1 foo: Command not found
try examining the value of the PATH variable
echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINDOWS/Microsoft.NET/Fr amework/v1.1.4322/:/cygdrive/c/Program Files/Borland/BDS/4.0/Bin:/cygdrive/c/pro gra~1/borland/cbuild~1/bin:/cygdrive/c/progra~1/borland/cbuild~1/projects/bpl:/c ygdrive/c/program files/thinkpad/utilities:/cygdrive/c/WINDOWS/system32:/cygdriv e/c/WINDOWS:/cygdrive/c/WINDOWS/system32/wbem:/cygdrive/c/program files/thinkpad /connectutilities:/cygdrive/c/Xilinx/bin/nt:/cygdrive/c/Program Files/MATLAB/R20 07a/bin:/cygdrive/c/Program Files/MATLAB/R2007a/bin/win32:/cygdrive/c/Program Fi les/Borland/CaliberRM SDK 2005 R2/lib:/cygdrive/c/Program Files/Common Files/GTK /2.0/bin:/cygdrive/c/Program Files/Common Files/Adobe/AGL:/cygdrive/c/Program Fi les/Celoxica/DK/Bin:/cygdrive/c/Program Files/Celoxica/DK/Plugins:/cygdrive/c/Pr ogram Files/QuickTime/QTSystem/:/cygdrive/c/Program Files/Celoxica/PDK/Software/ Bin:/cygdrive/d/My Documents/Borland Studio Projects/Bpl:/cygdrive/d/mmips/lcc/l ccdir
and check if the program you are trying to execute is in any of the directories named there. Note that the Cygwin root directory '/' is where you installed cygwin, e.g. c:\cygwin. E.g. /usr/bin in the default installation is in fact c:\cygwin\usr\bin

Note that by default the current directory (.) is NOT in the PATH. Therefore if you want to call an executable in the current directory, you need to specify the path to it, i.e. instead of


Adding new directories to search path

To add a new directory to the path use
This will however only be set for the current Bash session, so if you close Bash window, this change will be lost. To add a directory to the path permanently, add it to the Windows PATH variable. This can be done by in Start Menu/Settings/Control Panel/System/Advanced/Environment Variables, Edit the variable PATH, and add c:\new\directory\with\executables, separated by the colon ; from the other path components. Note, that while in Bash you use Cygwin directory notation (/cygdrive/c/), in Windows you have to use DOS notation (C:\)

Missing programs

If you are missing a program which should be a part of Cygwin installation, you Cygwin installation may be incomplete. Via the Cygwin website you can search, which package contains the program you need and then use the setup program to add this package to your installation.