发新话题
打印

【转帖】【推荐】在win下打造linux环境: cygwin的安装和简单配置

【转帖】【推荐】在win下打造linux环境: cygwin的安装和简单配置

[转载]在win下打造linux环境: cygwin的安装和简单配置

文章作者:lifesinger
信息来源:CCF

windows和linux各有其优越性,可以安装在同一台电脑上,但切换要重启。同时拥有两台电脑,一台装win,一台装linux,自然非常好,但具备此条件的不多。本文介绍cygwin,它可以让你在win下拥有linux开发环境,并且不用切换。

简单的讲述一下cygwin的安装和配置,入门级教程,还请各位高手指点一二。

首先到http://www.cygwin.com下载setup.e ... tup.exe放到此目录,

点击运行,Next->

选Install from Internet,Next->

填写Root Directory,如X:\cygwin,Next->

填写Local Package Directory,如X:\cygwin\ftp,Next->

选Direct Connection,Next->

选一个较快的ftp,Next->

到了关键步骤,如果仅想安装基本系统,直接Next;如果想完整安装,则点击All旁边的旋转状图标,将Default切换至Install;如果和我一样,仅想在命令行下写写程序,则只要将 gcc、make等开发工具选上,还有openssh等;选好后,Next->

开始下载,Take a coffee break。回来后,Next->

选择需不需要创建快捷方式。->END

点击快捷方式或X:\cygwin\cygwin.bat打开控制台,如果是域用户,按照提示makepasswd和makegroup即可。下面说一些简单的调整和配置。

一、ssh的安装

cygwin自带的控制台可调参数很少,舒适度较低。有没有办法用熟悉的putty或secureCRT来操控cygwin呢?办法有二:

1、用puttycyg。地址是http://gecko.gc.maricopa.edu/~me ... 谂渲枚曰翱蛑校琱ost name填 bash --login -i 即可。cygwin bash shell能做的,puttycyg基本上都能实现,本地操作的话,极力推荐这款好软件。

2、安装sshd,然后本机登陆。如果安装时已选择openssh,按照下面的操作继续。如果忘了安装,点击setup.exe,选上openssh,再装一次即可。

a、右键“我的电脑”->属性->高级->环境变量,在系统环境变量里添加变量CYGWIN,值为netsec tty,然后在Path里追加X:\cygwin\bin

b、打开cygwin控制台,输入ssh-host-config,一路yes,提示CYGWIN值时,输入netsec tty

c、启动sshd服务用: net start sshd 或 cygrunsrv --start sshd; 停止sshd服务用:net stop sshd 或 cygrunsrv --stop sshd

d、用ssh yourname@127.0.0.1 或 ssh localhost登陆

e、还可以继续安装配置sftp、scp等,就不细说了

f、每次输入密码登陆太麻烦,可以用key验证: 用puttygen.exe生存密钥对,然后在~/下,建立.ssh目录,创建authorized_keys2文件,将公钥复制到这个文件,然后在putty里指定私钥登陆,一劳永逸。

二、vim的简单配置

将\usr\share\vim\vim64目录下的vimrc_example.vim复制到~/,重命名为_vimrc, 按照自己的喜好修改里面的配置即可,如打开高亮,选择喜欢的colorscheme

三、cygwin的中文显示和输入

让bash命令行支持中文输入,vi ~/.inputrc,将下面几行的注释去掉:
set meta-flag on
set convert-meta off
set input-meta on
set output-meta on

让ls命令支持中文显示,vi ~\.bashrc中,修改:
alias ls='ls -hF --show-control-chars --color=tty'

vim64的话,已经支持中文输入。

四、sdcv的安装配置

坐在电脑前久了,屏幕太亮,辐射大,对身体不好。能不能在全黑的命名行模式下工作和学习呢?putty可以很好的全屏幕显示,sdcv则可以让你在命令行模式查找单词。

安装: 到stardict主页下载sdcv和想要的字典,编译安装后,将字典解压,放到/usr/share/startdict/dic目录

使用: sdcv word,就这么简单。小技巧: 可以在~/.bashrc里alias sdld='sdcv -u langdao'等等,这样可以避免词典太多,直接sdld word就可以用郎道字典查询。

五、结语

有了gcc、vim和sdcv,基本上就可以全屏幕工作了。老板来了,还以为你在linux下呢,嘿嘿

cygwin下还有很多好玩的程序,慢慢发掘吧……      
面包会有的 女人也会有的
_______________________

TOP

What Is Cygwin?

Cygwin is a Linux-like environment for Windows. It consists of two parts:
A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
A collection of tools, which provide Linux look and feel.
The Cygwin DLL works with all non-beta, non "release candidate", ix86 32 bit versions of Windows since Windows 95, with the exception of Windows CE.

What Isn't Cygwin?
Cygwin is not a way to run native linux apps on Windows. You have to rebuild your application from source if you want it to run on Windows.
Cygwin is not a way to magically make native Windows apps aware of UNIX ® functionality, like signals, ptys, etc. Again, you need to build your apps from source if you want to take advantage of Cygwin functionality.      
面包会有的 女人也会有的
_______________________

TOP

What's New and How Do I Get it?
The latest net releases of the Cygwin DLL are numbered 1.n.x, where "n" is currently "5" (e.g., 1.5.19). Any cygwin program built from December 1998 onward should work correctly with 1.n.x DLLs.

The 1.n.x version numbering refers only to the Cygwin DLL. Individual packages like bash, gcc, less, etc. are released independently of the DLL. The setup.exe utility tracks the versions of all installed components and provides the mechanism for installing or updating everything available from this site for Cygwin.

Run setup.exe any time you want to update or install a cygwin package.

Note that, when installing packages for the first time,h setup.exe does not select everything by default. Only the minimal base packages from the cygwin distribution are installed by default. When running setup.exe, clicking on categories and packages in the package installation screen will provide you with the ability to control what is installed or updated. Clicking on the "Default" field next to the "All" category will provide you with the opportunity to install every Cygwin package. Be advised that this will download and install hundreds of megabytes to your computer. The best plan is probably to click on individual categories and install either entire categories or packages from the categories themselves.

Once you've installed your desired subset of the Cygwin distribution, setup.exe will remember what you selected so rerunning the program will update your system with any new package releases.      
面包会有的 女人也会有的
_______________________

TOP

下载
http://cygwin.com/setup/

主站
http://www.cygwin.com/      


面包会有的 女人也会有的
_______________________

TOP

发新话题
最近访问的版块