aboutsummaryrefslogtreecommitdiff
path: root/winsup/doc/how-using.texinfo
blob: d1077b8372040dfddc2d4affa5e96eb30009a28b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
@section Using Cygwin

@subsection How should I set my PATH?

If you look at the "Cygwin 1.1.0" (or similar) shortcut created in the
"Cygnus Solutions" programs folder, you'll see that it runs
@code{C:\cygwin\bin\cygwin.bat} (assuming your root is
@code{C:\cygwin}).  The contents should look something like this:

@example
	@@echo off
	SET MAKE_MODE=unix
	SET PATH=C:\cygwin\bin;C:\cygwin\usr\local\bin;%PATH%
	bash
@end example

Effectively, this @strong{prepends} /usr/bin and /usr/local/bin to your
Windows system path.  If you choose to reset your PATH, say in
$HOME/.bashrc, then you should follow this rule.  You @strong{must} have
@code{/usr/bin} in your PATH @strong{before} any Windows system
directories.  (And you must not omit the Windows system directories!)
Otherwise you will likely encounter all sorts of problems
running Cygwin applications.

If you haven't messed up the default mounts, then @code{/bin} and
@code{/usr/bin} are the same location, so you only need one of them in
your PATH.  You should use @code{/usr/local/bin} for installing
additional Cygwin applications that are not part of the core net
release.  (That is, anything not found in an ftp mirror of @code{latest}
and installed by @code{setup.exe}.)

@subsection Bash says "command not found", but it's right there!

If you compile a program, you might find that you can't run it:

@example
	bash$ gcc -o hello hello.c
        bash$ hello
        bash: hello: command not found
@end example

Unlike Windows, bash does not look for programs in @samp{.} (the current
directory) by default.  You can add @samp{.} to your PATH (see above),
but this is not recommended (at least on UNIX) for security reasons.
Just tell bash where to find it, when you type it on the command line:

@example
	bash$ gcc -o hello hello.c
        bash$ ./hello
        Hello World!
@end example

@subsection How do I convert between Windows and UNIX paths?

Use the 'cygpath' utility.  Type '@code{cygpath}' with no arguments to
get usage information.  For example (on my installation):
@example
	bash$ cygpath --windows ~/.bashrc
        D:\starksb\.bashrc
        bash$ cygpath --unix C:/cygwin/bin/cygwin.bat
        /usr/bin/cygwin.bat
        bash$ cygpath --unix C:\\cygwin\\bin\\cygwin.bat
        /usr/bin/cygwin.bat
@end example
Note that bash interprets the backslash '\' as an escape character, so
you must type it twice in the bash shell if you want it to be recognised
as such.

@subsection Why doesn't bash read my .bashrc file on startup?

Your .bashrc is read from your home directory specified by the HOME
environment variable.  It uses /.bashrc if HOME is not set.  So you need
to set HOME correctly, or move your .bashrc to the top of the drive
mounted as / in Cygwin.

@subsection How can I get bash filename completion to be case insensitive?

"shopt -s nocaseglob" should do the trick.

@subsection Can I use paths/filenames containing spaces in them?

Cygwin does support spaces in filenames and paths.  That said, some
utilities that use the library may not, since files don't typically
contain spaces in Unix.  If you stumble into problems with this, you
will need to either fix the utilities or stop using spaces in filenames
used by Cygwin tools.

In particular, bash interprets space as a word separator.  You would have
to quote a filename containing spaces, or escape the space character.
For example:
@example
	bash-2.03$ cd '/cygdrive/c/Program Files'
@end example
or
@example
	bash-2.03$ cd /cygdrive/c/Program\ Files
@end example

@subsection Why can't I cd into a shortcut to a directory?

Cygwin does not follow MS Windows Explorer Shortcuts (*.lnk files).  It
sees a shortcut as a regular file and this you cannot "cd" into it.

Some people have suggested replacing the current symbolic link scheme
with shortcuts.  The major problem with this is that .LNK files would
then be used to symlink Cygwin paths that may or may not be valid
under native Win32 non-Cygwin applications such as Explorer.

@subsection I'm having basic problems with find.  Why?

Make sure you are using the find that came with Cygwin and that you
aren't picking up the Win32 find command instead.  You can verify that
you are getting the right one by doing a "type find" in bash.

If the path argument to find, including current directory (default), is
itself a symbolic link, then find will not traverse it unless you
specify the @samp{-follow} option.  This behavior is different than most
other UNIX implementations, but is not likely to change.

@subsection Why doesn't man work?

Even after installing the @samp{man} package, you get an error like this:

@example
	bash-2.03$ man man
	Error executing formatting or display command.
	System command (cd /usr/man ; (echo -e ".pl 1100i"; cat /usr/man/man1/man.1; echo ".pl \n(nlu+10") | /usr/bin/tbl | /usr/bin/groff -Tascii -mandoc | less -is) exited with status 32512.
	No manual entry for man
@end example

You also need /bin/sh, which is found in the @samp{ash} package.
Install this too.

@subsection Why doesn't chmod work?

@samp{ntsec} will allow UNIX permissions in Windows NT on NTFS file systems.

@samp{ntea} works on NTFS @emph{and} FAT but it creates a huge,
@strong{undeletable} file on FAT filesystems.

(The @samp{ntsec} and @samp{ntea} settings are values for the
@samp{CYGWIN} environment variable.  See the Cygwin User's Guide at
@file{http://cygwin.com/cygwin-ug-net/cygwin-ug-net.html} for more
information on this variable and its settings.)

There is no solution at all for Windows 9x.

If you have an application that requires a certain permission mode on a
file, you may be able to work around this requirement by modifying the
application's source code.  For a hint, based on work done by Corinna
Vinschen for OpenSSH, see this message from the cygwin mailing list:
@file{http://cygwin.com/ml/cygwin/2000-11/msg01176.html}.

@subsection Why doesn't @samp{mkdir -p} work on a network share?

Unfortunately, you cannot do something like this:

@example
bash$ mkdir -p //MACHINE/Share/path/to/new/dir
mkdir: cannot create directory `//MACHINE': No such file or directory
@end example

This is because mkdir checks for the existence of each directory on the
path, creating them as necessary.  Since @samp{//MACHINE} is not a
directory (you can't cd to it either), mkdir tries to create it, and
fails.

This might get fixed someday, but for now, you have to work around it:

@example
bash$ cd //MACHINE/Share
bash$ mkdir -p path/to/new/dir
@end example

@subsection Why doesn't my script work?

There are two basic problems you might run into.  One is the fact that
/bin/sh is really ash, and is missing some features you might expect in
/bin/sh.  For example:

@itemize bullet
@item No job control
@item No getopts
@item No functions exported
@end itemize

Or it could be a permission problem, and Cygwin doesn't understand that
your script is executable.  Because @samp{chmod} may not work (see FAQ
entry above), Cygwin must read the contents of files to determine if
they are executable.  If your script does not start with

@example
	#! /bin/sh
@end example

(or any path to a script interpreter, it does not have to be /bin/sh)
then Cygwin will not know it is an executable script.  The Bourne shell
idiom

@example
	:
	# This is the 2nd line, assume processing by /bin/sh
@end example

also works.

Note that you can use @samp{mount -x} to force Cygwin to treat all files
under the mount point as executable.  This can be used for individual
files as well as directories.  Then Cygwin will not bother to read files
to determine whether they are executable.

@subsection Why don't cursor keys work under Win95/Win98?

@strong{(Please note: This section has not yet been updated for the latest
net release.)}

Careful examination shows that they not just non-functional, but
rather behave strangely, for example, with NumLock off, keys on numeric
keyboard work, until you press usual cursor keys, when even numeric
stop working, but they start working again after hitting alphanumeric
key, etc. This reported to happen on localized versions of Win98 and
Win95, and not specific to Cygwin (there're known cases of Alt+Enter
(fullscreen/windowed toggle) not working and shifts sticking with
other programs). The cause of this problem is Microsoft keyboard
localizer which by default installed in 'autoexec.bat'. Corresponding
line looks like:

@example
keyb ru,,C:\WINDOWS\COMMAND\keybrd3.sys
@end example

(That's for russian locale.) You should comment that line if you want
your keys working properly. Of course, this will deprive you of your
local alphabet keyboard support, so you should think about
another localizer. exUSSR users are of course knowledgable of Keyrus
localizer, and it might work for other locales too, since it has keyboard
layout editor. But it has russian messages and documentation ;-(
Reference URL is http://www.hnet.ru/software/contrib/Utils/KeyRus/
(note the you may need to turn off Windows logo for Keyrus to operate
properly).

@subsection Is it OK to have multiple copies of the DLL?

You should only have one copy of the Cygwin DLL on your system.  If you
have multiple versions, they will conflict and cause problems.

If you get the error "shared region is corrupted" or "shared region
version mismatch" it means you have multiple versions of cygwin1.dll
running at the same time.  This could happen, for example, if you update
cygwin1.dll without exiting @emph{all} Cygwin apps (including inetd)
beforehand.

If you're trying to find multiple versions of the DLL that are causing
this problem, reboot first, in case DLL's still loaded in memory are the
cause.  Then use the Windows System find utility to search your whole
machine, not just components in your PATH (as 'type' would do) or
cygwin-mounted filesystems (as Cygwin 'find' would do).

@subsection Where can I find "more"?

If you are looking for the "more" pager, you should use the "less" pager
instead.

@subsection Where can I find "which"?

There is no "which" command with Cygwin.  However, you can use the bash
shell builtin "type" which does something similar.

@subsection Why isn't package XXXX available in Cygwin?  (Or, why is your package so out of date?)

Probably because there is nobody willing or able to maintain it.  It
takes time, and the priority for the Cygwin Team is the Cygwin package.
The rest is a volunteer effort.  Want to contribute?  See below.

@subsection How can I access other drives?

You have some flexibility here.

Cygwin has a builtin "cygdrive prefix" for drives that are not mounted.
You can access any drive, say Z:, as '/cygdrive/z/'.

In some applications (notably bash), you can use the familiar windows
<drive>:/path/, using posix forward-slashes ('/') instead of Windows
backward-slashes ('\').  (But see the warning below!)  This maps in the
obvious way to the Windows path, but will be converted internally to use
the Cygwin path, following mounts (default or explicit).  For example:
@example
	bash$ cd C:/Windows
	bash$ pwd
        /cygdrive/c/Windows
@end example
and
@example
	bash$ cd C:/cygwin
	bash$ pwd
        /
@end example
for a default setup.  You could also use backward-slashes in the
Windows path, but these would have to be escaped from the shell.

@strong{Warning:} There is some ambiguity in going from a Windows path
to the posix path, because different posix paths, through different
mount points, could map to the same Windows directory.  This matters
because different mount points may be binmode or textmode, so the
behaviour of Cygwin apps will vary depending on the posix path used to
get there.

You can avoid the ambiguity of Windows paths, and avoid typing
"/cygdrive", by explicitly mounting drives to posix paths.  For example:
@example
	bash$ mkdir /c
	bash$ mount c:/ /c
	bash$ ls /c
@end example
Then @samp{/cygdrive/c/Windows} becomes @samp{/c/Windows} which is a
little less typing.

Note that you only need to mount drives once.  The mapping is kept
in the registry so mounts stay valid pretty much indefinitely.
You can only get rid of them with umount, or the registry editor.

The '-b' option to mount mounts the mountpoint in binary mode
("binmode") where text and binary files are treated equivalently.  This
should only be necessary for badly ported Unix programs where binary
flags are missing from open calls.  It is also the setting for /,
/usr/bin and /usr/lib in a default Cygwin installation.  The default for
new mounts is text mode ("textmode"), which is also the mode for all
"cygdrive" mounts.

You can change the default @samp{cygdrive} prefix and whether it is
binmode or textmode using the @code{mount} command.  For example,
@example
	bash$ mount -b --change-cygdrive-prefix cygdrive
@end example
will change all @code{/cygdrive/...} mounts to binmode.

@subsection How can I copy and paste into Cygwin console windows?

Under Windows NT, open the properties dialog of the console window.
The options contain a toggle button, named "Quick edit mode".  It must
be ON.  Save the properties.

Under Windows 9x, open the properties dialog of the console window.
Select the Misc tab.  Uncheck Fast Pasting.  Check QuickEdit.

@subsection What does "mount failed: Device or resource busy" mean?

@strong{(Please note: This section has not yet been updated for the latest
net release.)}

This usually means that you are trying to mount to a location
already in use by mount.  For example, if c: is mounted as '/'
and you try to mount d: there as well, you will get this error
message.  First "umount" the old location, then "mount" the new one and
you should have better luck.

If you are trying to umount '/' and are getting this message, you may
need to run @code{regedit.exe} and change the "native" key for the '/'
mount in one of the mount points kept under
HKEY_CURRENT_USER/Software/Cygnus Solutions/CYGWIN.DLL setup/<version>
where <version> is the latest registry version associated with the
Cygwin library.

@subsection How can I share files between Unix and Windows?

During development, we have both Unix boxes running Samba and
NT/Windows 95/98 machines.  We often build with cross-compilers
under Unix and copy binaries and source to the Windows system
or just toy with them directly off the Samba-mounted partition.
On dual-boot NT/Windows 9x machines, we usually use the FAT
filesystem so we can also access the files under Windows 9x.

@subsection Are mixed-case filenames possible with Cygwin?

Several Unix programs expect to be able to use to filenames
spelled the same way, but with different case.  A prime example
of this is perl's configuration script, which wants @code{Makefile} and
@code{makefile}.  WIN32 can't tell the difference between files with
just different case, so the configuration fails.

In releases prior to beta 16, mount had a special mixed case option
which renamed files in such a way as to allow mixed case filenames.  We
chose to remove the support when we rewrote the path handling code for
beta 16.  The standard Windows apps -- explorer.exe,
cmd.exe/command.com, etc. -- do not distinguish filenames that differed
only in case, resulting in some (very) undesirable behavior.

Sergey Okhapkin had maintained a mixed-case patch ('coolview') until
about B20.1, but this has not been updated to recent versions of Cygwin.

@subsection What about DOS special filenames?

Files cannot be named com1, lpt1, or aux (to name a few); either as
the root filename or as the extension part.  If you do, you'll have
trouble.  Unix programs don't avoid these names which can make things
interesting.  E.g., the perl distribution has a file called
@code{aux.sh}.  The perl configuration tries to make sure that
@code{aux.sh} is there, but an operation on a file with the magic
letters 'aux' in it will hang.

@subsection When it hangs, how do I get it back?

If something goes wrong and the tools hang on you for some reason (easy
to do if you try and read a file called aux.sh), first try hitting ^C to
return to bash or the cmd prompt.

If you start up another shell, and applications don't run, it's a good
bet that the hung process is still running somewhere.  Use the Task
Manager, pview, or a similar utility to kill the process.

And, if all else fails, there's always the reset button/power switch.
This should never be necessary under Windows NT.

@subsection Why the weird directory structure?

Why do /lib and /usr/lib (and /bin, /usr/bin) point to the same thing?

Why use mounts instead of symbolic links?

Can I use a disk root (e.g., C:\) as Cygwin root?  Why is this discouraged?

After a new installation in the default location, your mount points will
look something like this:

@example
Device              Directory           Type         Flags
C:\cygwin\bin       /usr/bin            user         binmode
C:\cygwin\lib       /usr/lib            user         binmode
C:\cygwin           /                   user         binmode
@end example

Note that /bin and /usr/bin point to the same location, as do /lib and
/usr/lib.  This is intentional, and you should not undo these mounts
unless you @emph{really} know what you are doing.

Various applications and packages may expect to be installed in /lib or
/usr/lib (similarly /bin or /usr/bin).  Rather than distinguish between
them and try to keep track of them (possibly requiring the occasional
duplication or symbolic link), it was decided to maintain only one
actual directory, with equivalent ways to access it.

Symbolic links had been considered for this purpose, but were dismissed
because they do not always work on Samba drives.  Also, mounts are
faster to process because no disk access is required to resolve them.

Note that non-cygwin applications will not observe Cygwin mounts (or
symlinks for that matter).  For example, if you use WinZip to unpack the
tar distribution of a Cygwin package, it may not get installed to the
correct Cygwin path.  @emph{So don't do this!}

It is strongly recommended not to make the Cygwin root directory the
same as your drive's root directory, unless you know what you are doing
and are prepared to deal with the consequences.  It is generally easier
to maintain the Cygwin hierarchy if it is isolated from, say, C:\.  For
one thing, you avoid possible collisions with other (non-cygwin)
applications that may create (for example) \bin and \lib directories.
(Maybe you have nothing like that installed now, but who knows about
things you might add in the future?)

@subsection How do anti-virus programs like Cygwin?

Users have reported that NAI (formerly McAfee) VirusScan for NT (and
others?) is incompatible with Cygwin.  This is because it tries to scan
the newly loaded shared memory in cygwin1.dll, which can cause fork() to
fail, wreaking havoc on many of the tools.  (It is not confirmed that
this is still a problem, however.)

There have been several reports of NAI VirusScan causing the system to
hang when unpacking tar.gz archives.  This is surely a bug in VirusScan,
and should be reported to NAI.  The only workaround is to disable
VirusScan when accessing these files.  This can be an issue during
setup, and is discussed in that FAQ entry.

Some users report a significant performance hit using Cygwin when their
anti-virus software is enabled.  Rather than disable the anti-virus
software completely, it may be possible to specify directories whose
contents are exempt from scanning.  In a default installation, this
would be @samp{@code{C:\cygwin\bin}}.  Obviously, this could be
exploited by a hostile non-Cygwin program, so do this at your own risk.

@subsection Why can't I run bash as a shell under NT Emacs?

The Windows port of GNU Emacs (aka "NT emacs") uses the Windows command
shell by default.  Also, since Emacs is not a Cygwin application, it has
no knowledge of Cygwin mounts.  With those points in mind, you need to
add the following code to your ~/.emacs or ~/_emacs file in order to use
bash.  This is particularly useful for the JDE package
(@file{http://sunsite.dk/jde/}).

@example
	;; This assumes that Cygwin is installed in C:\cygwin (the
	;; default) and that C:\cygwin\bin is not already in your
	;; Windows Path (it generally should not be).
	;;
	(setq exec-path (cons "C:/cygwin/bin" exec-path))
	(setenv "PATH" (concat "C:\\cygwin\\bin;" (getenv "PATH")))
	;;
	;; NT-emacs assumes a Windows command shell, which you change
	;; here.
	;;
	(setq process-coding-system-alist '(("bash" . undecided-unix)))
	(setq w32-quote-process-args ?\")
	(setq shell-file-name "bash")
	(setenv "SHELL" shell-file-name) 
	(setq explicit-shell-file-name shell-file-name) 
	;;
	;; This removes unsightly ^M characters that would otherwise
	;; appear in the output of java applications.
	;;
	(add-hook 'comint-output-filter-functions
	          'comint-strip-ctrl-m)
@end example

@subsection info error "dir: No such file or directory"

Cygwin packages install their info documentation in the /usr/info
directory.  But you need to create a @code{dir} file there before the
standalone info program (probably @code{/usr/bin/info}) can be used to
read those info files.  This is how you do it:
@example
	bash$ cd /usr/info
	bash$ for f in *.info ; do install-info $f dir ; done
@end example
This may generate warnings:
@example
	install-info: warning: no info dir entry in `gzip.info'
	install-info: warning: no info dir entry in `time.info'
@end example
The @code{install-info} command cannot parse these files, so you will
have to add their entries to @code{/usr/info/dir} by hand.

@subsection Why do I get a message saying Out of Queue slots?

@strong{(Please note: This section has not yet been updated for the latest
net release.)}

"Out of queue slots!" generally occurs when you're trying to remove
many files that you do not have permission to remove (either because
you don't have permission, they are opened exclusively, etc).  What
happens is Cygwin queues up these files with the supposition that it
will be possible to delete these files in the future.  Assuming that
the permission of an affected file does change later on, the file will
be deleted as requested.  However, if too many requests come in to
delete inaccessible files, the queue overflows and you get the message
you're asking about.  Usually you can remedy this with a quick chmod,
close of a file, or other such thing.  (Thanks to Larry Hall for
this explanation).

@subsection Why don't symlinks work on samba-mounted filesystems?

Symlinks are marked with "system" file attribute.  Samba does not
enable this attribute by default.  To enable it, consult your Samba
documentation and then add these lines to your samba configuration
file:

@smallexample
	map system = yes
	create mask = 0775
@end smallexample

Note that the 0775 can be anything as long as the 0010 bit is set.

@subsection Why does df report sizes incorrectly.

@strong{(Please note: This section has not yet been updated for the latest
net release.)}

There is a bug in the Win32 API function GetFreeDiskSpace that
makes it return incorrect values for disks larger than 2 GB in size.
Perhaps that may be your problem?