Zurück

Free Unix Tools (ssh, bash, etc) under Windows


The Cygwin tools are ports of the popular GNU development tools for Windows 9x/ME/NT/2000. They run thanks to the Cygwin library which provides the UNIX system calls and environment these programs expect. For example you find the popular Commandline Secure Shell Tools (SSH) to create a secure terminal emulation from Windows to Unix systems.

The following packages are available with the current release: 

ash autoconf automake bash binutils bison byacc bzip2 clear cpio crypt cvs cygrunsrv cygwin dejagnu diff expect file fileutils findutils flex gawk gcc gdb gdbm gettext ghostscript gperf grep groff gzip inetutils irc jbigkit jpeg less libpng login lynx m4 make man mingw mt mutt ncftp ncurses newlib-man opengl openssh openssl patch pcre perl popt postgresql python readline regex rxvt sed sh-utils squid ssmtp tar tcltk tcsh termcap tetex-beta texinfo textutils tiff time unzip vim w32api wget which xpm xpm-nox zip zlib

Installation

This will then download the list of available packages, and offer to install them for you. There are a number of options within setup to control installation details.

  • Choose "Download from Internet to Current Directory" from the setup Program

The selected packages are now downloaded to your local drive.

  • Choose "Install from Current Directory" from the setup Program

 When installing, you will have to specify:

- Install root directory (e.g. D:\cygwin)
- Default Text File Type ("DOS" or "Unix")
- Install For ("All" or "Just Me")

Configuration Tips

  • Make sure you have set the HOME environment variable (e.g. C:\Home\Zahn)

  • Check and add your mounts with

mount

D:\Cygwin\bin on /usr/bin type system (binmode)
D:\Cygwin\lib on /usr/lib type system (binmode)
D:\Cygwin on / type system (binmode)
c: on /cygdrive/c type user (binmode,noumount)
d: on /cygdrive/d type user (binmode,noumount)
e: on /cygdrive/e type user (binmode,noumount)

If you need additional mount points create the directories and mount them e.g.

mount c:/uxhome /home/zahn

  • Check the automatically created mount points

The setup program will setup the needed mount points automatically. You can find them in the Windows registry under

HKEY_CURRENT_USER\Software\Cygnus\Cygwin\mounts v2
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus\Cygwin\mounts v2

  • How to use Device Files for tar ?

There is no need to create a POSIX /dev directory as it is simulated within Cygwin automatically. It supports the following devices: /dev/null, /dev/zero, /dev/tty, /dev/ttyX, /dev/ptmx, /dev/comX (the serial ports), /dev/windows (the windows message queue), /dev/random and /dev/urandom. These devices cannot be seen with the command ls /dev although commands such as ls /dev/tty work fine.

The Win32 device name for a partition is the drive letter with leading \\.\, so the floppy would be \\.\A:, the first partition typically \\.\C:. Complete drives (except floppies and CD-ROMS which are supported as partitions only) are named \\.\PHYSICALDRIVEx. The x is the drive number which you can check in the disk manager. Each drive line has prepended the text "Disk x".

To access tape drives the Win32 file name \\.\TAPEx is used. For example the first installed tape device is named \\.\tape0.

The naming convention is simple: The name of the POSIX device has to begin with /dev/ and the rest is as you like. The only exception are tape devices. To identify if the tape device is used as a rewind or a no-rewind device the name must not begin with n (rewind) or has to begin with n (no-rewind).

Some examples:

mount -b //./A: /dev/fd0 # mount floppy as raw block special
mount -b //./tape0 /dev/st0 # mount 1. tape as rewind device
mount -b //./tape0 /dev/nst0 # ...and as the no-rewind device

Note the usage of the -b option. It is best to include the -b option when mounting these devices to ensure that all file I/O is in "binary mode". Enter -s option to add mount point to system-wide registry location.

Now you can use tar as follows:

tar xvf /dev/st0 <dir>

  • Create and copy .bashrc to $HOME

The BASH shell can be configured with the configuration file $HOME/.bashrc (e.g)

# Aliases
alias more=less
alias up='cd ..'
alias ll='ls -la'
alias ls='ls -F'
alias ps='ps -Wl'
alias home='cd $HOME'
alias which='type -path'
alias unix2dos='recode lat1:ibmpc'
alias dos2unix='recode ibmpc:lat1'
alias h='history'

# Make Bash 8bit clean
set meta-flag on
set convert-meta off
set output-meta on
set completion-ignore-case on

# Set Prompt
PS1="`tput smso``whoami`@\h>`tput rmso` "
export PS1
PS2="> "
export PS2

  • Start BASH and enjoy the Unix Tools like SSH, SCP etc.

zahn@SMARAGD>ssh dbhost.akadia.com

We suggest to set the TERM variable for programs (e.g. vi) which use a correct terminal emulation to the following values:

Linux: TERM=linux; export TERM
Sun: TERM=ansi; export TERM

Example

The following screenshots shows a secure terminal emulation (SSH) from Windows to Unix using Cygwin's bash shell. The bash shell, like many other Unix utilities is ported to Windows.