cygwin

最後更新: 2024-07-05

目錄

介紹

A large collection of GNU and Open Source tools.

cygwin provide functionality similar to a Linux distribution on Windows.

A DLL (cygwin1.dll) which provides substantial POSIX API functionality.

HomePage: https://www.cygwin.com/

Bundle Cygwin with my product for free

If you ship applications that link with cygwin1.dll,
you must either provide those applications' source code under a GPL-compatible license,
or purchase a cygwin license from Red Hat.

 


Install

 

# 32bit

https://cygwin.com/setup-x86.exe

# 64bit

https://cygwin.com/setup-x86_64.exe

 * By default, only install the minimal base packages

Installer 本身有 GUI

Default Install Path: "C:\cygwin" OR "C:\cygwin64"

Setup(Installer) accept command-line arguments

-h, --help

-q, --quiet-mode                 # 沒有加入它就會有 GUI 出現

-C, --categories                  # Specify entire categories to install

-L, --local-install                 # Install from local directory
-l, --local-package-dir         # Local package directory

-B, --no-admin                   # Do not check for and enforce running as Administrator

-D, --download

-O --only-site                   # Do not download mirror list. Only use sites specified with -s
-s --site                           # Download site URL, path or UNC path

 * The default is to both download and install packages (unless either --download or --local-install)

 

Installer Usage Example

# Check Version (-V, --version)

setup-x86_64.exe -V

Cygwin setup 2.932

# Downlad Package Only

setup-x86_64.exe -D -l C:\cygwin64\packages -O -s https://ftp.ntu.edu.tw/pub/cygwin/ -q

會在 C:\cygwin64\packages 建立

dir /b C:\cygwin64\packages

https%3a%2f%2fftp.ntu.edu.tw%2fpub%2fcygwin%2f
setup.log
setup.log.full

%2f = "/"

# Install package from local folder

setup-x86_64.exe -L -l C:\cygwin64\packages -q

查看有什麼 Package List

Website: http://cygwin.com/packages/

 

# Install package (Online)

# install rsync

setup-x86_64.exe -P rysnc -q

 

 


cygcheck

 

功能

cygcheck - List system information, check installed packages, or query package database.

Check Version

cygcheck -V

cygcheck (cygwin) 1.7.32

List Only (no verify)

-d, --dump-only

Sdhow installed version of PACKAGE and verify integrity

-c, --check-setup

cygcheck -c

Cygwin Package Information
Package                  Version            Status
_autorebase              000229-1           OK
_update-info-dir         00316-1            OK
alternatives             1.3.30c-10         OK
base-cygwin              3.3-1              OK
base-files               4.2-3              OK
bash                     4.1.11-2           OK

Produce diagnostic system information (implies -c -d)

# -s, --sysinfo

cygcheck -s

Cygwin Configuration Diagnostics
Current System Time: Sun Sep 21 09:00:55 2014

Windows 7 Ultimate Ver 6.1 Build 7601 Service Pack 1

Path:   C:\cygwin64\usr\local\bin
        C:\cygwin64\bin
        C:\Program Files (x86)\AMD APP\bin\x86_64
        C:\Program Files (x86)\AMD APP\bin\x86
        C:\Windows\system32
        C:\Windows
        C:\Windows\System32\Wbem
        C:\Windows\System32\WindowsPowerShell\v1.0
        C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
        C:\Python27

Output from C:\cygwin64\bin\id.exe
UID: 1000(tim)      GID: 513(None)
513(None)           0(root)             544(Administrators) 545(Users)
1001(HomeUsers)

SysDir: C:\Windows\system32
WinDir: C:\Windows

USER = 'tim'
PWD = '/home/tim'
HOME = '/home/tim'

Use '-r' to scan registry

...

package

-e, --search-package

-i, --info-package

 


Automated Cygwin installation

 

# -l downloaded package tree

setup-x86_64.exe -q -L -l x:\cygwin-local\

Help

setup-x86.exe --help

Opts

-q, --quiet
-X --no-verify                    
-n --no-shortcuts
-N --no-startmenu
-d --no-desktop

-D --download                 # Download from internet
-s --site

-L --local-install                # Install from local directory
-l --local-package-dir

-P --packages                  # Specify packages to install

Script:

SET SITE=http://cygwin.mirrors.pair.com/
SET LOCALDIR=%CD%
SET ROOTDIR=C:/cygwin
SET PACKAGES=rsync,wget

setup --quiet-mode --no-desktop --download --local-install --no-verify -s %SITE% -l "%LOCALDIR%" -R "%ROOTDIR%" -P %PACKAGES%

 


Cygwin service

 

# List all services

cygrunsrv -L

# stop

cygrunsrv --stop service_name

# remove

cygrunsrv --remove service_name

Cygserver

designed to run as a background service.

It provides Cygwin applications with services

 


Windows, Cygwin and UNIX path

 

Fold / File path

# Windows                        # Cygwin
C:\WORK\*          -->           /cygdrive/c/work/*

# convert path between Windows and UNIX

cygpath --unix C:/cygwin/bin/ls.exe

/usr/bin/ls.exe

 


Packages

 

Core Package

  •  

常用 Package

  • rsync
  •  

 


Old Version

 

Note that Cygwin version 2.5.2 was the last version supporting Windows XP and Server 2003.

The last version of Setup.exe to support XP is 2.874

 


Other

 

 

 

Creative Commons license icon Creative Commons license icon