When working on a Windows machine after spending years in Linux, Cygwin provides a POSIX-compatible environment where your custom .bashrc and .vimrc configurations work out of the box (see My Custom Linux Environment).

However, Cygwin does not ship with a built-in command-line package manager like apt-get or yum—adding packages normally requires re-running the graphical setup-x86_64.exe installer. apt-cyg solves this by providing a lightweight Bash wrapper that installs, searches, and removes Cygwin packages directly from the Cygwin terminal.


Step 1: Prerequisites

Before installing apt-cyg, ensure the following base packages were selected during initial Cygwin setup (setup-x86_64.exe):

  • wget
  • tar
  • gawk
  • bzip2
  • xz (required for modern .tar.xz Cygwin packages)

Step 2: Install apt-cyg

Inside your Cygwin terminal, download the apt-cyg script and install it into /bin:

wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
rm -f apt-cyg

Step 3: Install and Manage Packages with apt-cyg

Common apt-cyg Commands

# Search for a package in the Cygwin mirror catalog
apt-cyg find <pattern>

# Show package description and dependencies
apt-cyg show <package_name>

# Install packages
apt-cyg install nano
apt-cyg install lynx

# Remove an installed package
apt-cyg remove <package_name>

Example Output: Installing lynx

┌─[Zubair][AHMD-WRK-HORSE][~]
└─▪ apt-cyg install lynx
Installing lynx
--2016-09-28 12:49:39--  http://cygwin.mirror.constant.com//x86_64/release/lynx/lynx-2.8.7-2.tar.bz2
Resolving cygwin.mirror.constant.com (cygwin.mirror.constant.com)... 108.61.5.83
Connecting to cygwin.mirror.constant.com (cygwin.mirror.constant.com)|108.61.5.83|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1746879 (1.7M) [application/octet-stream]
Saving to: ‘lynx-2.8.7-2.tar.bz2’

lynx-2.8.7-2.tar.bz2           100%[==================================>]   1.67M   181KB/s    in 12s

2016-09-28 12:49:52 (146 KB/s) - ‘lynx-2.8.7-2.tar.bz2’ saved [1746879/1746879]

lynx-2.8.7-2.tar.bz2: OK
Unpacking...
Package lynx requires the following packages, installing:
bash cygwin libiconv2 libintl8 libncursesw10 libopenssl100 zlib0
Package bash is already installed, skipping
Package cygwin is already installed, skipping
Package libiconv2 is already installed, skipping
Package libintl8 is already installed, skipping
Package libncursesw10 is already installed, skipping
Package libopenssl100 is already installed, skipping
Package zlib0 is already installed, skipping
Running /etc/postinstall/lynx.sh
Package lynx installed

Alternative: Installing Packages via setup-x86_64.exe CLI Flags

Cygwin’s official setup-x86_64.exe binary also supports unattended command-line package installation (-q -P <package1>,<package2>):

setup-x86_64.exe -q -P nano,lynx,tmux,git

And on modern Windows 10 / Windows 11 machines, Windows Subsystem for Linux (WSL2) (wsl --install) provides a full Linux kernel and native distribution (apt, dnf, pacman) directly on Windows.

References