Cygwin

From HalfgeekKB
Jump to navigation Jump to search

See also Unix commands.

When done with the initial setup, you might find some additional Cygwin utility scripts helpful.

Install a lot of packages using setup-*.exe

Cygwin setup can accept a list of packages at the command line. The setup itself is the same GUI as normal, but the indicated packages are pre-selected. If you know the package names already, this saves you the trouble of hunting them down individually.

   setup-ARCH.exe -q -P package1,package2,package3

Substitute x86 or x86_64 for ARCH, depending on the architecture target you're installing.

For example, this (as of 2016 Jan) installs a list of packages I tend to need:

   setup-x86_64.exe -q -P autoconf,autoconf2.1,autoconf2.5,automake,automake-1.10,automake-1.11,automake-1.12,automake-1.13,automake-1.14,automake-1.15,automake-1.4,automake-1.5,automake-1.6,automake-1.7,automake-1.8,automake-1.9,bash-completion,binutils,bzip2,bzr,cron,curl,dos2unix,flac,gcc-core,gcc-g++,git,git-completion,keychain,libstdc++6,libstdc++6-devel,libtool,lynx,libxml2,libxslt,make,mintty,nasm,ncurses,openssh,p7zip,perl,python,python-crypto,python-paramiko,rdiff,rsync,sox,stow,subversion,unzip,vim,wget,xz,zip,zlib0,zlib-devel

Make sure to install apt-cyg prerequisites with Cygwin installer

When installing Cygwin initially, make sure to install:

  • git
  • wget
  • xz
  • bz2

As long as these are installed, apt-cyg should be able to take care of the rest.

If you're not in a hurry to get the foundation laid down, check overhaul#Cygwin for other stuff you might decide you want while you have setup.exe open.

apt-cyg (Command-line package manager)

An excellent shell script exists that acts as a very apt-like package manager for Cygwin (which really should have it built in!).

Get the github branch:

mkdir -p /src &&
cd /src &&
git clone https://github.com/transcode-open/apt-cyg.git

Installation instructions:

cd /bin &&
ln -s /src/apt-cyg/apt-cyg &&
cd

To use,

apt-cyg find packagename
apt-cyg install packagename
apt-cyg remove packagename

do what you expect. Use no arguments for a usage rundown.

Cygwin ports

Cygwin ports is something like the "universe" package set for Cygwin.

What I thought would work

Simply use the -m option with apt-cyg (described above):

apt-cyg -m 'ftp://sourceware.org/pub/cygwinports' ...

Or freely substitute a mirror site instead.

See also the list of currently available ports.

Better information

apt-cyg's -m setting is apparently sticky, so to freely switch between the two you'll need to enter it every time.

I'm trying a slight variation of some general instructions to take care of this with my .bashrc:

alias apt-cyg='apt-cyg -m http://mirrors.kernel.org/sources.redhat.com/cygwin/' 
alias apt-cygports='apt-cyg -m http://mirrors.kernel.org/sources.redhat.com/cygwinports/'

Also, keep an eye on installs from cygports, which may depend on packages it won't install (because they are from the repository proper). Example

...
Installing libglib2.0-devel
Package libglib2.0-devel not found or ambiguous name, exiting
...

Solve this using

apt-cyg install libglib2.0-devel

cygpath

If you need to pass filename arguments from a Cygwin shell to Windows-native programs, you'll probably find cygpath useful.

Setting up some Cygwin services

Setting up cron

First, make sure cron is even installed. Apparently, it's not default. Look under "Admin".

Then, the prevailing command sequence is

cygrunsrv -I cron -p /usr/sbin/cron -a -D
net start cron

You'll then probably want to set it up to run updatedb from time to time so you can use the locate command.

Setting up sshd

Start with

ssh-host-config

Yes to privilege separation, yes to local user sshd, yes to install as a service, and default for how to set CYGWIN= at start.

Then,

net start sshd

If you only want to run the thing on localhost, comment any ListenAddress lines in sshd_config except one saying

ListenAddress 127.0.0.1

Permissions required to do that are something you can figure out. If you're really stumped, do it like this:

chmod go+w sshd_config
vim sshd_config
chmod go-w sshd_config

Make sure to add an inbound rule to Windows Firewall for the service's port (default 22, but can be changed in sshd_config) so that the service is accessible from the outside. (Otherwise, there will be helpful "Connection reset by peer" errors.)