Cygwin use 2-experience

Source: Internet
Author: User
Tags posix rsync

Reference: http://www.jb51.net/article/6236.htm

1. Access windows disk in Cygwin
Cd/cygdrive/c
CD C:

2. Consolidate Cygwin commands into Windows
Assuming that Cygwin is installed in D:/develop/cygwin, add D:/develop/cygwin/bin to the system variable path (preferably in front of windows, so that some of the same commands are executed with the Cygwin command first, Instead of Windows commands, such as Find)

You can execute the tar czvf xxx.tgz directly below the cmd.exe.
Basically all the commands are available, including ls,more,less,find,grep and so on.

3. Using tgz Backup
Add the Cygwin bin to the path
Build a BAT file:
@echo off
D:
CD D:\website\8thmanage
Tar czvf 8thmanage.tgz 8thmanage

4.Windows using shell scripts
Add the Cygwin bin to the path
In the $cygwin directory/var/a script t.sh, note that t.sh inside the path, are relative to the $cygwin, the inside need to access the C drive, please use/cygdrive/c/
Under Windows execution:
D:\cygwin\bin\bash d:\cygwin\var\t.sh
(Can be performed on a regular basis)

5. Synchronizing Windows system users
Mkpasswd-l >/etc/passwd
Mkgroup-l >/etc/group
If you have domain, you need to add-D domainname

6. Installing System Services
Cygrunsrv

Using rsync under 7.cygwing
A. Installing the Rsync component
B. Enter Cygwin, configure the server
Vi/etc/rsyncd.conf

... screts File=/etc/tom.ipaddr.pas

Configuration file, refer to another article I wrote about rsync, note: Password file permissions must be 0400
chmod 0400/etc/tom.ipaddr.pas
C. Start the service side
Rsync--daemon

D. Client synchronization
Under the client's Cygwin, run rsync sync, specific commands, please refer to another rsync article.

Using sshd under 8.cygwin
A. Need to install the CYGRUNSRC,OPENSSH
B. Running Ssh-host-config-y
Return to the cygwin=, enter the TTY Ntsec, and return to the
(or, add a system environment variable cugwin=nesec TTY)
C. The SSHD service has been installed into your Windows service and can be started and shut down directly in the service.
(Cygrunsrc-s sshd or net start sshd)

9. Chinese display
VI ~/.BASHRC
# Let LS and dir command display Chinese and color
Alias ls= ' ls--show-control-chars--color '
Alias dir= ' Dir-n--color '
# Set the Chinese environment so that the hint becomes Chinese
Export lang= "ZH_CN. GBK "
# Output to Chinese encoding
Export output_charset= "GBK"

~/.INPUTRC for
Set Completion-ignore-case on
Set Meta-flag on
Set Output-meta on
Set Convert-meta off

The Cygwin.bat script is:
@echo off
Set Make_mode=unix


Installation

Can be directly to http://www.cygwin.com download an installer, Setup.exe, this program is just a setup program, all the modules will be downloaded from the network installation. Alternatively, you can download a cygwin.iso image, directly image it into a disc, and then install it locally from the disc, which will be much faster, without considering the problem of disconnection.

Support for Chinese under X
Locale Support
Cygwin's locale support has always been a problem, fortunately X programs can also use Xlocale.
It is recommended that you use ZH_CN.GBK and do not use ZH_CN. GB2312

In the transplant program should be careful not to allow the program to connect Libcygwin.a inside the setlocale, but the use of libx11.a inside the _xsetlocale. The method is: Check the entire source code of the transplanted program and discover

#include
is modified to

#define X_locale
#include
Also note the connection Library of the program to add-lx11.
If the result is not sure, you can find a dependency walker to see if the program is connected to the cygwin1.dll inside the setlocale, if so, it means that there are omissions.

Chinese font
PCF Dot Matrix Font
Gtk1.x and some of the other old X programs are all in x font,

Note that you must have a font that is consistent with the locale, such as a font that must be encoded by GBK with ZH_CN.GBK, with ZH_CN. GB2312 must have GB2312 encoded fonts.

If you use ZH_CN. GB2312, here's a dot-matrix font pack with a redoffice polygon

You can use TTF2BDF to extract the BDF format from the TTF and then use BDF2PCF to get the PCF format font file.
(There is a Windows version of TTF2BDF, you can convert the Windows TTF font to the BDF font, note that after the BDF to manually edit the file header, the encoding declaration is correct)

Have
To the font, place it in a directory, execute Mkfontdir generate Fonts.dir, and then use Xset +FP
/path/to/your/fonts Add the font path (note that unlike the Fontconfig configuration, where the path is not recursive, if some fonts are placed in subdirectories,
Subdirectories also need to be added to the line).


TTF Font
Many new applications (such as GTK2) use fontconfig/libxft2 to display fonts, which supports TTF fonts better (x previously passed FreeType, XFT modules also support TTF fonts, but support for CJK fonts is not so good, And also under the Cygwin does not seem to have these modules)

You can use the Arphic font package under Linux completely. If you do not have Linux installed, you can download the corresponding package to http://packages.debian.org and extract the TTF file with 7zip decompression.

After you get the font file, place it under a directory, edit the/etc/fonts/local.conf, and add the font path:
/path/to/my/ttf/fonts If you only use it, you can put the font file under ~/.fonts, no need to modify any configuration, up to 30 seconds fontconfig will be able to find these fonts.



Chinese Input Method
Old Yellow (HZHR) transplanted minichinput to Cygwin, I also transplanted fcitx-1.8.5 and 3.0, can be found from my website Http://www.oliwen.com/bama ...

Lc_ctype and xmodifiers are generally set to activate input input methods in the program (unless the program does not have Xim support):

Lc_ctype=zh_cn.gbk
xmodifiers= "@im =chinput"
Export Lc_ctype xmodifiers

For FCITX, the xmodifiers setting is OK (but must be set), so it is set to "@im =chinput", Chinput and FCITX can be used normally

Backspace and Delete in VI are often

First, make sure $TERM is set to Cygwin.


Echo $TERM


If not, please set


term = Cygwin
Export term


Backspace and delete These two keys are normally only one useful. Can be used in $HOME/.bash_profile


Stty Erase ' ^h '//ctrl+v, ctrl+h


Stty erase ' ^? '




------------------------
Cygwin User Guide
1 Introduction
Cygwin is a UNIX simulation environment running on the Windows platform, the free software developed by Cygnus Solutions (the company has developed a lot of good things, famous and Ecos, but has now been Redhat acquired). It is useful for learning unix/linux operating environments, porting applications from UNIX to Windows, or doing some special development work, especially for embedded system development on Windows using the GNU toolset. With the growing popularity of embedded system development in China, more and more developers have been interested in Cygwin. This article will introduce it.

2 mechanism
Cygnus first improved the development tools such as Gcc,gdb,gas, enabling them to generate and interpret Win32 's target files. They then transplanted the tools to the Windows platform. One scenario is to drastically modify the source code of these tools based on the Win32 API, which obviously requires a lot of work. So they took a different approach-they wrote a shared library (that is, the Cygwin DLL), encapsulating UNIX-style calls (such as fork,spawn,signals,select,sockets, etc.) that are not in the Win32 API, which means They wrote a mock layer of a UNIX system library based on the Win32 API. This way, you can use the cross-compiler on a UNIX host to build a toolset that can run on a Windows platform as long as the source code of these tools is connected to the shared library. Based on these porting to the development tools on the Windows platform, Cygnus is gradually porting other tools (almost without the need to modify the source code, only to modify their configuration scripts) software to Windows. This way, running bash and development tools and user tools on the Windows platform feels like working on Unix.
For a more detailed description of the implementation of the Cygwin, refer to http://cygwin.com/cygwin-ug-net/highlights.html.

3 Installation Settings Cygwin
3.1 Installation
To install the network version of the Cygwin, you can go to http://cygwin.com, click "Install Cygwin now!". This will first download a GUI installer called Setup.exe, which can download a full cygwin. Follow the instructions on each screen to make the installation easy.
3.2 Environment variables
Before you start running bash, you should set up some environment variables. Cygwin provides a. bat file that has the most important environment variables set up. It's the safest way to start bash with it. This. bat file is installed in the root directory where Cygwin is located. You can edit the file freely.
The Cygwin variable is used to make various global settings for the Cygwin runtime system. At the beginning, you can set it to TTY in a DOS box without setting Cygwin or before you perform bash in a format similar to the following
C:\> Set Cygwin=tty notitle glob

The path variable is used by the Cygwin application as a list of paths to search for the knowable file. When a Cygwin process starts, the variable is removed from the Windows format (e.g. C:\WinNT\system32; C:\WinNT) into the UNIX format (e.g.,/winnt/system32:/winnt). If you want to use the Cygwin toolset when you're not running bash, the path should at least contain x:\cygwin \ bin, where X:\cygwin is the Cygwin directory on your system.
The home variable is used to specify the home directory, and it is recommended to define the variable before bash executes. When the Cygwin process starts, the variable is also converted from Windows to UNIX format, for example, on the author's machine The value of home is \ C (DOS command set home can see his value, set home=xxx can be set), in Bash with echo $ Home look, its value is/cygdrive/c.
The term variable specifies the terminal type. If the beauty is set on it, it will be automatically set to Cygwin.
Ld_library_path is Cygwin function dlopen () as a list of paths to search. dll files, which is also converted from Windows format to UNIX format. Most Cygwin applications do not use Dlopen, so the variable is not required.
3.3 Changing the maximum storage capacity of the Cygwin
The Cygwin program can allocate less than 384 MB (program+data) of memory by default. In most cases, you do not need to modify this restriction. However, if more actual or virtual memory is needed, you should modify the HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER section of the registry. Tian a DWORD key HEAP_CHUNK_IN_MB and sets its value to the required memory limit, in decimal megabytes. You can also use the Regtool in Cygwin to complete this setting. Examples are as follows:
Regtool-i set/hklm/software/cygnus\ SOLUTIONS/CYGWIN/HEAP_CHUNK_IN_MB 1024
Regtool-v list/hklm/software/cygnus\ Solutions/cygwin

4 using Cygwin
This section is about the differences between Cygwin and traditional UNIX systems.
4.1 Map path name
4.1.1 Introduction
Cygwin supports both Win32 and POSIX-style paths, and the path delimiter can be a forward slash or a backslash. UNC path names are also supported. (In a network, a UNC is a way to determine the location of a file, which allows users to not care about the physical location of the storage device and facilitates user use.) In the Windows operating system, Novell NetWare and other operating systems have used this specification to replace the local naming system. In a UNC, we don't have to worry about what disk (or volume) the file is on, and don't care where the disk (or volume) resides on the server. We can access the file in the following format:
\ \ server name \ share name \ path \ file name
The share name is also sometimes referred to as the logical identity of the volume or storage device where the file is located, but it is used to make it unnecessary for users to care about the physical location of those volumes or storage devices. )
POSIX compliant operating systems (such as Linux) do not have the concept of a drive letter. All absolute paths begin with a slash, not a drive letter (such as C:). All file systems are sub-directories. For example, two hard disks, one of which is the root and the other may be under the/disk2 path.
Because programs on many UNIX systems assume a single POSIX file system structure, Cygwin specifically maintains an internal POSIX view of the Win32 file system that allows these programs to run correctly under Windows. In some necessary cases, Cygwin uses this mapping to convert between Win32 and POSIX paths.
4.1.2 Cygwin Mount table
The Mount program in Cygwin is used to map the Win32 drive and network share paths to the internal POSIX directory tree of Cygwin. This is a concept similar to the typical UNIX mount program. For those who are unfamiliar with UNIX and have a Windows background, the Mount program is very similar to the earlier DOS command join, which is to put a letter as a subdirectory of the other path.
The path mapping information is stored in the Cygwin Mount table of the current user, which is also in the registry of Windows. This information is then removed from the registry the next time the user logs in. The Mount table is divided into two types, with the exception of each user-specific table and the system-wide mount table, which is inherited from the system table for each Cygwin user's installation table. System tables can only be modified by users who have the appropriate permissions (Windows NT administrators).
The current user's Mount table can be seen under the registry "Hkey_current_user/software/red Hat, Inc./cygwin/mounts v". system tables
exists under HKEY_LOCAL_MACHINE.
The POSIX root path/default points to the system partition, but you can use the Mount command to point back to any path in the Windows file system. Cygwin the longest prefix in the Mount table is always used when generating POSIX paths from the Win32 path. For example, if C: is installed simultaneously in/C and/,cygwin will convert C:/foo/bar into/c/foo/bar.
If you call the Mount command without any parameters, the Cygwin current mount point collection is all listed. In the following example, the C drive is the POSIX root, and the D disk is mapped to/d. In this case, the root is a system-wide installation point that is visible to all users and/d only to the current user.
c:\> Mount
F:\cygwin\bin On/usr/bin type System (Binmode)
F:\cygwin\lib on/usr/lib type System (Binmode)
F:\cygwin On/type System (Binmode)
E:\SRC on/usr/src type System (Binmode)
C:ON/CYGDRIVE/C type User (Binmode,noumount)
e:on/cygdrive/e type User (Binmode,noumount)
You can also use the Mount command to add a new mount point and remove the mount point with Umount.
When Cygwin cannot convert a Win32 path to a POSIX path based on an existing installation point, Cygwin automatically converts it to an installation point that is under the default POSIX path/cygdrive. For example, if Cygwin accesses Z:\foo and the Z-disk is not currently in the installation table, the z:\ is automatically converted to/cygdrive/z.
You can assign special properties to each installation point. Automatically installed partitions are displayed as "Auto" installations. The mount point can also be selected as "TextMode" or "Binmode", which determines whether text files and binaries are handled the same way.
4.1.3 Other path-related information
The Cygpath tool provides the ability to convert win32-posix path formats in shell scripts.
The HOME, PATH, and LD_LIBRARY_PATH environment variables are automatically converted from the WIN32 format to the POSIX format when the Cygwin process starts (for example, if there is an installation from that Win32 path to the POSIX path, the c:\cygwin\ Bin to/bin).

Cygwin use 2-experience

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.