通过终端安装apt-cyg之前选要安装以下软件包

wget
tar
gawk
bzip2

Cygwin终端安装

wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg -P /bin
chmod.exe +x /bin/apt-cyg
去googlecode手工下载安装
svn --force export http://apt-cyg.googlecode.com/svn/trunk/ /bin/
chmod +x /bin/apt-cyg
去github手工下载安装
https://codeload.github.com/transcode-open/apt-cyg/zip/master
解压到用户目录
mv apt-cyg /bin/
chmod +x /bin/apt-cyg

 

 

apt-cyg使用

apt-cyg install : to install packages

apt-cyg remove : to remove packages

apt-cyg update: to update setup.ini

apt-cyg show: to show installed packages

apt-cyg packageof : to locate parent packages

apt-cyg find : to find packages matching patterns

*apt-cyg describe : to describe packages matching patterns</PATTERN(S)></PATTERN(S)>


apt-cyg配置

*配置安装源

apt-cyg -m http://mirrors.163.com/cygwin/

export LANG="zh_CN.GBK"

alias ls="ls --color=auto"
alias dir="ls --color=auto" export PS1="\[\e]0;\w\a\]\[\e[32m\]\u@\h:\[\e[33m\]\w\[\e[0m\]\$ " alias ..="cd .." alias ...="cd ..." $ apt-cyg install wget
You must install wget, tar, gawk, xz and bzip2 to use apt-cyg.

Cygwin使用

(转自)http://w.gdu.me/wiki/cygwin/index.html

Update: 2013-01-04

常用软件安装

  • 安装Cygwin时,应安装上:wget, tar, gawk, bzip2, nc, xz, openssh

安装apt-cyg

  • 修改x86/x86_64源、xz压缩包支持的apt-cyg:apt-cyg

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    wget http://w.gdu.me/wiki/files/shell/apt-cyg
    chmod +x apt-cyg
    mv apt-cyg /usr/local/bin/
    apt-cyg --help
    cygcheck --help
    # 修改软件源
    apt-cyg --mirror http://mirrors.163.com/cygwin
     

  • 201308后Cygwin版本变更,需修改apt-cyg(使用上面已修改过的版本即可)
    • 软件源路径变更

      • 2013-08-08后Cygwin分为x86、x86_64两个安装包,源路径也改不同路径(x86、x86_64),因此apt-cyg下载setup.bz2和setup.ini时发生404错误。

        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        vim /usr/loccal/bin/apt-cyg
        # 将:
        wget -N $mirror/setup.bz2
        wget -N $mirror/setup.ini
        # 改为:
        wget -N $mirror/x86/setup.bz2
        wget -N $mirror/x86/setup.ini
        # 或:
        wget -N $mirror/x86_64/setup.bz2
        wget -N $mirror/x86_64/setup.ini

    • 添加xz压缩包支持
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      diff apt-cyg apt-cyg.bak
      353,358c353
      <     echo $file | grep ".xz$" >/dev/null 2>&1
      <     if [ "$?" = "0" ];then
      <       cat $file | xz -d | tar > "/etc/setup/$pkg.lst" xvf - -C /
      <     else
      <       cat $file | bunzip2 | tar > "/etc/setup/$pkg.lst" xvf - -C /
      <     fi
      ---
      >     cat $file | bunzip2 | tar > "/etc/setup/$pkg.lst" xvf - -C /

安装常用工具

1
2
3
# apt-cyg install man cygwin-doc
apt-cyg install vim screen wget subversion openssh pwgen gzip bzip2 curl rsync bash-completion \
 lftp nc tree p7zip connect-proxy util-linux bind-utils inetutils

安装python环境

1
apt-cyg install python python-crypto

常用工具设置

Cygwin终端

  • ~/.minttyrc

    1
    2
    3
    4
    5
    6
    7
    BoldAsFont=no
    Font=YaHei Consolas hybrid
    FontHeight=12
    #BackgroundColour=0,43,53
    BackgroundColour=11,22,33
    ForegroundColour=191,191,191
    FontSmoothing=full

  • 颜色、字体选择参数
    背景颜色:(RGB)0,40,51;或11,22,33(就是这个Wiki页面的背景色)
    字体颜色:(RGB)31,148,150(较暗);或191,191,191
    目录颜色:(RGB)255,128,128
    压缩文件颜色:(RGB)128,128,0 字体:Consolas,Courier New,Fixedsys,YaHei Consolas hybrid
  • YaHei Consolas hybrid.1.12字体下载:

bashrc

  • ~/.bashrc

    1
    2
    3
    4
    5
    6
    7
    8
    alias grep='grep --color'                     # show differences in colour
    alias egrep='egrep --color=auto'              # show differences in colour
    alias fgrep='fgrep --color=auto'              # show differences in colour
    alias ls='ls -hF --color=tty'                 # classify files in colour
    alias ll='ls -la'                             # long list
    alias la='ls -A'                              # all but . and ..
    alias l='ls -CF'                              #
    alias ssh="ssh -S none"

  • ~/.bash_profile

    1
    2
    3
    PS1="[\w]$"
    #彩色的PS1会造成命令编辑时光标定位错误
    #PS1="\e[0;32m[\u@\h \W]\$ \e[m"

screen设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# ~/.screenrc
#
# 启动时不显示欢迎屏幕
startup_message off
 
# 定义screen的功能键为Ctrl-A。向终端输入Ctrl-A时应按 Ctrl-A a。
#escape ^Aa
 
# 屏幕缓冲区 1024 行。
defscrollback 1024
 
# 显示窗口列表
caption always "%-w%{= BW}%50>%n %t%{-}%+w%<"
 
# 按 Ctrl-A w 或 Ctrl-A Ctrl-W 显示窗口列表
bind w windowlist -b
#bind ^w windowlist -b
 
#在使用screen过程中,经常会遇到“闪屏”的问题,这是可以关掉的。
#快速关掉:也就是先输入CTRL + a,再输入CTRL + g。
#永久关闭:修改/etc/screenrc 加入
vbell off

~/.vimrc

  • vim没有语法高亮,需加载基本设置

    1
    cd /usr/share/vim && cp vim74/vimrc_example.vim vimrc

  • .vimrc设置

详见:vimrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
" ~/.vimrc
set mouse=c
set nobackup
 
" set paste
 
set fileformats=unix,dos,mac
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set encoding=utf-8
" set termencoding=cp936
let &termencoding = &encoding
language messages en_US.UTF-8
"language messages zh_CN.UTF-8
 
" colo murphy
 
" tab
set tabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
" TAB -> Space
set expandtab

~/.ssh/config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ssh_config
#~/.ssh/config
IdentitiesOnly yes
ServerAliveInterval 60
GSSAPIAuthentication no
 
Host m*
    Port 22
    User root
    ControlMaster auto
    ControlPath ~/.ssh/master-%r@%h:%p
    #ProxyCommand connect-proxy -S 127.0.0.1:2223 %h %p
Host mNagios
    Hostname 172.16.16.150

其他设置

SSH Server

  • OS修改环境变量:path增加c:/cygwin/bin
  • OS增加环境变量:CYGWIN=ntsec tty
  • Cygwin安裝必要的套件:OpenSSH,cygrunsrv
  • Change permissions and ownership on some files:
    1
    2
    3
    4
    5
    6
    # 以下代码没测试过,慎用
    cd /; chmod -R og-w .
    chmod og+w /tmp
    touch /var/log/sshd.log
    chown system:system /var/log/sshd.log /var/empty /etc/ssh_h*
    chmod 755 /var/empty

  • Cygwin設定OpenSSH:
    1
    ssh-host-config

        Should privilege separation be used? (yes/no) :yes
    Should this script create a local user 'sshd' on this machine? (yes/no) :yes
    Do you want to install sshd as service? (yes/no) :yes
    Default is "ntsec" . CYGWIN=ntsec tty
  • 启动OpenSSH:net start sshd
    1
    cygrunsrv -S sshd

  • 停止OpenSSH:net stop sshd

crontab

  • 在Windows上安装系统服务 cron,开机即运行。

    1
    cygrunsrv -I cron -p /usr/sbin/cron -a -D

  • 启动服务
    1
    cygrunsrv -S cron

nontsec

这在 Cygwin 下创建的文件,其他管理员不可写,是所谓的 ntsec 在起作用。通过 NTFS 的权限设置,模拟 UNIX 的权限。可以通过 CYGWIN 环境变量修改。如:

1
export CYGWIN="nontsec nosmbntsec"

中文乱码设置

**若存在中文问题才进行以下设置。**

  • Rethat Cygwin安装后目录中文即正常,以下设置不一定需要。
  • ~/.bashrc
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    export SVN_EDITOR=vim
     
    # Redhat Cygwin中未做以下设置,中文正常
    alias ls='ls --color --show-control-chars'
    export LESSCHARSET=latin1
    alias less='/bin/less -r'
    #export LC_ALL=zh_CN.UTF-8
    #export LC_CTYPE=zh_CN.UTF-8
    #export LANG=zh_CN.UTF-8
    #export OUTPUT_CHARSET="GBK"
     
    #stty cs8 -istrip
    #stty pass8
     
    export CYGWIN="nontsec nosmbntsec"

  • ~/.inputrc

    1
    2
    3
    4
    5
    # Allow 8-bit input/output
    set meta-flag on
    set convert-meta off
    set input-meta on
    set output-meta on

技巧收集

  • Howto get version info?

    1
    cygcheck -c cygwin

  • 查看系统信息、软件包
    1
    2
    3
    4
    5
    cygcheck -h #帮助
    cygcheck -s #sysinfo
    cygcheck -l #已安装包列表
    cygcheck -c #列出并校验已安装的包
    cygcheck -p vim #从cygwin.com源查询包

  • 给curl安装CA Certificates
    1
    curl http://curl.haxx.se/ca/cacert.pem > /usr/ssl/certs/ca-bundle.crt

  • 同步Windows用户和组
    1
    2
    3
    4
    mkpasswd -l > /etc/passwd
    mkgroup -l > /etc/group
     
    # 如果有Domain的话,需要加上-d domainname

  • 设置Cygwin/mintty字体和大小
    • 界面中设置:右键菜单->Options->Text,然后选择你喜欢的字体和大小。
    • 如果没有你相要的字体,但Windows中有,可修改配置文件:~/.minttyrc,添加以下设置:
      BoldAsFont=no
      #Font=Courier New
      Font=YaHei Consolas hybrid
      FontHeight=12
  • 给Cygwin添加more/col/whereis等命令:安装util-linux包:apt-cyg install util-linux
  • 给Cygwin添加telnet/ftp工具:apt-cyg install inetutils
  • 给Cygwin安装dig命令
    • 安装bind-utils包:apt-cyg install bind-utils
    • 检查系统中已设置好DNS: ipconfig /all
  • 得到Windows格式的路径名?
    1
    cygpath -d -m "`pwd`"

  • 用Explorer打开当前目录
    1
    2
    3
    4
    5
    #!/bin/sh
    # openexplorer.sh
    d=$1;[ -z "$d" ] && d=$(pwd)
    d=$(cd "$d" > /dev/null 2>&1;pwd)
    Explorer /e,"$(cygpath -d -w $d)"

  • Cygwin error: -bash: fork: retry: Resource temporarily unavailable
    • http://stackoverflow.com/questions/9300722/cygwin-error-bash-fork-retry-resource-temporarily-unavailable
    • http://cygwin.wikia.com/wiki/Rebaseall
    • 错误现象
      -bash-4.1$ wc m1.txt
      3 [main] bash 2216 child_info_fork::abort: data segment start: parent(0x26D000) != child(0x38D000)
      -bash: fork: retry: Resource temporarily unavailable
      2013930 4027950 74968256 m1.txt
    • 处理办法
      rkosegi's Answer seems to be working for everyone (myself included). But, just so you don't have to follow the daisy chain of links:
      
      (assuming Cygwin is installed at C:\cygwin):
      
      1.Open Task Manager and close any processes that look to be Cygwin related.
      2.Open C:\Cygwin\bin in Windows Explorer
      3.Verify that dash.exe, ash.exe, rebase.exe, and rebaseall exist in this folder
      - If any of them are missing, re-run Cygwin setup and select the dash, ash, and rebase packages
      4.right-click your C:\Cygwin folder, uncheck Read-only (if its checked), and press OK.
      - When an error about not being able to switch some files comes up, select "Ignore All". Wait for this process to complete.
      5.Browse to C:\Cygwin\bin in Windows Explorer
      6.Right click dash.exe and click "Run as Administrator". A command Prompt should appear with nothing but a $
      7.Type /usr/bin/rebaseall -v, hit enter, and wait for the process to complete.
      - If you get errors about Cygwin processes running, try Step 1 again. If that still doesn't work, Restart your computer into safe mode and try these steps again.
      8.Try opening Cygwin again. This process worked for me. I hope it works for you guys too. Source: http://cygwin.wikia.com/wiki/Rebaseall

(转)cygwin包管理器apt-cyg的更多相关文章

  1. Cygwin的包管理器:apt-cyg

    参考<Cygwin的包管理器:apt-cyg> cygwin下安装每次需要启动set_up,比较蛋疼,还是debian的apt方便,在网上看到应该cygwin 下的apt,觉得不错. 从h ...

  2. Windows下安装Cygwin及包管理器apt-cyg(转)

    本文为转载文章: http://www.2cto.com/os/201212/176551.html Cygwin可以在Windows下使用unix环境Bash和各种功能强大的工具,对于Linux管理 ...

  3. [转]Cygwin的包管理器:apt-cyg

    [转]Cygwin的包管理器:apt-cyg http://zengrong.net/post/1792.htm Cygwin的包管理工具setup.exe实在是难用的让人蛋碎.于是就有了这样一个ap ...

  4. debian、ubuntu:使用apt包管理器可能存在的问题! 让新手望而却步!

    apt包管理器说好真好,说不好真不好. 最近在debian9.ubuntu18.04上安装oracle 10g 玩. 怎么都准备不好安装环境.原因就是i386构架体系的deb包总安装不正确! baid ...

  5. 关于Cygwin——包管理、替换默认终端、同MSYS的比较

    (搬运自我在SegmentFault的博客) Cygwin 是一个用于 Windows 的类 UNIX shell 环境. 它由两个组件组成:一个 UNIX API 库,它模拟 UNIX 操作系统提供 ...

  6. linux 各种发行版及包管理器的关系

    linux 各种发行版及包管理器的关系 Linux发行版列表 基于Kpkg(Debian 系) Debian GNU / Linux 及其派生发行版使用deb软件包格式,并使用dpkg及其前端作为包管 ...

  7. 在ubtuntu中使用包管理器 linux-brew

    用惯了mac的程序员回到linux开发平台总觉得有点不适应,这是因为linux的界面没有mac那么精美,而且linux的包管理器没有mac上面的homebrew那么强大.mac程序员遇到库的依赖问题时 ...

  8. Linux新手的最佳包管理器

    一个 Linux 新用户应该知道他或她的进步源自于对 Linux 发行版的使用,而 Linux 发行版有好几种,并以不同的方式管理软件包. 在 Linux开发 中,包管理器非常重要,知道如何使用多种包 ...

  9. Openresty 学习笔记(四)lualocks包管理器安装使用

    Luarocks是一个Lua包管理器,基于Lua语言开发,提供一个命令行的方式来管理Lua包依赖.安装第三方Lua包等,社区比较流行的包管理器之一,另还有一个LuaDist,Luarocks的包数量比 ...

随机推荐

  1. 笔记-reactor pattern

    笔记-reactor pattern 1.      reactor模式 1.1.    什么是reactor模式 The reactor design pattern is an event han ...

  2. NPM安装vue-cli,并创建vue+webpack项目模板

    1.安装npm npm 是node.js 的包管理工具, 安装流程地址:https://docs.npmjs.com/cli/install  估计会非常慢,我们可以使用淘宝NPM镜像下载安装:htt ...

  3. MySQL之查询性能优化(二)

    查询执行的基础 当希望MySQL能够以更高的性能运行查询时,最好的办法就是弄清楚MySQL是如何优化和执行查询的.MySQL执行一个查询的过程,根据图1-1,我们可以看到当向MySQL发送一个请求时, ...

  4. Pycharm的使用一

    一.编辑器的选择 Python 的学习过程少不了集成开发环境(IDE)或者代码编辑器,这些 Python 开发工具帮助开发者加快使用 Python 开发的速度,提高效率. 高效的代码编辑器或者 IDE ...

  5. 内部类inner class

    1.什么是内部类,为什么要用内部类? 可以将一个类定义在另一个类的定义内部,这就是内部类. 当描述事物时,事物的内部还有事物,该事物用内部类来描述,因为内部事物在使用外部事物的内容. 如: class ...

  6. laravel5.5任务调度

    目录 1. 定义调度 1.1 使用Closure 1.2 Artisan 命令调度 1.3 队列任务调度 1.4 Shell 命令调度 1.5 调度频率设置 1.6 闭包测试限制 1.7 避免任务重复 ...

  7. 剑指Offer - 九度1509 - 树中两个结点的最低公共祖先

    剑指Offer - 九度1509 - 树中两个结点的最低公共祖先2014-02-07 01:04 题目描述: 给定一棵树,同时给出树中的两个结点,求它们的最低公共祖先. 输入: 输入可能包含多个测试样 ...

  8. 《Cracking the Coding Interview》——第2章:链表——题目3

    2014-03-18 02:25 题目:给定一个单链表中间的节点,删掉那个节点. 解法:把后面节点的数据域拷到当前节点来,然后删除后面那个节点.当前节点不是尾巴,所以后面不为空. 代码: // 2.2 ...

  9. corosync.conf

    ##totem定义集群内各节点间是如何通信的,totem本是一种协议,专用于corosync专用于各节点间的协议,协议是有版本的 totem { ##版本号 version: ##安全认证on|off ...

  10. 第三节 MVC应用程序架构和测试

    在查看如何测试单个功能之后,您可能会问,整个Web应用程序如何? 如前所述,有以下级别的测试: 单元测试 集成测试 功能测试 在开始编写测试时考虑这一点很重要. 可能还有其他类型的测试,但现在让我们关 ...