Cygwin Utilities

Cygwin comes with a number of command-line utilities that are used to manage the UNIX emulation portion of the Cygwin environment. While many of these reflect their UNIX counterparts, each was written specifically for Cygwin.

cygcheck

Usage: cygcheck [-s] [-v] [-r] [-h] [program ...]
  -s = system information
  -v = verbose output (indented) (for -s or programs)
  -r = registry search (requires -s)
  -h = give help about the info
You must at least give either -s or a program name

The cygcheck program is a diagnostic utility that examines your system and reports the information that is significant to the proper operation of Cygwin programs. It can give information about a specific program (or program) you are trying to run, general system information, or both. If you list one or more programs on the command line, it will diagnose the runtime environment of that program or programs. If you specify the -s option, it will give general system information. If you specify -s and list one or more programs on the command line, it reports on both.

The cygcheck program should be used to send information about your system to Cygnus for troubleshooting (if your support representative requests it). When asked to run this command, include all the options plus any commands you are having trouble with, and save the output so that you can mail it to Cygnus, like this:

C:\Cygnus> cygcheck -s -v -r -h > tocygnus.txt

The -v option causes the output to be more verbose. What this means is that additional information will be reported which is usually not interesting, such as the internal version numbers of DLLs, additional information about recursive DLL usage, and if a file in one directory in the PATH also occurs in other directories on the PATH.

The -r option causes cygcheck to search your registry for information that is relevent to Cygnus programs. These registry entries are the ones that have "Cygnus" in the name. If you are paranoid about privacy, you may remove information from this report, but please keep in mind that doing so makes it harder for Cygnus to diagnose your problems.

The -h option prints additional helpful messages in the report, at the beginning of each section. It also adds table column headings. While this is useful information, it also adds some to the size of the report, so if you want a compact report or if you know what everything is already, just leave this out.

cygpath

Usage: cygpath [-p|--path] (-u|--unix)|(-w|--windows) filename
       cygpath [-v|--version]
  -u|--unix     print UNIX form of filename
  -w|--windows  print Windows form of filename
  -p|--path     filename argument is a path
  -v|--version  print program version

The cygpath program is a utility that converts Windows native filenames to Cygwin POSIX-style pathnames and back. It can be used when a Cygwin program needs to pass a file name to a native Windows program, or expects to get a file name from a native Windows program. You may use the long or short option names interchangeably, even though only the short ones are described here.

The -u and -w options indicate whether you want a conversion from Windows to UNIX (POSIX) format (-u) or a conversion from UNIX (POSIX) to Windows format (-w). You must give exactly one of these. To give neither or both is an error.

The -p option means that you want to convert a path-style string rather than a single filename. For example, the PATH environment variable is semicolon-delimited in Windows, but colon-delimited in UNIX. By giving -p you are instructing cygpath to convert between these formats.

Example 3-5. Example cygpath usage

#!/bin/sh
for i in `echo *.exe | sed 's/\.exe/cc/'`
do
  notepad `cygpath -w $i`
done

kill

Usage: kill [-sigN] pid1 [pid2 ...]

The kill program allows you to send arbitrary signals to other Cygwin programs. The usual purpose is to end a running program from some other window when ^C won't work, but you can also send program-specified signals such as SIGUSR1 to trigger actions within the program, like enabling debugging or re-opening log files. Each program defines the signals they understand.

Note that the "pid" values are the Cygwin pids, not the Windows pids. To get a list of running programs and their Cygwin pids, use the Cygwin ps program.

To send a specific signal, use the -signN option, either with a signal number or a signal name (minus the "SIG" part), like these examples:

Example 3-6. Specifying signals with the kill command

$ kill 123
$ kill -1 123
$ kill -HUP 123

Here is a list of available signals, their numbers, and some commentary on them, from the file <sys/signal.h>, which should be considered the official source of this information.

SIGHUP       1    hangup
SIGINT       2    interrupt
SIGQUIT      3    quit
SIGILL       4    illegal instruction (not reset when caught)
SIGTRAP      5    trace trap (not reset when caught)
SIGABRT      6    used by abort
SIGEMT       7    EMT instruction
SIGFPE       8    floating point exception
SIGKILL      9    kill (cannot be caught or ignored)
SIGBUS      10    bus error
SIGSEGV     11    segmentation violation
SIGSYS      12    bad argument to system call
SIGPIPE     13    write on a pipe with no one to read it
SIGALRM     14    alarm clock
SIGTERM     15    software termination signal from kill
SIGURG      16    urgent condition on IO channel
SIGSTOP     17    sendable stop signal not from tty
SIGTSTP     18    stop signal from tty
SIGCONT     19    continue a stopped process
SIGCHLD     20    to parent on child stop or exit
SIGCLD      20    System V name for SIGCHLD
SIGTTIN     21    to readers pgrp upon background tty read
SIGTTOU     22    like TTIN for output if (tp->t_local&LTOSTOP)
SIGIO       23    input/output possible signal
SIGPOLL     23    System V name for SIGIO
SIGXCPU     24    exceeded CPU time limit
SIGXFSZ     25    exceeded file size limit
SIGVTALRM   26    virtual time alarm
SIGPROF     27    profiling time alarm
SIGWINCH    28    window changed
SIGLOST     29    resource lost (eg, record-lock lost)
SIGUSR1     30    user defined signal 1
SIGUSR2     31    user defined signal 2

mkgroup

usage: mkgroup <options> [domain]
This program prints group information to stdout
Options:\n");
    -l,--local           print pseudo group information if there is
                         no domain
    -d,--domain          print global group information from the domain
                         specified (or from the current domain if there is
                         no domain specified)
    -?,--help            print this message

The mkgroup program can be used to help configure your Windows system to be more UNIX-like by creating an initial /etc/group substitute (some commands need this file) from your system information. It only works on NT. To initially set up your machine, you'd do something like this:

Example 3-7. Setting up the groups file

$ mkdir /etc
$ mkgroup > /etc/group

Note that this information is static. If you change the group information in your system, you'll need to regenerate the group file for it to have the new information.

The -d and -l options allow you to specify where the information comes from, either the local machine or the default (or given) domain.

mkpasswd

Usage: mkpasswd [options] [domain]
This program prints a /etc/passwd file to stdout
Options are
   -l,--local              print local accounts
   -d,--domain             print domain accounts (from current domain
                           if no domain specified
   -g,--local-groups       print local group information too
   -?,--help               displays this message
This program does only work on Windows NT

The mkpasswd program can be used to help configure your Windows system to be more UNIX-like by creating an initial /etc/passwd substitute (some commands need this file) from your system information. It only works on NT. To initially set up your machine, you'd do something like this:

Example 3-8. Setting up the passwd file

$ mkdir /etc
$ mkpasswd > /etc/passwd

Note that this information is static. If you change the user information in your system, you'll need to regenerate the passwd file for it to have the new information.

The -d and -l options allow you to specify where the information comes from, either the local machine or the default (or given) domain.

passwd

Usage passwd [name]
      passwd [-x max] [-n min] [-i inact] [-L len] 
      passwd {-l|-u|-S} name
  -x max   set max age of passwords
  -n min   set min age of passwords
  -i inact disables account after inact days of expiry
  -L len   set min password length
  -l       lock an account
  -u       unlock an account
  -S       show account information

passwd changes passwords for user accounts. A normal user may only change the password for their own account, the administrators may change the password for any account. passwd also changes account information, such as password expiry dates and intervals.

Password Changes: The user is first prompted for their old password, if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The administrators are permitted to bypass this step so that forgotten passwords may be changed.

The user is then prompted for a replacement password. passwd will prompt again and compare the second entry against the first. Both entries are require to match in order for the password to be changed.

After the password has been entered, password aging information is checked to see if the user is permitted to change their password at this time. If not, passwd refuses to change the password and exits.

Password expiry and length: The password aging information may be changed by the administrators with the -x, -n and -i options. The -x option is used to set the maximum number of days a password remains valid. After max days, the password is required to be changed. The -n option is used to set the minimum number of days before a password may be changed. The user will not be permitted to change the password until min days have elapsed. The -i option is used to disable an account after the password has been expired for a number of days. After a user account has had an expired password for inact days, the user may no longer sign on to the account. Allowed values for the above options are 0 to 999. The -L option sets the minimum length of allowed passwords for users, which doesn't belong to the administrators group, to len characters. Allowed values for the minimum password length are 0 to 14. In any of the above cases, a value of 0 means `no restrictions'.

Account maintenance: User accounts may be locked and unlocked with the -l and -u flags. The -l option disables an account. The -u option re-enables an account.

The account status may be given with the -S option. The status information is self explanatory.

Limitations: User's may not be able to change their password on some systems.

mount

Usage mount [-bf] <dospath> <unixpath>
      mount --reset
      mount
  -b   text files are equivalent to binary files (newline = \n)
  -f   force mount, don't warn about missing mount point directories
To reset the mount table use: mount --reset

The mount program is used to map your drives and shares onto the simulated POSIX directory tree, much like as is done by the POSIX mount command.

Normally, you'd just give the DOS/Windows equivalent path and where you want it to show up in the simulated POSIX tree, like these examples:

Example 3-9. Mounting filesystems

C:\Cygnus\> mount c:\ /
C:\Cygnus\> mount c:\Cygnus\98r2\bin /bin
C:\Cygnus\> mount -b d:\ /usr/data
C:\Cygnus\> mount e:\mystuff /mystuff

bash$ mount 'c:\' /

If you just type mount with no parameters, it will display the current mount table for you. Using --reset will reset the mount table to its default set of entries, which may include floppy and tape drives and such.

Limitations: there is a hard-coded limit of 30 mount points.

ps

Usage ps [-aefl] [-u uid]
  -f       show process uids, ppids
  -l       show process uids, ppids, pgids, winpids
  -u uid   list processes owned by uid
  -a, -e   show processes of all users

The ps program gives the status of all the Cygwin processes running on the system (ps = "process status"). Due to the limitations of simulating a POSIX environment under Windows, there is little information to give. The PID column is the process ID you need to give to the kill command. The WINPID column is the process ID that's displayed by NT's Task Manager program.

umount

Usage: umount <path>

The unmount program removes a mount from the system. You may specify either the Windows path or the POSIX path. See the mount program for information about the mount table.