Cygwin: Difference between revisions
No edit summary |
|||
Line 76: | Line 76: | ||
</source> |
</source> |
||
== |
== Administration == |
||
=== Adding Users === |
|||
Create the user in Windows User Management first, then use command <tt>mkpasswd</tt> to add it to Cygwin environment. |
Create the user in Windows User Management first, then use command <tt>mkpasswd</tt> to add it to Cygwin environment. |
||
<source lang=bash> |
<source lang=bash> |
||
Line 84: | Line 85: | ||
</source> |
</source> |
||
== Installing a Service == |
=== Installing a Service === |
||
''Reference: Cygwin inetutils-1.5 OLD-README'' |
''Reference: Cygwin inetutils-1.5 OLD-README'' |
||
Use '''cygrunsrv''' to install a Cygwin process as a service in Windows. Some examples: |
|||
⚫ | |||
⚫ | |||
Under Windows NT inetd must be started from service manager. To accompish that, you can install inetd as service running under '''cygrunsrv''': |
|||
$ cygrunsrv -I inetd -d "CYGWIN inetd" -p /usr/sbin/inetd -a -D |
|||
⚫ | |||
cygrunsrv - |
$ cygrunsrv --install imapd --desc "Courier IMAP daemon" --disp "CYGWIN imapd" \ |
||
--path /usr/local/sbin/imapd-service.sh --termsig QUIT --type auto --shutdown |
|||
</source> |
</source> |
||
By default this will install the service to run under account ''SYSTEM'' (''LocalSystem''), who is the user that has all the required permission up to Windows XP. For Windows 2003 Server or Windows Vista, see below. |
|||
⚫ | |||
There's also another way to install inetd as service. It allows to run inetd without '''cygrunsrv''': |
|||
Manually starting and stopping is possible via |
|||
⚫ | |||
inetd --install-as-service |
|||
⚫ | |||
inetd --remove-as-service |
|||
⚫ | |||
⚫ | |||
</source> |
</source> |
||
⚫ | |||
However, this always installs inetd as service running under the SYSTEM account, with the problems mentioned below starting with Windows 2003. This also adds the problem that you have to change the system environment so that The Cygwin '''/bin''' directory is in <tt>%Path%</tt>. For that reason it's much better to use cygrunsrv to start inetd. |
|||
⚫ | Beginning with Windows 2003 Server and Windows Vista, the ''SYSTEM'' user is lacking the ''"Create a token object"'' right, which is required to change the user without providing the password. On these systems you have to create an admin user account with special additional user rights. You can use the Cygwin tool '''editrights''' or the local/domain security policy '''mmc''' snap in to set these rights: |
||
=== Windows 2003, Windows Vista === |
|||
However, beginning with Windows 2003 Server and Windows Vista, the SYSTEM user is lacking the ''"Create a token object"'' right, which is required to change the user without providing the password. |
|||
⚫ | |||
''Create a token object'' |
''Create a token object'' |
||
Line 117: | Line 117: | ||
''Increase quotas'' |
''Increase quotas'' |
||
''Logon as a service'' |
''Logon as a service'' |
||
⚫ | |||
After you have installed inetd it will be started automatically on reboot. Manually starting and stopping is possible via |
|||
<source lang=winbatch> |
|||
⚫ | |||
⚫ | |||
</source> |
|||
== Miscellaneous == |
== Miscellaneous == |
Revision as of 23:49, 16 November 2008
Packages
- Do a grep <keyword> setup.ini in local cygwin repository cache file setup.ini to search for a keyword in package name/description.
- In google, do a query <keyword> site:cygwin.com to search on cygwin website.
- Cygwin package contributor guide
- Interesting repositories:
- ftp://ftp.gwdg.de/pub/linux/sources.redhat.com/cygwin/
- (usual repository I use)
- ftp://sunsite.dk/projects/cygwinports
- Repository of Cygwin Ports, maintained by Yaakov Selkowitz (homepage: http://cygwinports.sunsite.dk/)
- Website: http://sourceware.org/cygwinports/
Creating a local setup.ini
Packages in Cygwin can be installed from repositories. The content of these repositories is described in a file setup.ini. Each package in the repository is made of one or more .bz2 files (the actual package) and a file setup.hint (spec) describing the content of the package. The setup.ini file of the repository is actually a compilation of all setup.hint files in the repository along with additional information. Cygwin apparently does not want to install a package from a single .hint file (or at least have not found how to do so). In that case you need to generate the setup.ini file. Here's an example how this can be done.
Example is based on package recode v3.6.1.
- Download the package above, and create following directory structure within Cygwin Local Package Directory (where setup.ini location is already shown).
. |-- http%3a%2f%2fftp.... | ... `-- local |-- release | `-- recode | |-- recode-3.6-1-src.tar.bz2 | |-- recode-3.6-1.tar.bz2 | |-- recode-devel | | |-- recode-devel-3.6-1.tar.bz2 | | `-- setup.hint | `-- setup.hint `-- setup.ini
- Create the file ./local/setup.ini with the following content:
# File manually generated on 20081105. # setup-timestamp and setup-version are completely fake... setup-timestamp: 1214338445 setup-version: 2.573.2.2 @ recode sdesc: "GNU recode utility" ldesc: "The program recognizes or produces approx. 150 character sets and can convert almost any character set to almost any other." category: text requires: cygwin libintl3 version: 3.6-1 install: release/recode/recode-3.6-1.tar.bz2 838836 c185a17d8e1eb964611d26cbfe9b0e05 source: release/recode/recode-3.6-1-src.tar.bz2 1731299 83b0f5940aa5d2a82355586b6d977bab
- (in gray) First the header
- (in black) Then entry giving the package name
- (in red) Then a copy-paste from setup.hint file.
- (in green) Then the version (derived from package name)
- (in blue) And finally two entries for binary and source package, giving for each: location of .bz2 file, the file size in bytes, the md5 checksum (as given by md5sum).
When done, simply install the package by running Cygwin setup.exe, asking to Install from Local Directory. Cygwin will see the new file setup.ini, and proposes for install the packages listed inside.
Troubleshooting
Cygwin
- Look for multiple copies of the cygwin DLL cygwin1.dll. Removes all copies that are not in the cygwin install directory (usually c:\cygwin).
- List of interfering software:
- NoMachine NX Client - installs a custom version of the Cygwin DLL which can cause multiple interferences:
- Cygwin crashes when multiple instances are launched.
- Running cygwin commands (like ls) in a NT command shell when another instance of cygwin is running creates application error (Memory cannot be "read").
- setup.exe fails because it runs several instances of bash.
- SysInternals' Process Monitor
- All back-quoted commands or $() commands in scripts fail until Windows is restarted
- NoMachine NX Client - installs a custom version of the Cygwin DLL which can cause multiple interferences:
Missing DLL using strace
strace can be used to check whether an application needs a .DLL but cannot find it. This error is not reported by default on cygwin, so an application may just leave without any message, giving the impression that it simply does nothing. strace on the other hand will report about the missing .DLL. To solve the problem, install the .DLL somewhere in your PATH, or edit the PATH to include the .DLL location.
Example ([1]):
$ strace /usr/local/sbin/authtest # This will open a dialog box to complain about DLL.
$ export PATH=$PATH:/usr/local/lib/bin
$ /usr/local/sbin/authtest ausername
Administration
Adding Users
Create the user in Windows User Management first, then use command mkpasswd to add it to Cygwin environment.
$ net user <username> <password> /add /yes
$ net localgroup <an_local_group> <username> /add
$ mkpasswd -l -u <username> >> /etc/passwd
Installing a Service
Reference: Cygwin inetutils-1.5 OLD-README
Use cygrunsrv to install a Cygwin process as a service in Windows. Some examples:
$ cygrunsrv -I inetd -d "CYGWIN inetd" -p /usr/sbin/inetd -a -D
$ cygrunsrv --install imapd --desc "Courier IMAP daemon" --disp "CYGWIN imapd" \
--path /usr/local/sbin/imapd-service.sh --termsig QUIT --type auto --shutdown
By default this will install the service to run under account SYSTEM (LocalSystem), who is the user that has all the required permission up to Windows XP. For Windows 2003 Server or Windows Vista, see below.
Start/Stop the service
Manually starting and stopping is possible via
$ net start <service>
$ net stop <service>
Creating a Privileged User in Windows 2003, Windows Vista
Beginning with Windows 2003 Server and Windows Vista, the SYSTEM user is lacking the "Create a token object" right, which is required to change the user without providing the password. On these systems you have to create an admin user account with special additional user rights. You can use the Cygwin tool editrights or the local/domain security policy mmc snap in to set these rights:
Create a token object Act as part of the operating system Replace process level token Increase quotas Logon as a service
Miscellaneous
- Reference Cygwin documentation can be found in /usr/share/doc/cygwin-doc-1.4.
- Interesting post about the 'su' command, explaining why there is no 'su' in Cygwin, and how 'ssh' overcomes this.
- Other relevant post.
- To make ins to paste text from clipboard, add to .inputrc:
"\e[2~": paste-from-clipboard
- Use rxvt as terminal emulator instead of standard console window.
- The + that appears next to file permission in ls output means that there are other permissions for the file (use getfacl on the file to see them)
-rwxr-x---+ 1 beq06659 Users 2555 Oct 10 23:32 inetd.conf* #More permissions set (getfacl inetd.conf to see them) -rwxr-x--- 1 beq06659 Users 706 Nov 8 01:27 initscript*
Cygwin Useful commands
- id
- Use command id to print user identity
- getfacl
- Display file and directory access control lists (ACLs).