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 is to execute the Cygwin command first, not the Windows command, 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)
Get
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 fully use the Arphic font package under Linux. 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 1024x768
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, The Z-disk is not currently in the installation table, then the z:\ will be automatically converted into/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).
. bash_profile file you can find it in the Cygwin\etc\defaults\etc\skel directory (according to the description, the latest version of the Cygwin the file is found in the above directory # the latest version as Installed by the Cygwin Setup program can# always be found at/etc/defaults/etc/skel/.bash_profile) copy the file directly to your Home\adminis Trator\. (The home file is empty at the time of installation, so my Administrator folder was built by myself ha) as for environment variables, you can add user variables or system variables to home and set their value to D:\cygwin\home\administrator. (My is installed on the D drive, according to your own situation) to set up the NDK environment needs to modify the. bash_profil file, please refer to the online tutorial, there are many. My problem is solved, hope is helpful to you
Cygwin using notes