3. FAQ3.1. Q Howto get version info?3.2. Q 安装注意事项3.3. Q Howto setup default text format, CRLF(dos) or LF(unix)?3.4. Q 为什么在 Cygwin 下创建的文件,其他管理员不可写?3.5. Q 如何让 ls 能够显示中文文件名?3.6. Q 如何在按 TAB 键进行文件名扩展时忽略大小写,这样在 Windows 下才方便噢?[Cygwin User's Guide]
Customizing bash
Three initialization files that control the behavior of bash: .profile, .bashrc and .inputrc.
.profile
It is executed when bash is started as login shell, e.g. from the command bash --login.建议
- 在 PATH 后加上 ":.",这样可以象在 DOS 下,执行本目录下程序;
.bashrc
.bashrc is similar to .profile but is executed each time an interactive bash shell is launched.
.inputrc
.inputrc controls how programs using the readline library (including bash) behave.
# Ignore case while completing set completion-ignore-case on # Make Bash 8bit clean set meta-flag on set output-meta on # to show 8-bit characters set convert-meta off # to show it as character, not the octal representation
但是并不能保证 ls 显示中文。因为这些工具不使用 readline 来显示。象 less 和 ls 需要特别设置。在 .bashrc 中加入如下 alias:
alias less='/bin/less -r' alias ls='/bin/ls -F --color=tty --show-control-chars'
3.7. Q 如何在 Cygwin 中运行 crontab?3.8. Q 配置 SSH client? 3.9. Q 如何在 cygwin 中运行 sshd (SSH Server)? 3.10. Q 如何在 cygwin 中配置 Email? 3.11. Q 如何得到 Dos/Windows? 格式的路径名?
如下:- 在Windows上安装系统服务 cron,开机即运行。
bash$ cygrunsrv -I cron -p /usr/sbin/cron -a -D
- 启动服务
bash$ cygrunsrv -S cron
- 为了能够通过公钥验证进行SSH登陆其他服务器,先要在本地建立 SSH 公钥私钥对:
bash$ ssh-keygen -t rsa1 bash$ ssh-keygen -t rsa bash$ ssh-keygen -t dsa
- 建立无口令登录
如下:
- 设置 Windows 环境变量,添加"CYGWIN = ntsec tty"
- Config SSHD, running:
bash$ ssh-host-config -y根据提示,输入 CYGWIN=ntsec tty
- Change permissions and ownership on some files:
bash$ cd /; chmod -R og-w . bash$ chmod og+w /tmp bash$ touch /var/log/sshd.log bash$ chown system:system /var/log/sshd.log /var/empty /etc/ssh_h* bash$ chmod 755 /var/empty
- start the service:
bash$ cygrunsrv -S sshd
As follows:
- ssmtp & mutt
- ssmtp
bash$ /usr/bin/ssmtp-config
When using mutt as the mail client, add the following line to your $HOME/.muttrc file:set sendmail="/usr/sbin/ssmtp"
- mutt
- Make sure you have the Cygwin ssmtp package installed
- vi .bashrc and/or .bash_profile
export MAIL=~/Mail/inbox export EDITOR=nano
If you have nano installed (and I stongly recommend that you do)- Create the following directory structure in your HOME directory:
~/Mail | -- inbox (EMPTY FILE, NOT DIRECTORY) | -- sent (EMPTY FILE, NOT DIRECTORY) | -- received (EMPTY FILE, NOT DIRECTORY) | -- postponed (EMPTY FILE, NOT DIRECTORY)
- Create a ~/.muttrc file that looks like this:
# The file/directory where your incoming mail will be spooled to # (same as 'set spoolfile' below) mailboxes ~/Mail/inbox # Mail account setup. I know nothing about IMAP, so you're # on your own there. set sendmail="/usr/sbin/ssmtp" #set pop_host="your.pop3.mail.server.com" #set pop_last=yes #set pop_user="your_email_username" #set pop_pass="your_email_password" set from="your_complete@email_address.com" # Mail folder setup. set folder=~/Mail set mbox_type=mbox set spoolfile=+inbox set mbox=+received set postponed=+postponed set record=+sent
- mutt
- mutt command line
mutt [...] address 参数: -a file : attach a file to message -b address: BCC -c address: CC -F muttrc -H draft: draft contain both header and body -s subject: subject of the message -x : emulate the mailx compose mode 环境变量: EMAIL : user's email address MAIL : user's spool mailbox 示例: bash$ echo "contents" | mutt -x -s "subject" mail@address bash$ echo | mutt -x -s "subject" -i filename mail@address
- exim & minires
- exim
Exim is a fully featured mail transfer agent, a drop-in replacement for sendmail. bash$ /usr/bin/exim-config bash$ view /etc/exim.conf bash$ vi /etc/aliases postmaster: your_login_name bash$ vi /etc/reslov.conf nameserver 10.0.0.7 search your.domain bash$ cygrunsrv -I exim -p /usr/bin/exim -e CYGWIN=nontsec -a "-bdf -q15m" -d "Exim Mail Transfer Agent" -1 /var/log/exim/cygrunsrv_out.log -2 /var/log/exim/cygrunsrv_err.log bash$ cygrunsrv -S exim
bash$ cygpath -d -m "`pwd`"
3.12. Q Setup Xinetd3.13. Q other command?3.14. Q XFree86 under Cygwin?3.15. Q 安装后的设置综述?
- start init service
bash$ /usr/bin/init-config
- chkconfig 工具用来维护 /etc/rc.d 下的脚本
- 若要启动 sshd 执行 "/sbin/chkconfig --add sshd"
- xinetd config
bash$ /usr/bin/xinetd-config
ttcp, netsnoop
- add /usr/X11R6/bin to PATH;
- start Xwindow using startxwin.bat(dos/windows), or startxwin.sh(cygwin);
- if has a firewall installed, open port "6000" of local server;
- run xclient in local machine, just set environment: export DISPLAY=127.0.0.1:0.0
- if run xclient in remote machine, give authorize to remote host:
- telnet/ssh to remote host;
- set environment DISPLAY, like: export DISPLAY=<IP_of_Cygwin_XFree86>:0.0
- xterm
- binmode or textmode?
- 修改 ~/.inputrc 文件,加入如下内容
# Ignore case while completing set completion-ignore-case on # Make Bash 8bit clean set meta-flag on set output-meta on # to show 8-bit characters set convert-meta off # to show it as character, not the octal representation
- 修改 /etc/profile, 加入如下内容:
set -o vi alias less='/bin/less -r' alias ls='/bin/ls -F --color=tty --show-control-chars' # glob filenames in a case-insensitive manner shopt -s nocaseglob export SGML_CATALOG_FILES=/share/catalog.sgml export XML_CATALOG_FILES=/share/catalog.xml export CYGWIN="nobinmode nontsec nosmbntsec" export PATH=$PATH:.
- 修改登录用户的主要组:
bash$ vi /etc/passwd默认属于 513 组(对于域控制器是Domain Users,非域控制器为 NONE),个人偏好设置为 544(Administrator)
- 建立 symbol link:
- 因为一些脚本默认的 md5 摘要程序是 md5, 而非 md5sum;
bash$ ln -s /usr/bin/md5sum /usr/bin/md5
- 设置 DOCBOOK DTD/DSSSL 路径
bash$ ln -sf /cygdrive/e/HOME/WORK/johnson_homepage/worldhello/share /share
- 设置 usemodwiki 路径映射
mkdir /repos cd /repos/ ln -s /cygdrive/d /d ln -s /d/HOME/WORK/johnson_homepage/worldhello/usemod JohnsonUseModWiki ln -s /d/HOME/WORK/johnson_homepage/worldhello/wiki .
- 设置建立工作路径
bash$ ln -sf /cygdrive/e/HOME/WORK/ ~/work
bash$ cygcheck -c cygwin
- gzip
- 修改注册表项:HKEY_LOCAL_MACHINE/SOFTWARE/Cygnus Solutions/Cygwin/mounts v2/.../cygdrive flags。 cygdrive flags是一个DWORD值,&0x2 == 0x2 为 Unix Style,否则为 Dos like style。
- 设置环境变量 CYGWIN, 使得在 pipe 等模式下的处理方式:export CYGWIN=nobinmode
这是所谓的 ntsec 在起作用。通过 NTFS 的权限设置,模拟 UNIX 的权限。可以通过 CYGWIN 环境变量修改。如:
bash$ export CYGWIN="nontsec nosmbntsec"
因为 ls 不使用 readline 来显示, 因而不能用 .inputrc 控制。即 less 和 ls 需要特别设置。在 .bashrc 中加入如下 alias:
alias less='/bin/less -r' alias ls='/bin/ls -F --color=tty --show-control-chars'