Cygwin is not a full operating system, and so must rely on Windows for
accomplishing some tasks. For example, Cygwin provides a POSIX view
of the Windows filesystem, but does not provide filesystem drivers of
its own. Therefore part of using Cygwin effectively is learning to use
Many Windows utilities provide a good way to interact with Cygwin's
predominately command-line environment. For example,
ipconfig.exe provides information about network
configuration, and net.exe views and configures
network file and printer resources. Most of these tools
/? switch to display usage information.
Unfortunately, no standard set of tools included with all versions of
Windows exists. Generally, the younger the Windows version, the more
complete are the on-board tools. Additionally, many independent
sites such as
and Microsoft's own
provide quite useful command-line utilities, as far as they are not
already provided by Cygwin. A few Windows tools, such as
find.exe, link.exe and
sort.exe, may conflict with the Cygwin versions
make sure that you use the full path (/usr/bin/find)
or that your Cygwin
bin directory comes first in your
Windows programs do not understand POSIX pathnames, so any arguments that reference the filesystem must be in Windows (or DOS) format or translated. Cygwin provides the cygpath utility for converting between Windows and POSIX paths. A complete description of its options and examples of its usage are in cygpath(1), including a shell script for starting Windows Explorer in any directory. The same format works for most Windows programs, for example
notepad.exe "$(cygpath -aw "Desktop/Phone Numbers.txt")"
A few programs require a Windows-style, semicolon-delimited path list,
which cygpath can translate from a POSIX path with the
-p option. For example, a Java compilation from
bash might look like this:
javac -cp "$(cygpath -pw "$CLASSPATH")" hello.java
Since using quoting and subshells is somewhat awkward, it is often preferable to use cygpath in shell scripts.
Many popular Cygwin packages, such as
wget, require a
network connection. Since Cygwin relies on Windows for connectivity,
if one of these tools is not working as expected you may need to
troubleshoot using Windows tools. The first test is to see if you
can reach the URL's host with ping.exe, one of the
few utilities included with every Windows version since Windows 95.
If you chose to install the
you may have both
Windows and Cygwin versions of utilities such as ftp
and telnet. If you are having problems using one
of these programs, see if the alternate one works as expected.
There are a variety of other programs available for specific situations. If your system does not have an always-on network connection, you may be interested in rasdial.exe for automating dialup connections. Users who frequently change their network configuration can script these changes with netsh.exe. For proxy users, the open source NTLM Authorization Proxy Server or the no-charge Hummingbird SOCKS Proxy may allow you to use Cygwin network programs in your environment.
cygutils package contains
miscellaneous tools that are small enough to not require their own package.
It is not included in a default Cygwin install; select it from the Utils
category in setup.exe. Several of the
cygutils tools are useful for interacting with
One of the hassles of Unix-Windows interoperability is the different line
endings on text files. As mentioned in the section called “Text and Binary modes”,
Unix tools such as tr can convert between CRLF and LF
cygutils provides several dedicated programs:
conv, d2u, dos2unix,
u2d, and unix2dos. Use the
--help switch for usage information.
Another problem area is between Unix-style links, which link one file
to another, and Microsoft .lnk files, which provide a shortcut to a
file. They seem similar at first glance but, in reality, are fairly
different. By default, Cygwin does not create symlinks as .lnk files,
but there's an option to do that, see the section called “The
These symlink .lnk files are compatible with Windows-created .lnk files,
but they are still different. They do not include much of the information
that is available in a standard Microsoft shortcut, such as the working
directory, an icon, etc. The
package includes a mkshortcut utility for creating
standard native Microsoft .lnk files.
But here's the problem. If Cygwin handled these native shortcuts like any other symlink, you could not archive Microsoft .lnk files into tar archives and keep all the information in them. After unpacking, these shortcuts would have lost all the extra information and would be no different than standard Cygwin symlinks. Therefore these two types of links are treated differently. Unfortunately, this means that the usual Unix way of creating and using symlinks does not work with native Windows shortcuts.
There are several options for printing from Cygwin, including the
lpr found in
cygutils (not to be confused with the
native Windows lpr.exe). The easiest way to use
lpr is to specify a default device name in the
PRINTER environment variable. You may also specify a device
on the command line with the
options, which will override the environment variable setting.
A device name
may be a UNC path (
\\server_name\printer_name), a reserved
DOS device name (
lpt1), or a
local port name that is mapped to a printer share. Note that forward slashes
may be used in a UNC path (
which is helpful when using lpr from a shell that uses
the backslash as an escape character.
lpr sends raw data to the printer; no formatting is done.
Many, but not all, printers accept plain text as input. If your printer
supports PostScript, packages such as
enscript can prepare
text files for printing. The
ghostscript package also
provides some translation
from PostScript to various native printer languages. Additionally, a native
Windows application for printing PostScript, gsprint, is
available from the Ghostscript