<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>cygwin on 张戈博客</title><link>https://zhang.ge/tag/cygwin/</link><description>Recent content in cygwin on 张戈博客</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Sun, 02 Mar 2014 04:03:03 +0000</lastBuildDate><atom:link href="https://zhang.ge/tag/cygwin/index.xml" rel="self" type="application/rss+xml"/><item><title>Cygwin：Windows下的Linux终端模拟器</title><link>https://zhang.ge/cygwin-linux-terminal-on-windows.html</link><pubDate>Mon, 24 Feb 2014 13:12:48 +0000</pubDate><guid>https://zhang.ge/cygwin-linux-terminal-on-windows.html</guid><description>&lt;img src="https://zhangge.net/img/uploads/2014/02/cygwin.png" alt="Featured image of post Cygwin：Windows下的Linux终端模拟器" /&gt;&lt;p&gt;提到 Linux 学习，可能很多童鞋都会说，不是我不想学，而是真的没有一个好的 linux 环境：装了 linux 吧，有时又会想回 Windows 玩玩游戏娱乐什么的，搞个双系统吧，又不想折腾！如果真是这样，下面的内容将让你的理由统统成为借口。想学习 Linux 基本命令又不想安装 Linux 系统的童鞋请往下看。&lt;/p&gt;&#10;&lt;p&gt;虽说 Linux 是学习 Bash Shell 的天然环境，但是我们可以借助工具，在 Windows 下运行 bash。最著名的工具是 Cygwin，它是模拟类 UNIX 环境的软件，最初由 Cygnus Solution 公司开发，目的在于通过重新编译将 Linux 系统上的软件移植到 Windows 上。&lt;a class="link" href="https://zhangge.net/img/uploads/2014/02/cygwin.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="cygwin" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/02/cygwin.png"&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;安装 Cygwin 需要到&lt;a class="link" href="http://www.cygwin.com/" target="_blank" rel="noopener"&#10; &gt;官网&lt;/a&gt;下载安装包。在该网站首页的 Current Cygwin DLL version 中找到 setup.exe 并下载。该安装程序只是一个“外壳”，或者可以被称为 Cygwin 的安装器，因为该文件只有不到 1MB 的大小。下面是官方的安装步骤：&lt;/p&gt;&#10;&lt;h2 id="下载-setupexe"&gt;&lt;strong&gt;下载 setup.exe&lt;/strong&gt;&#10;&lt;/h2&gt;&lt;p&gt;安装 Cygwin，您需要下载 setup.exe，此程序根据您选择的软件包，再从互联网下载所有组件。&lt;/p&gt;&#10;&lt;p&gt;&lt;div class="file_download"&gt;&#10; &lt;div type="button" class="getit"&gt;&lt;a href="http://cygwin.com/setup-x86.exe" target="_blank" rel="nofollow noopener"&gt;&lt;span&gt;地址一&lt;/span&gt;&lt;span&gt;点击下载&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&#10; &lt;div type="button" class="getit"&gt;&lt;a href="http://pan.baidu.com/s/1i3KbtTN" target="_blank" rel="nofollow noopener"&gt;&lt;span&gt;地址二&lt;/span&gt;&lt;span&gt;点击下载&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&#10;&lt;/div&gt;&lt;a href="http://cygwin.com/setup.exe"&gt;&#10;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="安装"&gt;&lt;strong&gt;安装&lt;/strong&gt;&#10;&lt;/h2&gt;&lt;p&gt;1.双击 setup-x86.exe&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://zhangge.net/img/uploads/2014/02/a0f848942ce863cf53c0fa6cc684007d.png" target="_blank" rel="noopener"&#10; &gt;&lt;img loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/02/a0f848942ce863cf53c0fa6cc684007d.png"&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;2.按照安装提示“下一步”&lt;/p&gt;&#10;&lt;p&gt;3.选择从“互联网”安装：&lt;/p&gt;&#10;&lt;p&gt;&lt;img loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/02/36cd38f49b9afa08222c0dc9ebfe35eb.png"&gt;&lt;/p&gt;&#10;&lt;ol start="4"&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;选择安装的路径，一般是 C:\Cygwin，选择本地临时目录，用于存放下载的软件；选择您连接互联网的方式，一般选“直接连接”就可以了。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;选择下载源：（本站已不再提供镜像，请选择 163 镜像）&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;&lt;img loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/02/27e9549628eb6ff8b839ecb5ecd64476.png"&gt;&lt;/p&gt;&#10;&lt;p&gt;6.根据安装提示，选择需要安装的软件包，完成安装。&lt;/p&gt;&#10;&lt;h2 id="使用"&gt;&lt;strong&gt;使用&lt;/strong&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;双击桌面的 Cygwin 图标，即可启动 Cygwin 里的 Bash。&lt;/li&gt;&#10;&lt;li&gt;或者，你可将 C:/Cygwin/bin 加到 %PATH% 当中，您就可以直接在 cmd.exe 里面使用 Linux 命令了，比如 less, cat, wc , wget&lt;/li&gt;&#10;&lt;li&gt;如果您有一个 Bash 脚本，您可以直接用 C:/Cygwin/bin/bash.exe X:/scripts/Monitor.sh 的形式调用。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;已经安装了之后，在桌面启动 Cygwin Terminal 后出现如图终端窗口：&#10;&lt;a class="link" href="https://zhangge.net/img/uploads/2014/02/cngwin1.png" target="_blank" rel="noopener"&#10; &gt;&lt;img alt="cngwin1" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://zhangge.net/img/uploads/2014/02/cngwin1.png"&gt;&lt;/a&gt;&#10;率先测试了一下编辑器功能，可能使用了默认选项，未安装 vim，只好测试下 vi 了。发现了方向键和回车键无法正常工作，在 option 中看了半天没能解决之后，只好问下搜索引擎，问题才得到了解决：&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;原来 vim 缺省是 vi 兼容模式，设置成不兼容模式就好了：&#10;在 vi 中按下 esc 进入命令模式，然后输入下面命令回车即可（注意是英文冒号）&#10;`:set nocp`&#10;&lt;/blockquote&gt;&#10;设置好了，随便输入内容试试：&#10;[![cngwin2](https://zhangge.net/img/uploads/2014/02/cngwin2.png)](https://zhangge.net/img/uploads/2014/02/cngwin2.png)&#10;使用 wq 保存并退出后，用 sh 执行刚刚这个简单的打印脚本：&#10;[![cngwin3](https://zhangge.net/img/uploads/2014/02/cngwin3.png)](https://zhangge.net/img/uploads/2014/02/cngwin3.png)&#10;好了，这个模拟工具就介绍到这，想学 linux 的童鞋可以边看鸟哥的私房菜边使用这个工具先练练手，要真正学习 linux，个人还是建议安装个正统的 Linux 系统学习下比较好，比如 Redhat 或 Centos 等。&#10;</description></item></channel></rss>