Basic usage
In the prompt, Cygwin displays username and the
computer name (green s000000@s000000), 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
/cygdrive/c/WINNT/explorer
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:/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/Program Files/Hummingbird/Connectivity/7.10/Accessories/:/cygdrive/d/mmips/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/Program Files/Hu
mmingbird/Connectivity/7.10/Accessories/
and check if the program you're 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
$ foo
use $ ./foo
Adding new directories to search path
To add a new directory
to the path use $ PATH=/cygdrive/c/new/directory/with/executables:$PATH
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: 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're missing a program which should be
a part of Cygwin installation, you Cygwin installation may be
incomplete.
Via the