Alec the Geek

mobile version http://alecthegeek.mofuse.mobi/

Top Tip: Installing Cygwin on Windows

Posted by Alec on 1 August 2008

If you are like me, a *nix user (sometimes) trapped in MS Windows land, then you’ll come to depend on the Cygwin utilities. Their use is pretty straight forward, but you can make life a little bit easier for yourself:

  • When installing Cygwin select the option for default UNIX / binary style line endings for files. When selecting DOS style text files I’ve had subsequent problems with Perl CPAN modules failing unit tests and bash failing to process login scripts
  • After the install issue a mount -c / command, this means that you can access drives without using the /cygdrive mount point (i.e. /c/Program\ Files instead of /cygdrive/c/Program\ Files)
  • NB This is not recommended practice, but for years I have been installing cygwin into the root of my C: drive, apparently without ill effects, and it does make life slightly easier. However you will need to modify startxwin.bat (and startxdmcp.bat if used) and make sure that the environment variable CYGWIN_ROOT is defined as an empty string.
  • Create a shortcut to invoke bash, I use “C:\bin\run.exe C:\bin\rxvt.exe -sl 2500 -fg lightblue -geometry 80x25 -bg midnightblue -sbt 10 -title bash -e /bin/xhere /bin/bash.exe %HOME%” (noting of course that I install into the root of the C: drive). You can also use chere to install a ‘Open Bash here’ option in Windows Explorer

Anyone else have anything to pass on?

6 Responses to “Top Tip: Installing Cygwin on Windows”

  1. Beware of chown and chmod. They really don’t work that well in Windows (in my experience). Instead, prefer Window’s own security mechanisms where possible.

  2. Alec said

    I didn’t think there were any? :-)

  3. They shouldn’t be that different, but I found on several occasions that I’d get whole directories (and volumes) inaccessible for no discernable reason other than some recent cygwin security settings.

    particular issue on removable media.

  4. Alec said

    Thanks Andrew. The interaction between Cygwin and Windows security is explored in the Cygwin docs site

  5. sinewalker said

    Here’s my top 5 list:

    1. You can fix /etc/passwd and /etc/group files so that the annoying errors displayed by Bash will go away:

    mkpasswd -l -c > /etc/passwd; mkgroup -l -d > /etc/group

    (this assumes only local users on the system will use cygwin, which is probably the case for most people).

    2. Learn about cygpath — very useful when interacting with Win32 programs from the bash prompt (e.g. java.exe)

    3. Adding other programs: just remember to use Cygwin’s own SETUP.EXE for adding and removing/upgrading Cygwin packages to your install. Usually if some command is not found (e.g. a compiler), you can find it there and install it. There are a whole slew of progs I couldn’t live without, but probably Midnight Commander (mc) is the top program to add. You’ll find it under the “shells” category.

    4. There is no “update-alternatives” like in Debian systems, but you can still simulate it with links, and there is an /etc/alternatives branch point. Use this for instance to change from Cygwin’s own emacs to a local copy if you’re playing with emacs 22.2 / 23… (i.e. /bin/emacs -> /etc/alternatives/emacs -> /usr/local/emacs22/bin/emacs.exe)

    5. I like to reserve X:\cygwin\usr\local for local cygwin programs, doc, info files etc, as you would in real *nix systems. This makes backups easier — no need to back up the whole cygwin tree. Also very easy to restore after a system rebuild.

  6. sinewalker said

    see also http://sinewalker.wordpress.com/tag/cygwin/

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>