Dialog UNIX: Use Cygwin on Windows

Source: Internet
Author: User
Article Title: UNIX: Cygwin on Windows. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Is Cygwin used for Microsoft? Windows? Operating system UNIX? Environment. It contains a real UNIX shell, a Portable Operating System Interface (POSIX) simulation library, and thousands of UNIX utilities.

If you are a loyal reader of this column, you should be familiar with a lot of UNIX dialect. It is strange for new users to say "Redirect outputs with pipelines", "Kill processes", and "use wildcards", but you should be familiar with these statements.

 Common acronyms
  • API:Application Programming Interface
  • IT:Information Technology

UNIX itself is also called. IBM? Mainframe users speak a variety of slang words with the letter "z", such as IBM z/OS? And System z9 Virtual Machine (z/VM); Nested System developers use the word eCos; many other UNIX styles, such as Linux? , FreeBSD, Sun Solaris, and Mac OS X. Modern information technology uses a variety of dialects, just like the story of the babeta in the Bible.

Of course, there are also many people talking about Windows terms, although most people only master simple words such as "pointing and clicking. After 20 years of development, most Windows users have forgotten the old DOS terminology.

However, compared with the UNIX shell, the Windows COMMAND utility has poor functionality. Therefore, UNIX users generally think that Windows is a frustrating platform. For UNIX software developers who are used to using a rich set of command line tools, Windows is especially awkward. For UNIX developers, using Windows is like a stranger to a foreign country.

Fortunately, Cygwin (see references) provides a world that everyone is familiar with in a Windows environment, just as Americans have found McDonald's in France.

Cygwin is a UNIX-like shell environment for Windows. It consists of two components: a unix api library, which simulates many features provided by the UNIX operating system, as well as the Bash shell rewrite version and many UNIX utilities, they provide familiar UNIX Command Line interfaces. The previous component is a Windows dynamic link library (DLL ). The latter component is a set of Cygwin DLL-based programs, many of which are compiled with unmodified UNIX source code. They work together to provide a familiar UNIX environment.

In this session, we will install Cygwin, discuss its command line interface (CLI), and build open source code not included in the standard Cygwin release, how easy it is to migrate UNIX applications (at least a part of UNIX applications) to this simulated environment

 Version details

At the time of writing this article, the current version of Cygwin DLL is 1.5.25-15. Cygwin can be installed in any recent Windows business version, except Windows CE. (However, Cygwin will not support Windows 95, Windows 98, and Windows ME in the future ). The example and graph provided in this article are based on Windows XP Professional with Service Pack 3 (SP3). The computer used is an Apple MacBook in Coherence mode and uses Parallels version 3.0.


Install Cygwin

Unlike other software described here, Cygwin uses the Windows installer. In the Cygwin setup.exe file, you can reinstall the software and add, modify, or upgrade the Cygwin configuration components.

Open your browser on Windows and download the Cygwin installer by accessing the http://cygwin.com/setup.exe. The installer itself is very small (about KB) because most Cygwin software is downloaded during installation. After the download is complete, follow these steps to install Cygwin:

Run the installer. Figure 1 shows the Cygwin welcome screen.

Figure 1. The first dialog box that appears during Cygwin Installation

Click Next to go to the Next screen and select the installation type to be executed.
Click Install from Internet.
Click Next and select an installation directory.
The configuration and installation window is shown in figure 2.


Figure 2. Cygwin Installation Options

In most cases, the recommended installation options are suitable and can be customized, but pay attention to the following points:

Do not install Cygwin in the Windows root directory (such as C. It is best to install Cygwin in its own subdirectory, such as the default directory (C: \ cygwin) or C: \ Program Files \ cygwin. (The target directory you selected will be the root directory of the simulated UNIX environment /. For example, if you install it in C: \ cygwin, the virtual/usr/bin is actually C: \ cygwin \ usr \ bin ).
Do not select Just Me For the Install For option.
Set the Default Text File type to Unix to improve compatibility with existing files stored on other UNIX machines.
Click Next.
In the next window, select a directory for storing the data required by Cygwin. Do not select the Cygwin directory selected in the previous step. If possible, create or select a directory on a drive with at least 1 GB of free space.

Click Next again and select the Internet connection type to use. Select Direct Connection.
Click Next again.
Wait a moment, Cygwin will download the current image site list and let you select an image site, as shown in figure 3. If you are not sure which site to choose, select a site with a relatively close geographical location.


Figure 3. Select an installation site that you think is reliable or geographically close


After a short delay, the installer displays a complete list of available categories and packages. Figure 4 shows part of a category. Click the plus sign (+) to expand the corresponding category. Click the "loop" icon to cycle between Skip (ignore this package) and all available versions of the package. If Cygwin provides multiple versions of a utility, select an instance that meets your needs. By the way, if Column B is selected, the binary package is downloaded. If column S is selected, the source code is also downloaded.


Figure 4. select the most suitable package and instance

There are more than 1,000 packages available in Cygwin, so you should select only the type and package you need. (Installation of all Cygwin packages will occupy more than 800 MB of disk space ). You can add the entire category or package at any time: simply re-run the Cygwin installer. (You can also use the same installer to delete or update packages at any time ). Search for the Cygwin package list (see references) and check whether your favorite UNIX utility is available in Cygwin.

Select the required tool and click Next. The download process starts!
The progress bar displays the download progress, total download progress, and disk usage of each package. Figure 5 is a screen screenshot taken during installation on my test computer.


Figure 5. Cygwin downloads a large number of software, so please be patient


Finally, install the software and (optional) add shortcuts to the Start menu and desktop. Click Finish.

Use the Start Menu or double-click the Cygwin icon (if you have added these shortcuts) to Start Cygwin. You can also execute the Cygwin script in the Cygwin directory (for example, C: \ cygwin \ Cygwin. bat ).
Figure 6 shows the first time Cygwin was started: it creates your home directory and executes the shell Startup File, showing a prompt. Now you can run the UNIX Command!


Figure 6. Now you can use UNIX commands in Windows!

For example, try ls-a or type touch. The last command indicates that touch is an executable file/usr/bin/touch.

[1] [2] Next page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.