Professional Documents
Culture Documents
Linux Complete Command Reference
Linux Complete Command Reference
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
201 West 103rd Street
Indianapolis, Indiana 46290
LINUX COMPLETE
Command Reference
For more information on the Linux operating system and
Red Hat Software, Inc., check http://www.redhat.com.
Compiled by J. Purcell
Red Hat Software, Inc.
President Richard K. Swadley
Publisher and Director of Acquisitions Jordan Gold
Director of Product Development Dean Miller
Managing Editor KittyWilson Jarrett
Indexing Manager Johnna L. VanHoose
Director of Marketing Kelli S. Spencer
Associate Product Marketing Manager Jennifer Pock
Marketing Coordinator Linda Beckwith
COPYRIGHT 1997 BY RED HAT SOFTWARE, INC.
FIRST EDITION
All rightsreserved. No part of thisbook shall be reproduced, stored in a retrieval
system, or transmitted by any means, electronic, mechanical, photocopying,
recording, or otherwise, without written permission from the publisher. No
patent liability isassumed with respect to the use of the information contained
herein. Although every precaution hasbeen taken in the preparation of this
book, the publisher and author assume no responsibility for errorsor omissions.
Neither isany liability assumed for damagesresulting from the use of the
information contained herein. For information, addressSamsPublishing, 201
W. 103rd St., Indianapolis, IN 46290.
International Standard Book Number: 0-672-31104-6
Library of CongressCatalog Card Number: 97-66202
2000 99 98 97 4 3 2 1
Interpretation of the printing code: the rightmost double-digit number isthe
year of the booksprinting; the rightmost single-digit, the number of the books
printing. For example, a printing code of 97-1 showsthat the first printing of the
book occurred in 1997.
Composed in AGaramond and MCPdigital by Macmillan Computer Publishing
Printed in the United Statesof America
TRADEMARKS
All termsmentioned in thisbook that are known to be trademarksor service
markshave been appropriately capitalized. SamsPublishing cannot attest to the
accuracy of thisinformation. Use of a term in thisbook should not be regarded
asaffecting the validity of any trademark or service mark.
Acquisitions Editor
GraceM. Buechlein
Development Editor
Brian Proffitt
Software Development Specialist
Jack Belbot
Production Editor
KittyWilson Jarrett
KateShoup Welsh
Copy Editors
KimberlyK. Hannel
Carolyn Linn
KristineSimmons
Indexer
ChristineL. Nelsen
Technical Reviewer
Bill Ball
Editorial Coordinators
MandieRowell
KatieWise
Technical Edit Coordinator
LynetteQuinn
Editorial Assistants
Carol Ackerman
Andi Richter
Rhonda Tinch-Mize
Karen Williams
Cover Designer
Karen Ruggles
Book Designer
Ann Jones
Copy Writer
David Reichwein
Production Team Supervisor
Beth Lewis
Production Team
Erin Danielson, Bryan Flores,
DiMoniqueFord, JulieGeeting,
KayHoskin, ChristyM. Lemasters,
TonyMcDonald, Darlena Murray,
JulieSearls, SossitySmith
Overview
Part I
User Commands 2
Part II
System Calls 738
Part III
Library Functions 892
Part IV
Special Files 1064
Part V
File Formats 1104
Part VI
Games 1210
Part VII
Miscellaneous 1214
Part VIII
Administration and Privileged Commands 1258
Part IX
Kernel Reference Guide 1424
Index
Linux CompleteCommand Reference
iv
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
Part I User Commands
Introduction ......................................................................................................... 2
addftinfo ............................................................................................................... 2
afmtodit ................................................................................................................ 2
ansi2knr ................................................................................................................ 4
anytopnm ............................................................................................................. 4
appres ................................................................................................................... 5
ar .......................................................................................................................... 5
arch....................................................................................................................... 8
GNU as................................................................................................................ 8
asciitopgm........................................................................................................... 10
atktopbm ............................................................................................................ 10
bash .................................................................................................................... 11
bdftopcf .............................................................................................................. 47
beforelight ........................................................................................................... 47
biff ...................................................................................................................... 48
bioradtopgm ....................................................................................................... 48
bitmap, bmtoa, atobm ........................................................................................ 49
bmptoppm.......................................................................................................... 57
brushtopbm ........................................................................................................ 57
cal ....................................................................................................................... 58
cat ....................................................................................................................... 58
chattr .................................................................................................................. 59
chfn .................................................................................................................... 60
chgrp................................................................................................................... 61
chkdupexe........................................................................................................... 61
chmod................................................................................................................. 61
chown ................................................................................................................. 62
chsh .................................................................................................................... 63
ci ......................................................................................................................... 64
cidentd................................................................................................................ 69
cksum ................................................................................................................. 70
clear .................................................................................................................... 70
cmuwmtopbm .................................................................................................... 71
co........................................................................................................................ 71
col ....................................................................................................................... 76
colcrt ................................................................................................................... 77
colrm .................................................................................................................. 77
column................................................................................................................ 78
comm.................................................................................................................. 78
v
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
convdate.............................................................................................................. 79
cp........................................................................................................................ 80
cccp, cpp............................................................................................................. 81
crontab................................................................................................................ 84
csplit ................................................................................................................... 85
ctags.................................................................................................................... 87
cu........................................................................................................................ 88
cut ...................................................................................................................... 90
cvs....................................................................................................................... 91
date................................................................................................................... 106
dd ..................................................................................................................... 108
depmod, modprobe........................................................................................... 109
df ...................................................................................................................... 112
dig .................................................................................................................... 113
dnsquery ........................................................................................................... 117
domainname..................................................................................................... 119
dsplit ................................................................................................................. 119
du ..................................................................................................................... 120
editres............................................................................................................... 121
elvis, ex, vi, view, input ..................................................................................... 126
elvprsv............................................................................................................... 128
elvrec................................................................................................................. 129
emacs................................................................................................................ 130
emacstool .......................................................................................................... 134
etags.................................................................................................................. 135
expand .............................................................................................................. 137
find ................................................................................................................... 137
fitstopnm .......................................................................................................... 142
fmt .................................................................................................................... 143
fold ................................................................................................................... 143
free.................................................................................................................... 144
fsinfo................................................................................................................. 145
fslsfonts............................................................................................................. 145
fstobdf ............................................................................................................... 146
fstopgm............................................................................................................. 147
ftp..................................................................................................................... 147
fuser .................................................................................................................. 154
g++.................................................................................................................... 155
g3topbm ........................................................................................................... 160
gawk ................................................................................................................. 161
Linux CompleteCommand Reference
vi
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
gcal ................................................................................................................... 173
gcc, g++............................................................................................................. 174
gemtopbm ........................................................................................................ 201
geqn.................................................................................................................. 202
getlist ................................................................................................................ 206
getopt ................................................................................................................ 207
giftopnm........................................................................................................... 208
gindxbib............................................................................................................ 209
glookbib............................................................................................................ 210
gnroff ................................................................................................................ 210
gouldtoppm...................................................................................................... 211
gpic................................................................................................................... 211
gprof ................................................................................................................. 216
grefer ................................................................................................................. 217
grep, egrep, fgrep .............................................................................................. 224
grephistory........................................................................................................ 226
grodvi ............................................................................................................... 227
groff .................................................................................................................. 228
grog .................................................................................................................. 230
grops................................................................................................................. 230
grotty ................................................................................................................ 235
gsoelim.............................................................................................................. 236
gtbl ................................................................................................................... 236
gtroff ................................................................................................................. 237
gzip, gunzip, zcatgzip, gunzip, zcat .................................................................... 248
gzexe................................................................................................................. 252
head .................................................................................................................. 253
hexdump........................................................................................................... 254
hipstopgm......................................................................................................... 256
host ................................................................................................................... 257
hostid................................................................................................................ 258
hostname.......................................................................................................... 259
hpcdtoppm v0.3................................................................................................ 260
httpd................................................................................................................. 261
icontopbm ........................................................................................................ 262
ident ................................................................................................................. 262
ilbmtoppm........................................................................................................ 263
imake................................................................................................................ 264
imgtoppm......................................................................................................... 267
inews................................................................................................................. 267
info................................................................................................................... 269
innconfval ......................................................................................................... 270
insmod.............................................................................................................. 271
install ................................................................................................................ 272
installit .............................................................................................................. 273
vii
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
ispell, buildhash, munchlist, findaffix, tryaffix, icombine, ijoin ......................... 274
join ................................................................................................................... 282
kill .................................................................................................................... 283
killall ................................................................................................................. 284
ksyms................................................................................................................ 284
last .................................................................................................................... 285
lbxproxy............................................................................................................ 286
ld ...................................................................................................................... 287
lispmtopgm....................................................................................................... 292
lkbib ................................................................................................................. 292
ln ...................................................................................................................... 293
lndir .................................................................................................................. 294
locate ................................................................................................................ 295
logger ................................................................................................................ 295
login.................................................................................................................. 296
look................................................................................................................... 297
lpq .................................................................................................................... 298
lpr ..................................................................................................................... 299
lprm.................................................................................................................. 301
lptest ................................................................................................................. 302
ls, dir, vdir ......................................................................................................... 303
lsattr .................................................................................................................. 304
lsmod ................................................................................................................ 305
lynx................................................................................................................... 306
macptopbm....................................................................................................... 309
make................................................................................................................. 310
makedepend...................................................................................................... 312
makestrs............................................................................................................ 314
mattrib.............................................................................................................. 315
mbadblocks....................................................................................................... 316
mcd................................................................................................................... 316
mcookie............................................................................................................ 317
mcopy............................................................................................................... 317
md5sum............................................................................................................ 318
mdel .................................................................................................................. 318
mdeltree............................................................................................................ 319
mdir .................................................................................................................. 319
merge................................................................................................................ 320
mesg.................................................................................................................. 321
mformat ............................................................................................................ 321
mgrtopbm......................................................................................................... 322
mkdir ................................................................................................................ 323
mkdirhier .......................................................................................................... 323
mkfifo............................................................................................................... 323
mkmanifest ....................................................................................................... 324
Linux CompleteCommand Reference
viii
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
mknod .............................................................................................................. 325
mlabel ............................................................................................................... 325
mmd ................................................................................................................. 326
mmount ............................................................................................................ 326
mmove.............................................................................................................. 327
more................................................................................................................. 327
mrd................................................................................................................... 329
mread................................................................................................................ 329
mren ................................................................................................................. 329
mtest ................................................................................................................. 330
mtools............................................................................................................... 330
mtvtoppm......................................................................................................... 333
mtype................................................................................................................ 333
mv .................................................................................................................... 334
mwrite.............................................................................................................. 335
namei ................................................................................................................ 335
newaliases.......................................................................................................... 336
newgrp.............................................................................................................. 336
nl ...................................................................................................................... 337
nlmconv............................................................................................................ 338
nm.................................................................................................................... 339
nntpget ............................................................................................................. 340
objcopy ............................................................................................................. 341
objdump ........................................................................................................... 342
oclock ............................................................................................................... 344
od ..................................................................................................................... 345
passwd .............................................................................................................. 346
paste.................................................................................................................. 347
pbmclean .......................................................................................................... 348
pbmfilters.......................................................................................................... 348
pbmlife............................................................................................................. 352
pbmmake.......................................................................................................... 353
pbmmask .......................................................................................................... 353
pbmpscale......................................................................................................... 354
pbmreduce........................................................................................................ 355
pbmtext ............................................................................................................ 355
pbmto10x ......................................................................................................... 356
pbmto4425....................................................................................................... 357
pbmtoascii ........................................................................................................ 357
pbmtoatk .......................................................................................................... 358
pbmtobg ........................................................................................................... 358
pbmtocmuwm .................................................................................................. 358
pbmtoepsi ......................................................................................................... 359
pbmtoepson ...................................................................................................... 359
pbmtog3 ........................................................................................................... 360
ix
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
pbmtogem ........................................................................................................ 360
pbmtogo ........................................................................................................... 360
pbmtoicon ........................................................................................................ 361
pbmtolj ............................................................................................................. 361
pbmtoln03........................................................................................................ 362
pbmtolps........................................................................................................... 362
pbmtomacp....................................................................................................... 363
pbmtomgr ......................................................................................................... 363
pbmtopgm........................................................................................................ 364
pbmtopi3.......................................................................................................... 364
pbmtopk ........................................................................................................... 364
pbmtoplot ......................................................................................................... 365
pbmtoptx .......................................................................................................... 366
pbmtox10bm.................................................................................................... 366
pbmtoxbm........................................................................................................ 367
pgmtoybm ........................................................................................................ 367
pbmtozinc......................................................................................................... 367
pbmupc ............................................................................................................ 368
pcxtoppm.......................................................................................................... 368
pfbtops.............................................................................................................. 369
pgmbentley ....................................................................................................... 369
pgmcrater .......................................................................................................... 370
pgmedge ........................................................................................................... 371
pgmenhance...................................................................................................... 371
pgmhist ............................................................................................................. 372
pgmkernel ......................................................................................................... 372
pgmnoise .......................................................................................................... 373
pgmnorm.......................................................................................................... 373
pgmoil .............................................................................................................. 374
pgmramp .......................................................................................................... 374
pgmtexture........................................................................................................ 375
pgmtofs............................................................................................................. 376
pgmtolispm....................................................................................................... 376
pgmtopbm........................................................................................................ 377
pgmtoppm........................................................................................................ 378
pi1toppm.......................................................................................................... 378
pi3topbm.......................................................................................................... 379
picttoppm......................................................................................................... 379
pjtoppm............................................................................................................ 381
pktopbm........................................................................................................... 381
pnmalias............................................................................................................ 381
pnmarith........................................................................................................... 382
pnmcat .............................................................................................................. 383
pnmcomp ......................................................................................................... 383
pnmconvol ........................................................................................................ 384
Linux CompleteCommand Reference
x
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
pnmcrop ........................................................................................................... 385
pnmcut ............................................................................................................. 385
pnmdepth ......................................................................................................... 385
pnmenlarge....................................................................................................... 386
pnmfile............................................................................................................. 386
pnmflip............................................................................................................. 387
pnmgamma....................................................................................................... 387
pnmhistmap...................................................................................................... 388
pnmindex.......................................................................................................... 388
pnminvert ......................................................................................................... 389
pnmmargin ....................................................................................................... 389
pnmnlfilt ........................................................................................................... 390
pnmnoraw ........................................................................................................ 391
pnmpad ............................................................................................................ 392
pnmpaste.......................................................................................................... 392
pnmrotate......................................................................................................... 393
pnmscale........................................................................................................... 393
pnmshear .......................................................................................................... 394
pnmsmooth ...................................................................................................... 395
pnmtile............................................................................................................. 395
pnmtoddif ......................................................................................................... 396
pnmtofits.......................................................................................................... 396
pnmtops............................................................................................................ 397
pnmtorast ......................................................................................................... 398
pnmtosgi ........................................................................................................... 398
pnmtosir ........................................................................................................... 399
pnmtotiff .......................................................................................................... 399
pnmtoxwd ........................................................................................................ 400
ppm3d .............................................................................................................. 400
ppmbrighten ..................................................................................................... 401
ppmchange....................................................................................................... 401
ppmdim............................................................................................................ 402
ppmdist ............................................................................................................. 402
ppmdither ......................................................................................................... 403
ppmflash ........................................................................................................... 404
ppmforge.......................................................................................................... 404
ppmhist ............................................................................................................. 408
ppmmake.......................................................................................................... 408
ppmmix ............................................................................................................ 408
ppmnorm.......................................................................................................... 409
ppmntsc............................................................................................................ 409
ppmpat ............................................................................................................. 410
ppmquant ......................................................................................................... 411
ppmquantall ...................................................................................................... 412
ppmqvga........................................................................................................... 412
xi
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
ppmrelief .......................................................................................................... 413
ppmshift ........................................................................................................... 413
ppmspread ........................................................................................................ 414
ppmtoacad ........................................................................................................ 414
ppmtobmp........................................................................................................ 416
ppmtogif ........................................................................................................... 416
ppmtoicr ........................................................................................................... 417
ppmtoilbm........................................................................................................ 418
ppmtomap ........................................................................................................ 419
ppmtomitsu ...................................................................................................... 420
ppmtopcx.......................................................................................................... 421
ppmtopgm........................................................................................................ 421
ppmtopi1.......................................................................................................... 422
ppmtopict ......................................................................................................... 422
ppmtopj ............................................................................................................ 423
ppmtopjxl ......................................................................................................... 424
ppmtopuzz........................................................................................................ 424
ppmtorgb3........................................................................................................ 425
ppmtosixel ........................................................................................................ 425
ppmtotga .......................................................................................................... 426
ppmtouil ........................................................................................................... 427
ppmtoxpm........................................................................................................ 427
ppmtoyuv ......................................................................................................... 428
ppmtoyuvsplit ................................................................................................... 428
pr ...................................................................................................................... 429
ps...................................................................................................................... 430
psbb .................................................................................................................. 433
psidtopgm......................................................................................................... 433
pstopnm............................................................................................................ 434
pstree................................................................................................................ 435
psupdate ........................................................................................................... 436
qrttoppm .......................................................................................................... 436
quota................................................................................................................. 437
ranlib ................................................................................................................ 437
rasttopnm ......................................................................................................... 438
rawtopgm.......................................................................................................... 439
rawtoppm ......................................................................................................... 439
rcp .................................................................................................................... 440
rcs..................................................................................................................... 441
rcsclean ............................................................................................................. 443
rcsdiff ................................................................................................................ 445
rcsfreeze............................................................................................................ 446
rcsintro ............................................................................................................. 447
rcsmerge............................................................................................................ 449
rdist .................................................................................................................. 451
Linux CompleteCommand Reference
xii
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
reconfig............................................................................................................. 454
ref ..................................................................................................................... 455
reset .................................................................................................................. 456
resize................................................................................................................. 456
rev..................................................................................................................... 457
rgb3toppm........................................................................................................ 457
rlog ................................................................................................................... 458
rlogin ................................................................................................................ 460
rm..................................................................................................................... 461
rmdir ................................................................................................................ 462
rmmod.............................................................................................................. 462
rnews................................................................................................................ 463
rpcgen ............................................................................................................... 464
rsh..................................................................................................................... 466
rstart ................................................................................................................. 467
rstartd ............................................................................................................... 468
rup.................................................................................................................... 472
rusers ................................................................................................................ 472
rwall .................................................................................................................. 473
rwho ................................................................................................................. 474
script ................................................................................................................. 474
sed .................................................................................................................... 475
sessreg............................................................................................................... 480
setterm.............................................................................................................. 482
sgitopnm........................................................................................................... 483
shar ................................................................................................................... 484
shlock................................................................................................................ 487
showrgb ............................................................................................................ 488
shrinkfile........................................................................................................... 488
sirtopnm ........................................................................................................... 488
size.................................................................................................................... 489
sldtoppm........................................................................................................... 490
smproxy ............................................................................................................ 491
sort .................................................................................................................... 492
spctoppm.......................................................................................................... 494
split ................................................................................................................... 494
spottopgm......................................................................................................... 495
sputoppm.......................................................................................................... 495
sq ...................................................................................................................... 496
startx................................................................................................................. 496
strings............................................................................................................... 498
strip .................................................................................................................. 499
subst ................................................................................................................. 500
sum................................................................................................................... 501
SuperProbe....................................................................................................... 501
xiii
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
tac..................................................................................................................... 503
tail .................................................................................................................... 504
talk.................................................................................................................... 505
tcal .................................................................................................................... 506
telnet ................................................................................................................. 507
tfmtodit ............................................................................................................ 513
tftp.................................................................................................................... 514
tgatoppm .......................................................................................................... 515
tifftopnm .......................................................................................................... 515
tin, rtin, cdtin, tind........................................................................................... 516
tload.................................................................................................................. 533
top .................................................................................................................... 533
touch ................................................................................................................ 536
tr ....................................................................................................................... 536
tset, reset ........................................................................................................... 539
tsort .................................................................................................................. 542
twm .................................................................................................................. 542
txt2gcal ............................................................................................................. 558
ul ...................................................................................................................... 558
unexpand .......................................................................................................... 559
uniq .................................................................................................................. 560
unshar ............................................................................................................... 560
updatedb........................................................................................................... 561
uptime.............................................................................................................. 562
userlist ............................................................................................................... 563
uucp.................................................................................................................. 563
uuencode .......................................................................................................... 565
uustat ................................................................................................................ 566
uux.................................................................................................................... 569
uuxqt ................................................................................................................ 572
w....................................................................................................................... 573
wall ................................................................................................................... 574
wc ..................................................................................................................... 574
whereis.............................................................................................................. 575
write.................................................................................................................. 576
x11perf .............................................................................................................. 577
x11perfcomp..................................................................................................... 585
xargs.................................................................................................................. 586
xauth................................................................................................................. 587
xbmtopbm........................................................................................................ 592
xcmsdb.............................................................................................................. 592
xclock................................................................................................................ 593
xclipboard ......................................................................................................... 595
xconsole............................................................................................................ 597
xcutsel ............................................................................................................... 598
Linux CompleteCommand Reference
xiv
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
xdm .................................................................................................................. 599
xdpyinfo............................................................................................................ 614
Xf86_Accel ....................................................................................................... 614
XF86_Mono..................................................................................................... 624
XF86_SVGA .................................................................................................... 627
XF86_VGA16 .................................................................................................. 631
xf86config......................................................................................................... 633
xfd .................................................................................................................... 633
XFree86 ............................................................................................................ 636
xfs..................................................................................................................... 641
xhost ................................................................................................................. 643
xieperf ............................................................................................................... 645
ximtoppm......................................................................................................... 654
xinetd................................................................................................................ 655
xinit .................................................................................................................. 664
xkill ................................................................................................................... 666
xlogo................................................................................................................. 667
xlsatoms............................................................................................................ 668
xlsclients............................................................................................................ 669
xlsfonts.............................................................................................................. 670
xmag................................................................................................................. 671
xmkmf .............................................................................................................. 672
xmodmap.......................................................................................................... 672
xon.................................................................................................................... 676
xpmtoppm........................................................................................................ 677
xprop ................................................................................................................ 677
xrdb .................................................................................................................. 681
xrefresh ............................................................................................................. 684
Xserver .............................................................................................................. 685
xset .................................................................................................................... 690
xsetroot ............................................................................................................. 693
xsm................................................................................................................... 694
xsmclient ........................................................................................................... 698
xstdcmap........................................................................................................... 699
xterm ................................................................................................................ 700
Xvfb.................................................................................................................. 717
xvidtune............................................................................................................ 719
xvminitoppm .................................................................................................... 720
xwd................................................................................................................... 721
xwdtopnm ........................................................................................................ 722
xwininfo............................................................................................................ 722
xwud................................................................................................................. 725
ybmtopbm........................................................................................................ 726
ytalk.................................................................................................................. 727
yuvplittoppm.................................................................................................... 730
xv
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
yuvtoppm ......................................................................................................... 731
zcmp, zdiff ........................................................................................................ 731
zeisstopnm ........................................................................................................ 732
zforce................................................................................................................ 732
zgrep ................................................................................................................. 733
zmore................................................................................................................ 733
znew.................................................................................................................. 734
Part II System Calls
intro.................................................................................................................. 738
exit .................................................................................................................... 739
accept ................................................................................................................ 740
access ................................................................................................................ 741
acct ................................................................................................................... 742
adjtimex ............................................................................................................ 742
alarm................................................................................................................. 744
bdflush.............................................................................................................. 744
bind .................................................................................................................. 745
brk, sbrk............................................................................................................ 746
cacheflush ......................................................................................................... 746
chdir, fchdir ...................................................................................................... 747
chmod, fchmod................................................................................................. 748
chown, fchown ................................................................................................. 749
chroot ............................................................................................................... 750
clone................................................................................................................. 751
close.................................................................................................................. 752
connect ............................................................................................................. 752
dup, dup2 ......................................................................................................... 753
execve................................................................................................................ 754
fcntl .................................................................................................................. 755
fdatasync........................................................................................................... 756
flock.................................................................................................................. 757
fork, vfork ......................................................................................................... 758
fsync ................................................................................................................. 758
getdents ............................................................................................................ 759
getdomainname, setdomainname...................................................................... 760
getdtablesize...................................................................................................... 760
getgid, getegid................................................................................................... 761
getgroups, setgroups.......................................................................................... 761
gethostid, sethostid ........................................................................................... 762
gethostname, sethostname................................................................................. 763
getitimer, setitimer ............................................................................................ 763
getpagesize........................................................................................................ 765
getpeername...................................................................................................... 765
getpid, getppid .................................................................................................. 766
getpriority, setpriority ....................................................................................... 766
Linux CompleteCommand Reference
xvi
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
getrlimit, getrusage, setrlimit ............................................................................. 767
getsid ................................................................................................................ 768
getsockname...................................................................................................... 769
getsockopt, setsockopt ....................................................................................... 769
gettimeofday, settimeofday................................................................................ 772
getuid, geteuid .................................................................................................. 773
idle.................................................................................................................... 774
ioctl ................................................................................................................... 774
ioperm .............................................................................................................. 788
iopl ................................................................................................................... 788
ipc..................................................................................................................... 789
kill .................................................................................................................... 790
killpg................................................................................................................. 790
link ................................................................................................................... 791
listen ................................................................................................................. 792
llseek ................................................................................................................. 793
lseek .................................................................................................................. 793
mkdir ................................................................................................................ 794
mknod .............................................................................................................. 795
mlock................................................................................................................ 796
mlockall ............................................................................................................ 797
mmap, munmap ............................................................................................... 799
modify_ldt ........................................................................................................ 800
get_kernel_syms, create_module, init_module, delete_module......................... 800
mount, umount ................................................................................................ 802
mprotect ........................................................................................................... 804
mremap ............................................................................................................ 805
msgctl ............................................................................................................... 806
msgget ............................................................................................................... 807
msgop ............................................................................................................... 808
msync ............................................................................................................... 811
munlock............................................................................................................ 811
munlockall ........................................................................................................ 812
nanosleep .......................................................................................................... 813
nice................................................................................................................... 814
oldfstat, oldlstat, oldstat, oldolduname, olduname............................................ 814
open, creat ........................................................................................................ 815
outb, outw, outl, outsb, outsw, outsl ................................................................. 816
pause................................................................................................................. 817
personality ........................................................................................................ 817
phys.................................................................................................................. 818
pipe................................................................................................................... 818
profil ................................................................................................................. 819
ptrace................................................................................................................ 820
quotactl ............................................................................................................. 821
xvii
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
read................................................................................................................... 822
readdir .............................................................................................................. 823
readlink............................................................................................................. 823
readv, writev...................................................................................................... 824
reboot ............................................................................................................... 825
recv, recvfrom, recvmsg..................................................................................... 826
rename.............................................................................................................. 828
rmdir ................................................................................................................ 829
sched_get_priority_max, sched_get_priority_min ............................................. 830
sched_rr_get_interval ........................................................................................ 831
sched_setparam, sched_getparam...................................................................... 832
sched_setscheduler, sched_getscheduler ............................................................ 833
sched_yield ....................................................................................................... 835
select, FD_CLR, FD_ISSET, FD_SET, FD_ZERO......................................... 835
semctl ................................................................................................................ 837
semget ............................................................................................................... 839
semop ............................................................................................................... 840
send, sendto, sendmsg....................................................................................... 842
setfsgid.............................................................................................................. 843
setfsuid.............................................................................................................. 844
setgid ................................................................................................................ 845
setpgid, getpgid, setpgrp, getpgrp...................................................................... 845
setregid, setegid ................................................................................................. 846
setreuid, seteuid ................................................................................................ 847
setsid................................................................................................................. 848
setuid ................................................................................................................ 848
setup ................................................................................................................. 849
shmctl ............................................................................................................... 849
shmget .............................................................................................................. 851
shmop............................................................................................................... 853
shutdown .......................................................................................................... 855
sigaction, sigprocmask, sigpending, sigsuspend.................................................. 855
signal ................................................................................................................. 857
sigblock, siggetmask, sigsetmask, sigmask .......................................................... 858
sigpause............................................................................................................. 858
sigreturn............................................................................................................ 859
sigvec ................................................................................................................ 860
socket ................................................................................................................ 860
socketcall ........................................................................................................... 862
socketpair .......................................................................................................... 862
stat, fstat, lstat ................................................................................................... 863
statfs, fstatfs....................................................................................................... 865
stime................................................................................................................. 866
swapon, swapoff ................................................................................................ 866
symlink ............................................................................................................. 867
Linux CompleteCommand Reference
xviii
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
sync................................................................................................................... 869
sysctl ................................................................................................................. 869
sysfs................................................................................................................... 871
sysinfo............................................................................................................... 871
syslog ................................................................................................................ 872
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfgetospeed,
cfgetispeed, cfsetispeed, cfsetospeed, tcgetpgrp, tcsetpgrp ............................... 874
time.................................................................................................................. 878
times................................................................................................................. 878
truncate, ftruncate............................................................................................. 879
umask ............................................................................................................... 880
uname............................................................................................................... 880
none.................................................................................................................. 881
afs_syscall, break, gtty, lock, mpx, prof, quotactl, stty, ustat .............................. 881
unlink ............................................................................................................... 882
uselib ................................................................................................................ 883
ustat .................................................................................................................. 883
utime, utimes.................................................................................................... 884
vhangup ............................................................................................................ 885
vm86 ................................................................................................................ 885
wait, waitpid ..................................................................................................... 886
wait3, wait4 ...................................................................................................... 888
write.................................................................................................................. 889
Part III Library Functions
Intro ................................................................................................................. 892
abort ................................................................................................................. 892
abs .................................................................................................................... 892
acos................................................................................................................... 893
acosh................................................................................................................. 893
alloca................................................................................................................. 894
asin ................................................................................................................... 894
asinh ................................................................................................................. 895
assert ................................................................................................................. 895
atan................................................................................................................... 896
atan2................................................................................................................. 896
atanh................................................................................................................. 897
atexit ................................................................................................................. 897
atof ................................................................................................................... 898
atoi .................................................................................................................... 898
atol .................................................................................................................... 899
bcmp................................................................................................................. 899
bcopy ................................................................................................................ 900
bsearch.............................................................................................................. 900
bcmp, bcopy, bzero, memccpy, memchr, memcmp, memcpy, memfrob, memmem,
memmove, memset ......................................................................................... 901
xix
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
htonl, htons, ntohl, ntohs ................................................................................. 901
bzero................................................................................................................. 902
catgets............................................................................................................... 902
catopen, catclose ............................................................................................... 903
ceil .................................................................................................................... 904
clientlib............................................................................................................. 904
clock ................................................................................................................. 905
closedir .............................................................................................................. 905
confstr ............................................................................................................... 906
copysign............................................................................................................ 907
cos .................................................................................................................... 907
cosh .................................................................................................................. 908
crypt ................................................................................................................. 908
ctermid ............................................................................................................. 909
asctime, ctime, gmtime, localtime, mktime....................................................... 909
difftime............................................................................................................. 911
div..................................................................................................................... 911
drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48,
seed48, lcong48.............................................................................................. 912
drem ................................................................................................................. 913
ecvt, fcvt ........................................................................................................... 913
erf, erfc.............................................................................................................. 914
execl, execlp, execle, exect, execv, execvp ........................................................... 914
errno ................................................................................................................. 916
exit .................................................................................................................... 917
exp, log, log10, pow.......................................................................................... 917
expm1, log1p .................................................................................................... 918
fabs................................................................................................................... 919
fclose................................................................................................................. 919
clearerr, feof, ferror, fileno................................................................................. 919
fflush, fpurge..................................................................................................... 920
ffs...................................................................................................................... 921
fgetgrent ............................................................................................................ 921
fgetpwent .......................................................................................................... 922
floor .................................................................................................................. 923
fmod ................................................................................................................. 923
fnmatch ............................................................................................................ 924
fopen, fdopen, freopen ...................................................................................... 924
fpathconf, pathconf ........................................................................................... 925
fread, fwrite....................................................................................................... 926
frexp.................................................................................................................. 927
fgetpos, fseek, fsetpos, ftell, rewind.................................................................... 927
ftime................................................................................................................. 928
ftok ................................................................................................................... 929
ftw .................................................................................................................... 930
Linux CompleteCommand Reference
xx
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
gcvt ................................................................................................................... 930
getcwd, get_current_dir_name, getwd............................................................... 931
getdirentries...................................................................................................... 931
getenv ............................................................................................................... 932
getgrent, setgrent, endgrent ............................................................................... 932
getgrnam, getgrgid ............................................................................................ 933
getlogin, cuserid ................................................................................................ 934
getmntent, setmntent, addmntent, endmntent, hasmntopt ............................... 935
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent ........................... 936
getopt ................................................................................................................ 937
getpass............................................................................................................... 940
getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoent .... 941
getpw................................................................................................................ 942
getpwent, setpwent, endpwent .......................................................................... 943
getpwnam, getpwuid......................................................................................... 944
fgetc, fgets, getc, getchar, gets, ungetc ............................................................... 944
getservent, getservbyname, getservbyport, setservent, endservent ....................... 945
getusershell, setusershell, endusershell ............................................................... 946
getutent, getutid, getutline, pututline, setutent, endutent, utmpname............... 947
getw, putw........................................................................................................ 948
glob, globfree.................................................................................................... 949
hosts_access, hosts_ctl ....................................................................................... 950
hcreate, hdestroy, hsearch.................................................................................. 951
hypot ................................................................................................................ 953
index, rindex ..................................................................................................... 953
inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof,
inet_netof ....................................................................................................... 953
infnan ............................................................................................................... 954
initgroups.......................................................................................................... 955
inndcomm ........................................................................................................ 956
insque, remque.................................................................................................. 957
isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint,
ispunct, isspace, isupper, isxdigit ..................................................................... 957
isatty ................................................................................................................. 958
isinf, isnan, finite .............................................................................................. 959
j0, j1, jn, y0, y1, yn........................................................................................... 959
killpg................................................................................................................. 960
labs................................................................................................................... 960
ldexp................................................................................................................. 961
ldiv.................................................................................................................... 961
lgamma............................................................................................................. 962
libinn ................................................................................................................ 962
libpbm.............................................................................................................. 966
libpgm .............................................................................................................. 969
libpnm.............................................................................................................. 970
xxi
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
libppm.............................................................................................................. 973
localeconv ......................................................................................................... 974
longjmp ............................................................................................................ 975
lfind, lsearch...................................................................................................... 975
calloc, malloc, free, realloc................................................................................. 976
mblen................................................................................................................ 977
mbstowcs.......................................................................................................... 977
mbtowc............................................................................................................. 978
memccpy .......................................................................................................... 978
memchr ............................................................................................................ 979
memcmp........................................................................................................... 979
memcpy ............................................................................................................ 980
memfrob ........................................................................................................... 980
memmem.......................................................................................................... 981
memmove......................................................................................................... 981
memset ............................................................................................................. 982
mkfifo............................................................................................................... 982
mkstemp ........................................................................................................... 983
mktemp ............................................................................................................ 983
modf ................................................................................................................. 984
asctime, ctime, difftime, gmtime, localtime, mktime......................................... 984
tzset .................................................................................................................. 986
on_exit .............................................................................................................. 988
opendir ............................................................................................................. 989
parsedate........................................................................................................... 989
perror ................................................................................................................ 990
popen, pclose.................................................................................................... 991
printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf .................. 992
psignal .............................................................................................................. 996
putenv............................................................................................................... 996
putpwent .......................................................................................................... 997
fputc, fputs, putc, putchar, puts........................................................................ 997
qio .................................................................................................................... 998
qsort ................................................................................................................ 1000
raise ................................................................................................................ 1000
rand, srand...................................................................................................... 1001
random, srandom, initstate, setstate................................................................ 1001
readdir ............................................................................................................ 1002
readv, writev.................................................................................................... 1003
realpath........................................................................................................... 1004
Re_comp, re_exec ........................................................................................... 1005
regcomp, regexec, regerror, regfree.................................................................. 1005
remove............................................................................................................ 1007
res_query, res_search, res_mkquery, res_send, res_init, dn_comp,
dn_expand.................................................................................................... 1008
Linux CompleteCommand Reference
xxii
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
rewinddir ........................................................................................................ 1011
rint .................................................................................................................. 1011
rquota............................................................................................................. 1012
scandir, alphasort ............................................................................................ 1012
scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf ..................................................... 1013
seekdir ............................................................................................................. 1015
setbuf, setbuffer, setlinebuf, setvbuf ................................................................. 1016
setenv.............................................................................................................. 1017
setjmp ............................................................................................................. 1018
setlocale........................................................................................................... 1018
siginterrupt ..................................................................................................... 1019
sigemptyset, sigfillset, sigaddset, sigdelset, sigismember ................................... 1019
sin ................................................................................................................... 1020
sinh................................................................................................................. 1021
sleep................................................................................................................ 1021
snprintf, vsnprintf ........................................................................................... 1022
sqrt .................................................................................................................. 1023
stdarg.............................................................................................................. 1023
stdio................................................................................................................ 1025
stpcpy ............................................................................................................. 1027
strcasecmp, strncasecmp.................................................................................. 1028
strcat, strncat ................................................................................................... 1028
strchr, strrchr .................................................................................................. 1029
strcmp, strncmp .............................................................................................. 1029
strcoll .............................................................................................................. 1030
strcpy, strncpy................................................................................................. 1030
strdup ............................................................................................................. 1031
strerror ............................................................................................................ 1032
strfry ............................................................................................................... 1032
strftime........................................................................................................... 1032
strcasecmp, strcat, strchr, strcmp, strcoll, strcpy, strcspn, strdup, strfry,
strlen, strncat, strncmp, strncpy, strncasecmp, strpbrk, strrchr, strsep,
strspn, strstr, strtok, strxfrm, index, rindex ................................................... 1034
strlen............................................................................................................... 1035
strpbrk ............................................................................................................ 1035
strptime .......................................................................................................... 1036
strsep............................................................................................................... 1037
strsignal ........................................................................................................... 1038
strspn, strcspn ................................................................................................. 1038
strstr ................................................................................................................ 1039
strtod .............................................................................................................. 1039
strtok .............................................................................................................. 1040
strtol ............................................................................................................... 1041
strtoul ............................................................................................................. 1041
strxfrm............................................................................................................ 1042
xxiii
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
swab................................................................................................................ 1043
sysconf ............................................................................................................ 1043
closelog, openlog, syslog.................................................................................. 1045
system............................................................................................................. 1047
tan .................................................................................................................. 1047
tanh ................................................................................................................ 1048
telldir .............................................................................................................. 1048
tempnam ........................................................................................................ 1049
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfmakeraw,
cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, tcgetpgrp, tcsetpgrp.......... 1049
tmpfile............................................................................................................ 1053
tmpnam.......................................................................................................... 1054
toascii .............................................................................................................. 1055
toupper, tolower .............................................................................................. 1055
tsearch, tfind, tdelete, twalk ............................................................................ 1056
ttyname........................................................................................................... 1058
tzset ................................................................................................................ 1058
none................................................................................................................ 1060
usleep.............................................................................................................. 1061
wcstombs........................................................................................................ 1061
wctomb........................................................................................................... 1061
Part IV Special Files
charsets........................................................................................................... 1064
console............................................................................................................ 1066
console_codes ................................................................................................. 1067
console ioctls................................................................................................... 1074
fd .................................................................................................................... 1080
hd ................................................................................................................... 1083
ispell ............................................................................................................... 1084
lp .................................................................................................................... 1090
mem, kmem, port ........................................................................................... 1091
mouse............................................................................................................. 1092
null, zero......................................................................................................... 1094
ram ................................................................................................................. 1094
sd .................................................................................................................... 1095
st ..................................................................................................................... 1096
tty ................................................................................................................... 1100
ttys.................................................................................................................. 1101
vcs, vcsa .......................................................................................................... 1101
Part V File Formats
intro................................................................................................................ 1104
active, active.times .......................................................................................... 1104
adduser.conf .................................................................................................... 1105
aliases.............................................................................................................. 1106
Linux CompleteCommand Reference
xxiv
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
cfingerd........................................................................................................... 1106
cfingerd.conf ................................................................................................... 1109
cfingerd text rules.............................................................................................1115
control.ctl ....................................................................................................... 1115
cvs................................................................................................................... 1116
DEVINFO ..................................................................................................... 1120
environ............................................................................................................ 1121
expire.ctl ......................................................................................................... 1121
exports............................................................................................................ 1123
filesystems....................................................................................................... 1125
fstab ................................................................................................................ 1126
groff_font ........................................................................................................ 1127
groff_out ......................................................................................................... 1129
group .............................................................................................................. 1131
history............................................................................................................. 1131
hosts.nntp, hosts.nntp.nolimit ........................................................................ 1132
hosts_access..................................................................................................... 1133
hosts_options.................................................................................................. 1137
inittab ............................................................................................................. 1139
inn.conf .......................................................................................................... 1141
innwatch.ctl .................................................................................................... 1142
ipc................................................................................................................... 1144
issue................................................................................................................ 1146
lilo.conf ........................................................................................................... 1147
MAKEDEV.cfg .............................................................................................. 1151
moderators...................................................................................................... 1151
/etc/modules................................................................................................... 1152
motd............................................................................................................... 1152
mtools............................................................................................................. 1152
newsfeeds........................................................................................................ 1158
newslog........................................................................................................... 1163
nfs................................................................................................................... 1165
nnrp.access...................................................................................................... 1167
nntpsend.ctl .................................................................................................... 1168
nologin ........................................................................................................... 1168
overview.fmt ................................................................................................... 1168
passwd ............................................................................................................ 1169
passwd.nntp.................................................................................................... 1170
pbm................................................................................................................ 1170
pgm ................................................................................................................ 1171
pnm................................................................................................................ 1173
ppm................................................................................................................ 1173
/proc............................................................................................................... 1174
protocols......................................................................................................... 1180
rcsfile.............................................................................................................. 1181
xxv
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
resolver ............................................................................................................ 1183
securetty.......................................................................................................... 1184
services............................................................................................................ 1184
shells............................................................................................................... 1186
syslog.conf ...................................................................................................... 1186
termcap........................................................................................................... 1188
ttytype............................................................................................................. 1197
tzfile................................................................................................................ 1197
utmp, wtmp.................................................................................................... 1198
uuencode ........................................................................................................ 1200
XF86Config.................................................................................................... 1201
Part VI Games
intro................................................................................................................ 1210
banner ............................................................................................................. 1210
ddate............................................................................................................... 1210
Part VII Miscellaneous
intro................................................................................................................ 1214
ascii ................................................................................................................. 1214
bootparam ...................................................................................................... 1216
groff_me......................................................................................................... 1225
groff_mm........................................................................................................ 1227
groff_ms.......................................................................................................... 1234
hier ................................................................................................................. 1236
hostname........................................................................................................ 1238
iso_8859_1 ..................................................................................................... 1239
locale............................................................................................................... 1243
mailaddr .......................................................................................................... 1244
man ................................................................................................................ 1246
signal ............................................................................................................... 1248
suffixes............................................................................................................ 1249
tr2tex .............................................................................................................. 1252
Unicode.......................................................................................................... 1253
UTF-8 ............................................................................................................ 1255
Part VIII Administration and Privileged Commands
intro................................................................................................................ 1258
adduser, addgroup........................................................................................... 1258
agetty .............................................................................................................. 1259
archive............................................................................................................ 1262
arp .................................................................................................................. 1263
badblocks........................................................................................................ 1264
buffchan.......................................................................................................... 1264
cfdisk .............................................................................................................. 1265
chat ................................................................................................................. 1269
Linux CompleteCommand Reference
xxvi
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
chroot ............................................................................................................. 1273
clock ............................................................................................................... 1273
comsat ............................................................................................................. 1274
crond .............................................................................................................. 1275
ctlinnd ............................................................................................................ 1276
ctrlaltdel .......................................................................................................... 1279
cvsbug............................................................................................................. 1279
cvtbatch .......................................................................................................... 1281
cytune............................................................................................................. 1282
debugfs ........................................................................................................... 1284
dip .................................................................................................................. 1285
dmesg.............................................................................................................. 1288
dumpe2fs........................................................................................................ 1289
e2fsck.............................................................................................................. 1289
edquota........................................................................................................... 1291
expire.............................................................................................................. 1292
expireover ....................................................................................................... 1293
fastrm.............................................................................................................. 1294
fdformat .......................................................................................................... 1295
fdisk ................................................................................................................ 1296
filechan ........................................................................................................... 1297
fsck ................................................................................................................. 1298
fsck.minix ....................................................................................................... 1300
ftpd................................................................................................................. 1301
ifconfig............................................................................................................ 1304
inetd ............................................................................................................... 1305
init, telinit ....................................................................................................... 1307
innd, inndstart ................................................................................................ 1309
innxmit ........................................................................................................... 1312
ipcrm.............................................................................................................. 1313
ipcs................................................................................................................. 1314
kbdrate............................................................................................................ 1314
klogd............................................................................................................... 1315
lpc................................................................................................................... 1317
lpd .................................................................................................................. 1318
MAKEDEV .................................................................................................... 1320
MAKEDEV .................................................................................................... 1321
mke2fs............................................................................................................ 1324
mkfs................................................................................................................ 1325
mkfs................................................................................................................ 1326
mklost+found.................................................................................................. 1327
mkswap........................................................................................................... 1327
mount, umount .............................................................................................. 1328
mountd........................................................................................................... 1332
named-xfer ...................................................................................................... 1333
xxvii
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
named............................................................................................................. 1334
named.reload .................................................................................................. 1338
named.restart .................................................................................................. 1338
ndc.................................................................................................................. 1338
netstat ............................................................................................................. 1339
makeactive, makehistory, newsrequeue............................................................ 1342
news.daily ....................................................................................................... 1344
newslog........................................................................................................... 1346
nfsd................................................................................................................. 1347
nnrpd.............................................................................................................. 1347
nntpsend......................................................................................................... 1349
nslookup ......................................................................................................... 1350
overchan ......................................................................................................... 1353
pac .................................................................................................................. 1354
pcnfsd ............................................................................................................. 1355
plipconfig........................................................................................................ 1357
ping ................................................................................................................ 1358
portmap .......................................................................................................... 1358
powerd............................................................................................................ 1359
pppd ............................................................................................................... 1360
pppstats........................................................................................................... 1369
prunehistory.................................................................................................... 1370
quotacheck ...................................................................................................... 1371
quotaon, quotaoff ........................................................................................... 1372
rarp ................................................................................................................. 1373
rdev................................................................................................................. 1373
renice.............................................................................................................. 1375
repquota.......................................................................................................... 1376
rexecd ............................................................................................................. 1376
rlogind ............................................................................................................ 1377
route............................................................................................................... 1379
routed ............................................................................................................. 1380
rpc.rusersd ...................................................................................................... 1382
rpc.rwalld........................................................................................................ 1383
rpcinfo ............................................................................................................ 1383
rquotad, rpc.rquotad ....................................................................................... 1384
rshd................................................................................................................. 1385
rwhod ............................................................................................................. 1386
sendmail .......................................................................................................... 1387
setfdprm.......................................................................................................... 1391
setserial ........................................................................................................... 1391
setsid............................................................................................................... 1395
showmount ..................................................................................................... 1396
shutdown ........................................................................................................ 1396
simpleinit ........................................................................................................ 1397
Linux CompleteCommand Reference
xxviii
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
slattach............................................................................................................ 1399
sliplogin .......................................................................................................... 1399
swapon, swapoff .............................................................................................. 1401
sync................................................................................................................. 1401
sysklogd .......................................................................................................... 1402
syslogd ............................................................................................................ 1404
talkd................................................................................................................ 1405
telnetd............................................................................................................. 1406
tftpd................................................................................................................ 1407
timed .............................................................................................................. 1407
timedc............................................................................................................. 1408
traceroute........................................................................................................ 1409
tune2fs............................................................................................................ 1412
tunelp ............................................................................................................. 1413
update_state.................................................................................................... 1414
uucico............................................................................................................. 1415
vmstat ............................................................................................................. 1417
vipw................................................................................................................ 1418
zdump............................................................................................................. 1419
zic ................................................................................................................... 1419
Part IX Kernel Reference Guide
add_timer, del_timer, init_timer ..................................................................... 1424
adjust_clock .................................................................................................... 1424
ctrl_alt_del ...................................................................................................... 1425
file_table......................................................................................................... 1425
file_table_init .................................................................................................. 1427
filesystems....................................................................................................... 1427
get_empty_filp................................................................................................ 1428
grow_files........................................................................................................ 1428
in_group_p ..................................................................................................... 1429
insert_file_free................................................................................................ 1429
kernel_mktime................................................................................................ 1430
proc_sel ........................................................................................................... 1430
put_file_last .................................................................................................... 1431
remove_file_free.............................................................................................. 1431
Tell Us What You Think!
Asa reader, you are the most important critic of and commentator on our books. We value your opinion and
want to know what were doing right, what we could do better, what areasyoud like to see uspublish in, and
any other wordsof wisdom youre willing to passour way. You can help usmake strong booksthat meet your
needsand give you the computer guidance you require.
Do you have accessto the World Wide Web?Then check out our site at http://www.mcp.com.
NOTE
If you have a technical question about thisbook, call the technical support line at 317-581-3833 or e-mail
support@mcp.com.
Asthe team leader of the group that created thisbook, I welcome your comments. You can fax, e-mail, or
write me directly to let me know what you did or didnt like about thisbookaswell aswhat we can do to
make our booksstronger. Heresthe information:
Fax: 317-581-4669
E-mail: opsys_mgr@sams.mcp.com
Mail: Dean Miller
CommentsDepartment
SamsPublishing
201 W. 103rd Street
Indianapolis, IN 46290
Linux CompleteCommand Reference
xxx
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
Copyright
exit(2), access(2), alarm(2), close(2), dup(2), fcntl(2), link(2), mkdir(2), mknod(2), open(2), read(2), rename(2),
rmdir(2), symlink(2), write(2) copyright 1992 Drew Eckhardt; 1993 Michael Haardt, Ian Jackson.
unlink(2), remove(3) copyright 1992 Drew Eckhardt; 1993 Ian Jackson.
chdir(2), chmod(2), chown(2), chroot(2), clone(2), execve(2), fork(2), getrlimit(2), gettimeofday(2), kill(2),
nice(2), pause(2), pipe(2), reboot(2), setup(2), stime(2), swapon(2), sync(2), time(2), times(2), umask(2),
uname(2), uselib(2), utime(2) copyright 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992.
mprotect(2) copyright 1995 Michael Shields(shields@tembel.org).
select(2) copyright 1992 Drew Eckhardt, copyright 1995 Michael Shields.
acct(2), brk(2), intro(2), ioperm(2), phys(2), ptrace(2), setsid(2), termios(2), ascii(7), crypt(3), environ(5),
ftime(3), ftw(3), group(5), hd(4), intro(1), intro(3), intro(4), intro(5), intro(6), intro(7), intro(8), isatty(3),
issue(5), longjmp(3), mem(4), motd(5), nologin(5), null(4), passwd(5), ram(4), securetty(5), setjmp(3), shells(5),
termcap(7), tty(4), ttys(4), ttytype(5), utmp(5), lp(4), perror(3) copyright 1993, 1994, 1995 Michael
Haardt.
bind(2), connect(2), flock(2), fsync(2), getdomainname(2), getdtablesize(2), getgid(2), getgroups(2),
gethostid(2), gethostname(2), getpagesize(2), getpid(2), getuid(2), idle(2), iopl(2), profil(2), recv(2),
sigvec(2), undocumented(2), vhangup(2), vm86(2), acosh(3), getdiren-tries(3), ctrlaltdel(8), dmesg(8),
fdformat(8), fdisk(8), fsck.minix(8), ipcrm(8), ipcs(8), sync(8), sd(4), clear(1), clock(8), domainname(1),
mkfs.minix(8), mkswap(8), passwd(1), rdev(8), reset(1), setfdprm(8), setserial(8), shutdown(8), kbdrate(8),
update state(8), chkdupexe(1), cytune(8) copyright 1992, 1993, 1994, 1995 Rickard E. Faith
(faith@cs.unc.edu).
getdents(2), llseek(2), readdir(2), syslog(2), console.4 copyright 1994, 1995 AndriesBrouwer (aeb@cwi.nl).
mount(2) copyright 1993 Rickard E. Faith (faith@cs.unc.edu), copyright 1994 AndriesE. Brouwer
(aeb@cwi.nl).
adjtimex(2), bdflush(2), ipc(2), modify ldt(2), obsolete(2), socketcall(2), unimplemented(2) copyright 1995
Michael Chastain (mec@shell.portal.com).
accept(2), getpeername(2), listen(2), lseek(2), getpriority(2), getsockname(2), getsockopt(2), ioctl(2),
killpg(2), mmap(2), readlink(2), send(2), setpgid(2), setregid(2), setreuid(2), shut-down(2), sigblock(2),
sigpause(2), socket(2), socketpair(2), statfs(2),truncate(2), alloca(3), fclose(3), ferror(3), fflush(3),
fread(3), fseek(3), getpass(3), mailaddr(7), popen(3), printf(3), scanf(3), setbuf(3), stdarg(3), stdio(3),
banner(6), cal(1), col(1), colcrt(1), colrm(1), column(1), fstab(5), getoptprog(1), logger(1), look(1), lpc(8),
lpd(8), lpq(1), lpr(1), lprm(1), lptest(1), mesg(1), mount(8), pac(8), ping(8), syslog.conf(5), syslogd(8),
tsort(8), vipw(1), write(1), vi(1), rev(1), biff(1), tset(1), w(1), aliases(5), ftp(1), ftpd(8), inetd(8),
newaliases(1), rcp(1), resolver(5), rexecd(8), rlogin(1), routed(8), rpc.rusersd(8), rpc.rwalld(8), rsh(1),
rshd(8), rup(1), rusers(1), rwall(1), rwho(1), rwhod(8), sendmail(8), sliplogin(8), talk(1), talkd(8), telnet(1),
telnetd(8), tftp(1), tftpd(8), timed(8), timedc(8), traceroute(8) copyright 1980, 1983, 1985, 1989, 1990,
1991, 1992 The Regentsof the University of California. All rightsreserved.
getitimer(2) copyright 1993 by Darren Senn (sinster@scintilla.santa-clara.ca.us).
modules(2), ksyms(1), insmod(1), lsmod(1), rmmod(1) copyright 1994, 1995 Bjorn Ekwall (bj0rn@blox.se).
msgctl(2), msgget(2), msgop(2), semctl(2), semget(2), semop(2), ftok(3), ipc(5) copyright 1993 Giorgio Ciucci
(giorgio@crcc.it).
setgid(2), setuid(2), realpath(3) copyright 1994, Graeme W. Wilford.
xxxi
Introduction
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
shmctl(2), shmget(2), shmop(2) copyright 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993.
sigaction(2), signal(2), sigsetops(3) copyright 1994 Mike Battersby (mike@starbug.apana.org.au).
stat(2) copyright 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992. Partscopyright 1995
Nicolai Langfeldt (janl@ifi.uio.no), January 1, 1995.
sysinfo(2), adjustclock(9), ctrl-alt-del(9), filesystems(9), file table(9), file table init(9), get empty
filp(9), grow files(9), in group p(9), insert file free(9), kernel mktime(9), proc sel(9), put file last(9),
remove file free(9) copyright 1993 by Dan Miner (dminer@nyx.cs.du.edu).
wait(2), wait4(2), confstr(3), ctermid(3), fnmatch(3), fpathconf(3), getcwd(3), getopt(3), gets(3), isalpha(3),
malloc(3), signal(7), sleep(3), suffixes(7), sysconf(3), system(3), hier(7), assert(3), glob(3), killpg(3),
locale(7), localeconv(3), puts(3), raise(3), readv(3), setlocale(3) copyright 1993 by ThomasKoenig
(ig25@rz.uni-karlsruhe.de).
abort(3), abs(3), acos(3),asin(3), asinh(3),atan(3), atan2(3), atanh(3), atexit(3), atof(3), atoi(3), atol(3),
bcmp(3), bcopy(3), bstring(3), byteorder(3), bzero(3), ceil(3), closedir(3), confstr(3), copysign(3), cos(3),
cosh(3), ctime(3), difftime(3), div(3), drand48(3), drem(3), ecvt(3), erf(3), exec(3), exit(3), exp(3), fabs(3),
ffs(3), fgetgrent(3), fgetpwent(3), fmod(3), fopen(3), frexp(3), gcvt(3), getenv(3), getgrent(3), getgrnam(3),
gethostbyname(3), getm-ntent(3), getnetent(3), getprotoent(3), getpw(3), getpwent(3), getpwnam(3),
getservent(3), getusershell(3), hypot(3), index(3), inet(3), infnan(3), initgroups(3), isinf(3), j0(3), labs(3),
ldexp(3), ldiv(3), lgamma(3), mblen(3), mbstowcs(3), mbtowc(3), memccpy(3), mem-chr(3), memcmp(3), memcpy(3),
memfrob(3), memmem(3), memmove(3), memset(3), mkstemp(3), mktemp(3), modf(3), on exit(3), opendir(3),
psignal(3), putenv(3), putpwent(3), qsort(3), rand(3), random(3), readdir(3), resolver(3), rewinddir(3), rint(3),
scandir(3), seekdir(3), setenv(3), siginterrupt(3), sin(3), sinh(3), sqrt(3), strcmp(3), strcat(3), strchr(3),
strcmp(3), strcoll(3), strcpy(3), strdup(3), strerror(3), strfry(3), strftime(3), string(3), strlen(3), strp-
break(3), strptime(3), strsep(3), strsignal(3), strspn(3), strstr(3), strtod(3), strtok(3), str-tol(3),
strtoul(3), strxfrm(3), swab(3), tan(3), tanh(3), telldir(3), tempnam(3), tmpfile(3), tmpnam(3), toupper(3),
tzset(3), usleep(3), wcstombs(3), wctomb(3) copyright 1993 David Metcalfe (david@prism.demon.co.uk).
add timer(9), console ioctl(4), ttyname(3), vcs(4) copyright 1995 Jim Van Zandt (jrv@vanzandt.mv.com).
catgets(3), catopen(3), hostid(1) copyright 1993 Mitchum DSouza (m.dsouza@mrc-applied-
psychology.cambridge.ac.uk).
fd(4) copyright 1993 Michael Haardt (michael@cantor.informatik.rwth-aachen.de) and 1994, 1995 Alain
Knaff (Alain.Knaff@imag.fr).
getutent(3) copyright 1995 Mark D. Roth (roth@uiuc.edu).
hsearch(3) copyright 1993 Ulrich Drepper (drepper@karlsruhe.gmd.de).
iso88591(7), proc(5), sed(1) copyright 1993[nd]1995 Daniel Quinlan (quinlan@yggdrasil.com).
st(4) copyright 1995 Robert K. Nichols(Robert.K.Nichols@att.com).
agetty(8) copyright by W.Z. Venema (wietse@wzv.win.tue.nl), Peter Orbaek (poe@daimi.aau.dk).
cfdisk(8) copyright 1994 Kevin E. Martin (martin@cs.unc.edu).
chfn(1), chsh.1 copyright 1994 by Salvatore Valente (svalente@athena.mit.edu).
crond(8), crontab(1) copyright 1994 Matthew Dillon (dillon@apollo.west.oic.com).
kill(1) copyright 1994 Salvatore Valente (svalente@mit.edu), copyright 1992 Rickard E. Faith
(faith@cs.unc.edu).
klogd(8), sysklogd(8) copyright 1994 Greg Wettstein, Enjellic SystemsDevelopment.
Linux CompleteCommand Reference
xxxii
gr11 Linux Complete Command Reference 31104-6 christy 11.6.97 FM lp3
setterm(1) copyright 1990 Gordon Irlam (gordoni@cs.ua.oz.au). Copyright 1992 Rickard E. Faith
(faith@cs.unc.edu).
tunelp(8), ps(1), psupdate(8) copyright 1992 Michael K. Johnson (johnsonm@nigel.vnet.net).
xinetd(1) copyright 1992 by PanagiotisTsirigotis.
bash(1) copyright 1995 Chet Ramey (chet@ins.cwru.edu).
adduser(8) copyright 1995 by Ted Hajek, 1994 by Ian Murdock.
e2fsck(8) copyright 1993, 1994 by Theodore Tso.
free(1), tload(1) copyright 1993 Matt Welsh (mdw@sunsite.unc.edu).
top(1) copyright 1992 Robert J. Nation.
vmstat(8) copyright 1994 Henry Ware (al172@yfn.ysu.edu).
bdftopcf(1x), beforelight(1x), bitmap(1x), editres(1x), fsinfo(1x), flsfonts(1x),fstobdf(1x), iceauth(1x),
imake(1x), lbxproxy(1x), lndir(1x), makedepend(1x), makestrs(1x), mkdirhier(1x), mkfontdir(1x), oclock(1x),
resize(1x), sessreg(1x), showrgb(1x), smproxy(1x), startx(1x), x11perf(1x), x11perfcomp(1x), xauth(1x),
xclipboard(1x), xclock(1x), xcmsdb(1x), xcon-sole(1x), xcutsel(1x), xdm(1x), xdpyinfo(1x), xf86config(1x),
xfd(1x), xfs(1x), xhost(1x), xinit(1x), xkill(1x), xlogo(1x), xlsatoms(1x), xlsclients(1x), xlsfonts(1x),
xmag(1x), xmkmf(1x), xmodmap(1x), xon(1x), xprop(1x), xrdb(1x), xrefresh(1x), xset(1x), xsetroot(1x), xsm(1x),
xsmclient(1x), xstdcmap(1x), xterm(1x), xwd(1x), xwininfo(1x), xwud(1x) copyright 1993, 1994 X Consor-
tium.
portmap(8) copyright 1987 Sun Microsystems, copyright 1990, 1991 The Regentsof the University of
California.
rpcgen.new(1) copyright 1988, 1990 Sun Microsystems, Inc.
rstart(1x), rstartd(1x) copyright 1993 Quarterdeck Office Systems.
showmount(8) copyright 1993 Rick Sladkey (jrs@world.std.com).
twm(1x) copyright 1993, 1994 X Consortium. Portionscopyright 1988 Evans& Sutherland Computer
Corporation. Portionscopyright 1989 Hewlett-Packard Company.
xieperf.1x copyright 1993, 1994 by AGE Logic, Inc.
Many thanksto all these contributorsfor providing excellent-quality man pagesand also to the Free Software
Foundation for providing the rest.
1
User Commands
Part I:
Part I: User Commands
2
Introduction
Thissection introducesand describesuser commands.
AUTHORS
Look at the header of the manual page for the author(s) and copyright conditions. Note that these can be different from page
to page.
addftinfo
addftinfoAdd information to troff font filesfor use with groff
SYNOPSIS
addftinfo [ paramvalue... ] res uni t wi dt h f ont
DESCRIPTION
addftinfo readsa troff font file and addssome additional font-metric information that isused by the groff system. The font
file with the information added iswritten on the standard output. The information added isguessed using some parametric
information about the font and assumptionsabout the traditional troff namesfor characters. The main information added
isthe heightsand depthsof characters. The res and unitwidth argumentsshould be the same asthe corresponding param-
etersin the DESC file; font isthe name of the file describing the font; if font endswith I, the font will be assumed to be italic.
OPTIONS
Each of the f optionschangesone of the parametersthat isused to derive the heightsand depths. Like the existing quantities
in the font file, each value isin inches/resfor a font whose point size isunitwidth. param must be one of the following:
x-height The height of lowercase letterswithout ascenderssuch asx
fig-height The height of figures(digits)
asc-height The height of characterswith ascenders, such asb, d, or l
body-height The height of characterssuch asparentheses
cap-height The height of uppercase letterssuch asA
comma-depth The depth of a comma
desc-depth The depth of characterswith descenders, such asp, q, or y
body-depth The depth of characterssuch asparentheses
addftinfo makesno attempt to use the specified parametersto guessthe unspecified parameters. If a parameter isnot
specified, the default will be used. The defaultsare chosen to have the reasonable valuesfor a Timesfont.
SEE ALSO
font(5) groff_font(5), groff(1), groff_char(7)
Groff Version 1.09, 6 August 1992
afmtodit
afmtoditCreate font filesfor use with groff Tps
SYNOPSIS
afmtodit [ ns ][ddesc_f i l e ][eenc_f i l e ][in ][an ] af m_f i l e map_f i l e f ont
3
DESCRIPTION
afmtodit createsa font file for use with groff and grops. afmtodit iswritten in Perl; you must have Perl version 3 installed in
order to run afmtodit. afm_file isthe AFM (Adobe Font Metric) file for the font. map_file isa file that sayswhich groff
character namesmap onto each PostScript character name; thisfile should contain a sequence of linesof the form:
ps_char gr of f _char
where ps_char isthe PostScript name of the character and groff_char isthe groff name of the character (asused in the groff
font file.) The same ps_char can occur multiple timesin the file; each groff_char must occur, at most, once. font isthe groff
name of the font. If a PostScript character isin the encoding to be used for the font but isnot mentioned in map_file, then
afmtodit will put it in the groff font file asan unnamed character, which can be accessed by the \N escape sequence in troff.
The groff_font file will be output to a file called font.
If there isa downloadable font file for the font, it may be listed in the file /usr/lib/groff/font/devps/download; see grops(1).
If the i option isused, afmtodit will automatically generate an italic correction, a left italic correction, and a subscript
correction for each character (the significance of these parametersisexplained in groff_font(5)); these parametersmay be
specified for individual charactersby adding to the afm_file linesof the form:
italicCorrectionps charn
leftItalicCorrectionps charn
subscriptCorrectionps charn
where ps_char isthe PostScript name of the character, and n isthe desired value of the corresponding parameter in thou-
sandthsof an em. These parametersare normally needed only for italic (or oblique) fonts.
OPTIONS
n Dont output a ligaturescommand for thisfont. Use thiswith constant-width fonts.
s The font isspecial. The effect of thisoption isto add the special command to the font file.
ddesc_f i l e The device description file isdesc_f i l e rather than the default DESC.
eenc_f i l e The PostScript font should be reencoded to use the encoding described in enc_f i l e. The format of
enc_f i l e isdescribed in grops(1).
an Use n asthe slant parameter in the font file; thisisused by groff in the positioning of accents. By
default, afmtodit usesthe negative of the ItalicAngle specified in the af m_f i l e; with true italic
fonts, it issometimesdesirable to use a slant that islessthan this. If you find that charactersfrom
an italic font have accentsplaced too far to the right over them, then use the a option to give the
font a smaller slant.
in Generate an italic correction for each character so that the characterswidth plusthe characters
italic correction isequal to n thousandthsof an em plusthe amount by which the right edge of the
charactersbounding isto the right of the charactersorigin. If thiswould result in a negative italic
correction, use a zero italic correction instead.
Also generate a subscript correction equal to the product of the tangent of the slant of the font and
four-fifthsof the x-height of the font. If thiswould result in a subscript correction greater than the
italic correction, use a subscript correction equal to the italic correction instead.
Also generate a left italic correction for each character equal to n thousandthsof an em plusthe
amount by which the left edge of the charactersbounding box isto the left of the characters
origin. The left italic correction may be negative.
Thisoption isnormally needed only with italic (or oblique) fonts. The font filesdistributed with
groff were created using an option of i50 for italic fonts.
FILES
/usr/lib/groff/font/devps/DESC Device description file
/usr/lib/groff/font/devps/F Font description file for font F
/usr/lib/groff/font/devps/download List of downloadable fonts
afmtodit
Part I: User Commands
4
/usr/lib/groff/font/devps/text.enc Encoding used for text fonts
/usr/lib/groff/font/devps/generate/textmap Standard mapping
SEE ALSO
groff(1), grops(1), groff_font(5), perl(1)
Groff Version 1.09, 14 February1994
ansi2knr
ansi2knrConvert ANSI C to Kernighan & Ritchie C
SYNOPSIS
ansi2knr i nput _f i l e out put _f i l e
DESCRIPTION
If no out put _f i l e issupplied, output goesto stdout. There are no error messages.
ansi2knr recognizesfunctionsby seeing a nonkeyword identifier at the left margin, followed by a left parenthesis, with a right
parenthesisasthe last character on the line. It will recognize a multiline header if the last character on each line but the last is
a left parenthesisor comma. These algorithmsignore whitespace and comments, except that the function name must be the
first thing on the line.
The following constructswill confuse it:
I Any other construct that startsat the left margin and followsthe above syntax (such asa macro or function call)
I Macrosthat tinker with the syntax of the function header
31 December 1990
anytopnm
anytopnmAttempt to convert an unknown type of image file to a portable anymap
SYNOPSIS
anytopnm f i l e
DESCRIPTION
anytopnm usesthe file program, possibly augmented by the magic numbersfile included with PBMPLUS, to try to figure out
what type of image file it is. If that fails(very few image formatshave magic numbers), looksat the filename extension. If
that fails, punt.
The type of the output file dependson the input file.
SEE ALSO
pnmfile(1), pnm(5), file(1)
BUGS
Itsa script. Scriptsare not portable to non-UNIX environments.
AUTHOR
Copyright 1991 by Jef Poskanzer
27 July1990
5
appres
appresList X application resource database
SYNOPSIS
appres [[cl ass [i nst ance]] [1] [t ool ki t opt i ons]
DESCRIPTION
The appres program printsthe resourcesseen by an application (or subhierarchy of an application) with the specified class
and instance names. It can be used to determine which resourcesa particular program will load. For example,
% appres XTerm
will list the resourcesthat any xterm program will load. If no application classisspecified, the class-AppResTest- isused.
To match a particular instance name, specify an instance name explicitly after the classname, or use the normal Xt toolkit
option. For example,
% appres XTerm myxterm
or
% appres XTerm name myxterm
To list resourcesthat match a subhierarchy of an application, specify hierarchical classand instance names. The number of
classand instance componentsmust be equal, and the instance name should not be specified with a toolkit option. For
example,
% appres Xman.TopLevelShell.Form xman.topBox.form
will list the resourcesof widgetsof xman topBox hierarchy. To list just the resourcesmatching a specific level in the hierarchy,
use the 1 option. For example,
% appres XTerm.VT100 xterm.vt100 1
will list the resourcesmatching the xterm vt100 widget.
SEE ALSO
X(1), xrdb(1), listres(1)
AUTHOR
Jim Fulton (MIT X Consortium)
X Version 11 Release6
ar
arCreate, modify, and extract from archives
SYNOPSIS
ar [ - ] dmpqrtx[abcilosuvV] [ member name ] ar chi ve f i l es ...
DESCRIPTION
The GNU ar program creates, modifies, and extractsfrom archives. An archive isa single file holding a collection of other
filesin a structure that makesit possible to retrieve the original individual files(called membersof the archive).
The original files contents, mode (permissions), timestamp, owner, and group are preserved in the archive, and may be
reconstituted on extraction.
ar
Part I: User Commands
6
GNU ar can maintain archiveswhose membershave namesof any length; however, depending on how ar isconfigured on
your system, a limit on member-name length may be imposed (for compatibility with archive formatsmaintained with other
tools). If it exists, the limit isoften 15 characters(typical of formatsrelated to a.out) or 16 characters(typical of formats
related to coff).
ar isconsidered a binary utility because archivesof thissort are most often used aslibrariesholding commonly needed
subroutines.
ar will create an index to the symbolsdefined in relocatable object modulesin the archive when you specify the modifier s.
Once created, thisindex isupdated in the archive whenever ar makesa change to itscontents(save for the q update
operation). An archive with such an index speedsup linking to the library, and allowsroutinesin the library to call each
other without regard to their placement in the archive.
You may use nm s or nm printarmap to list thisindex table. If an archive lacksthe table, another form of ar called ranlib
can be used to add just the table.
ar insistson at least two argumentsto execute: one keyletter specifying the operation (optionally accompanied by other
keylettersspecifying modifiers), and the archive name to act on.
Most operationscan also accept further filesarguments, specifying particular filesto operate on.
OPTIONS
GNU ar allowsyou to mix the operation code p and modifier flagsmod in any order, within the first command-line
argument.
If you wish, you may begin the first command-line argument with a dash.
The p keyletter specifieswhat operation to execute; it may be any of the following, but you must specify only one of them:
d Delete modulesfrom the archive. Specify the namesof modulesto be deleted asfiles; the archive is
untouched if you specify no filesto delete.
If you specify the v modifier, ar will list each module asit isdeleted.
m Use thisoperation to move membersin an archive.
The ordering of membersin an archive can make a difference in how programsare linked using the
library if a symbol isdefined in more than one member.
If no modifiersare used with m, any membersyou name in the filesargumentsare moved to the end of
the archive; you can use the a, b, or i modifiersto move them to a specified place instead.
p Print the specified membersof the archive to the standard output file. If the v modifier isspecified,
show the membername before copying itscontentsto standard output.
If you specify no files, all the filesin the archive are printed.
q Quick append; add filesto the end of archive without checking for replacement.
The modifiersa, b, and i do not affect thisoperation; new membersare alwaysplaced at the end of the
archive.
The modifier v makesar list each file asit isappended.
Since the point of thisoperation isspeed, the archivessymbol table index isnot updated, even if it
already existed; you can use ar s or ranlib explicitly to update the symbol table index.
r Insert filesinto archive (with replacement). Thisoperation differsfrom q in that any previously existing
membersare deleted if their namesmatch those being added.
If one of the filesnamed in filesdoesnt exist, ar displaysan error message and leavesundisturbed any
existing membersof the archive matching that name.
By default, new membersare added at the end of the file, but you may use one of the modifiersa, b, or
i to request placement relative to some existing member.
The modifier v used with thisoperation elicitsa line of output for each file inserted, along with one of
the lettersa or r to indicate whether the file wasappended (no old member deleted) or replaced.
7
t Display a table listing the contentsof archive, or those of the fileslisted in filesthat are present in the
archive. Normally, only the membername isshown; if you also want to see the modes(permissions),
timestamp, owner, group, and size, you can request that by also specifying the v modifier.
If you do not specify any files, all filesin the archive are listed.
If there ismore than one file with the same name (say, fie) in an archive (say, b.a), ar t b.a fie will
list only the first instance; to see them all, you must ask for a complete listingin our example, ar t
b.a.
x Extract members(named files) from the archive. You can use the v modifier with thisoperation to
request that ar list each name asit extractsit.
If you do not specify any files, all filesin the archive are extracted.
A number of modifiers(mod) may immediately follow the p keyletter, to specify variationson an operationsbehavior, as
follows:
a Add new filesafter an existing member of the archive. If you use the modifier a, the name of an
existing archive member must be present asthe membername argument, before the archive specifica-
tion.
b Add new filesbefore an existing member of the archive. If you use the modifier b, the name of an
existing archive member must be present asthe membername argument, before the archive specifica-
tion (same asi).
c Create the archive. The specified archive isalwayscreated if it didnt exist when you request an update.
But a warning isissued unlessyou specify in advance that you expect to create it by using thismodifier.
i Insert new filesbefore an existing member of the archive. If you use the modifier i, the name of an
existing archive member must be present asthe membername argument, before the archive specifica-
tion. (same asb).
l Thismodifier isaccepted but not used.
o Preserve the original datesof memberswhen extracting them. If you do not specify thismodifier, files
extracted from the archive will be stamped with the time of extraction.
s Write an object-file index into the archive, or update an existing one, even if no other change ismade
to the archive. You may use thismodifier flag either with any operation, or alone. Running ar s on an
archive isequivalent to running ranlib on it.
u Normally, ar r... insertsall fileslisted into the archive. If you would like to insert only those of the
filesyou list that are newer than existing membersof the same names, use thismodifier. The u modifier
isallowed only for the operation r (replace). In particular, the combination qu isnot allowed, since
checking the timestampswould lose any speed advantage from the operation q.
v Thismodifier requeststhe verbose version of an operation. Many operationsdisplay additional
information, such asfilenamesprocessed, when the modifier v isappended.
V Thismodifier showsthe version number of ar.
SEE ALSO
binutils entry in info; TheGNU BinaryUtilities, Roland H. Pesch (October 1991); nm(1), anlib(1)
COPYING
Copyright 1991 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim copiesof this
manual provided the copyright notice and thispermission notice are preserved on all copies. Permission isgranted to copy
and distribute modified versionsof thismanual under the conditionsfor verbatim copying, provided that the entire resulting
derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
CygnusSupport, 5 November 1991
ar
Part I: User Commands
8
arch
archPrint architecture
SYNOPSIS
arch
DESCRIPTION
arch displaysmachine architecture type.
SEE ALSO
uname(1), uname(2)
Debian GNU/Linux, 15 January1994
GNU as
GNU asThe portable GNU assembler
SYNOPSIS
as [ a | al | -as ][D ][f ][I pat h ][K ][L ][o obj f i l e ][R ][v ][w ][\|\
f i l es ...]
i960-only options:
[ ACA| ACA A | ACB | ACC| AKA| AKB | AKC| AMC][b ][no-relax ]
m680x0-only options:
[ l ][mc68000| mc68010| mc68020]
DESCRIPTION
GNU as isreally a family of assemblers. If you use (or have used) the GNU assembler on one architecture, you should find a
fairly similar environment when you use it on another architecture. Each version hasmuch in common with the others,
including object file formats, most assembler directives(often called pseudo-ops) and assembler syntax.
For information on the syntax and pseudo-opsused by GNU as, see as entry in info (or the manual Usingas: TheGNU
Assembler).
as isprimarily intended to assemble the output of the GNU C compiler gcc for use by the linker ld. Nevertheless, weve tried
to make as assemble correctly everything that the native assembler would. Thisdoesnt mean as alwaysusesthe same syntax
asanother assembler for the same architecture; for example, we know of several incompatible versionsof 680x0 assembly
language syntax.
Each time you run as, it assemblesexactly one source program. The source program ismade up of one or more files. (The
standard input isalso a file.)
If as isgiven no filenames, it attemptsto read one input file from the as standard input, which isnormally your terminal.
You may have to type Ctrl-D to tell as there isno more program to assemble. Use if you need to explicitly name the
standard input file in your command line.
as may write warningsand error messagesto the standard error file (usually your terminal). Thisshould not happen when as
isrun automatically by a compiler. Warningsreport an assumption made so that as could keep assembling a flawed program;
errorsreport a grave problem that stopsthe assembly.
9
OPTIONS
a|al|as Turn on assembly listings; al, listing only, as, symbolsonly, -a, everything.
D Thisoption isaccepted only for script compatibility with callsto other assemblers; it
hasno effect on as.
f Fastskip preprocessing (assume source iscompiler output).
I\pat h Add path to the search list for .include directives.
K Issue warningswhen difference tablesaltered for long displacements.
L Keep (in symbol table) local symbols, starting with L.
o\obj f i l e Name the object-file output from as.
R Fold data section into text section.
v Announce as version.
W Suppresswarning messages.
\|\f i l es ... Source filesto assemble, or standard input ().
Avar (When configured for Intel 960.) Specify which variant of the 960 architecture isthe
target.
b (When configured for Intel 960.) Add code to collect statisticsabout branchestaken.
no-relax (When configured for Intel 960.) Do not alter compare-and-branch instructionsfor
long displacements; error if necessary.
l (When configured for Motorola 68000.) Shorten referencesto undefined symbolsto
one word instead of two.
mc68000|mc68010|mc68020 (When configured for Motorola 68000.) Specify which processor in the 68000
family isthe target (default 68020).
Optionsmay be in any order, and may be before, after, or between filenames. The order of filenamesissignificant.
The double hyphenscommand () by itself namesthe standard input file explicitly, asone of the filesfor as to assemble.
Except for , any command line argument that beginswith a hyphen () isan option. Each option changesthe behavior of
as. No option changesthe way another option works. An option isa hyphen followed by one or more letters; the case of the
letter isimportant. All optionsare optional.
The o option expectsexactly one filename to follow. The filename may either immediately follow the optionsletter
(compatible with older assemblers) or it may be the next command argument (GNU standard).
These two command linesare equivalent:
as o myobjectfile.o mumble.s
as omyobjectfile.o mumble.s
SEE ALSO
as entry in info; Usingas: TheGNU Assembler; gcc(1), ld(1).
COPYING
Copyright 1991, 1992 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim copiesof
thismanual provided the copyright notice and thispermission notice are preserved on all copies. Permission isgranted to
copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying, provided that the entire
resulting derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
CygnusSupport, 21 January1992
GNU as
Part I: User Commands
10
asciitopgm
asciitopgmConvert ASCII graphicsinto a portable graymap
SYNOPSIS
asciitopgm [-d divisor] hei ght wi dt h [asci i f i l e]
DESCRIPTION
ReadsASCII data asinput. Producesa portable graymap with pixel valuesthat are an approximation of the brightnessof the
ASCII characters, assuming black-on-white printing. In other words, a capital M isvery dark, a period isvery light, and a
space iswhite. Input linesthat are fewer than wi dt h charactersare automatically padded with spaces.
The divisor argument isa floating-point number by which the output pixelsare divided; the default value is1.0. Thiscan be
used to adjust the brightnessof the graymap; for example, if the image istoo dim, reduce the divisor.
In keeping with (I believe) FORTRAN line-printer conventions, input linesbeginning with a + (plus) character are assumed
to overstrike the previousline, allowing a larger range of gray values.
Thistool contradictsthe message in the pbmtoascii manual: Note that there isno asciitopbm toolthistransformation is
one-way.
BUGS
The table of ASCII-to-gray valuesissubject to interpretation, and, of course, dependson the typeface intended for the input.
SEE ALSO
pbmtoascii(1), pgm(5)
AUTHOR
Wilson H. Bent, Jr. (whb@usc.edu)
26 December 1994
atktopbm
atktopbmConvert Andrew Toolkit raster object to portable bitmap
SYNOPSIS
atktopbm [at kf i l e]
DESCRIPTION
atktopbm readsan Andrew Toolkit raster object asinput and producesa portable bitmap asoutput.
SEE ALSO
pbmtoatk(1), pbm(5)
AUTHOR
Copyright 1991 by Bill Janssen
26 September 1991
11
bash
bashGNU Bourneagain shell
SYNOPSIS
bash [opt i ons ] [f i l e]
DESCRIPTION
bash isan shcompatible command language interpreter that executescommandsread from the standard input or from a file.
bash also incorporatesuseful featuresfrom the Korn and C shells(ksh and csh).
bash isultimately intended to be a conformant implementation of the IEEE POSIX Shell and Toolsspecification (IEEE
Working Group 10032).
OPTIONS
In addition to the singlecharacter shell optionsdocumented in the description of the set built-in command, bash interprets
the following flagswhen it isinvoked:
c st r i ng If the c flag ispresent, then commandsare read from st r i ng. If there are argumentsafter the
string, they are assigned to the positional parameters, starting with $0.
i If the i flag ispresent, the shell isinteractive.
s If the s flag ispresent, or if no argumentsremain after option processing, then commandsare
read from the standard input. Thisoption allowsthe positional parametersto be set when
invoking an interactive shell.
A single signalsthe end of optionsand disablesfurther option processing. Any argumentsafter
the are treated asfilenamesand arguments. An argument of isequivalent to an argument
of .
bash also interpretsa number of multicharacter options. To be recognized, these optionsmust appear on the command line
before the singlecharacter options.
norc Do not read and execute the personal initialization file /.bashrc if the shell isinteractive. This
option ison by default if the shell isinvoked assh.
noprofile Do not read either the systemwide startup file /etc/profile or any of the personal initializa-
tion files/.bash_profile, /.bash_login, or /.profile. By default, bash normally readsthese
fileswhen it isinvoked asa login shell. (See the Invocation section, later in thismanual page.)
rcfile f i l e Execute commandsfrom file instead of the standard personal initialization file /.bashrc, if the
shell isinteractive. (See Invocation.)
version Show the version number of thisinstance of bash when starting.
quiet Do not be verbose when starting up (do not show the shell version or any other information).
Thisisthe default.
login Make bash act asif it had been invoked asa login shell.
nobraceexpansion Do not perform curly brace expansion. (See Brace Expansion, later in thismanual page.)
nolineediting Do not use the GNU readline library to read command linesif interactive.
posix Change the behavior of bash where the default operation differsfrom the POSIX 1003.2
standard to match the standard.
ARGUMENTS
If argumentsremain after option processing, and neither the c nor the s option hasbeen supplied, the first argument is
assumed to be the name of a file containing shell commands. If bash isinvoked in thisfashion, isset to the name of the file,
and the positional parametersare set to the remaining arguments. bash readsand executescommandsfrom thisfile, then
exits. bashsexit statusisthe exit statusof the last command executed in the script.
bash
Part I: User Commands
12
DEFINITIONS
blank A space or tab.
word A sequence of charactersconsidered asa single unit by the shell. Also known asa token.
name A word consisting only of alphanumeric charactersand underscoresand beginning with an
alphabetic character or an underscore. Also referred to asan identifier.
meta character A character that, when unquoted, separateswords. One of the following:
|, &, ;, (, ), <, >, space, tab
control operator A token that performsa control function. It isone of the following symbols:
||, &, &&, ;, ;;, (, ), |, <newline>
RESERVED WORDS
Reserved wordsare wordsthat have a special meaning to the shell. The following wordsare recognized asreserved when
unquoted and either the first word of a simple command (see Shell Grammar, next) or the third word of a case or for
command:
! case do done elif else esac fi for function if in select then until while { }
SHELL GRAMMAR
SIMPLE COMMANDS
A simplecommand isa sequence of optional variable assignmentsfollowed by wordsand redirectionsseparated by blank and
terminated by a control operator. The first word specifiesthe command to be executed. The remaining wordsare passed as
argumentsto the invoked command.
The return value of a simple command isitsexit status, or 128+n if the command isterminated by signal n.
PIPELINES
A pipelineisa sequence of one or more commandsseparated by the character |. The format for a pipeline is
[!]command [ | command2 ... ]
The standard output of command isconnected to the standard input of command2. Thisconnection isperformed before any
redirectionsspecified by the command. (See the Redirection section, later in thismanual page.)
If the reserved word ! precedesa pipeline, the exit statusof that pipeline isthe logical NOT of the exit statusof the last
command. Otherwise, the statusof the pipeline isthe exit statusof the last command. The shell waitsfor all commandsin
the pipeline to terminate before returning a value.
Each command in a pipeline isexecuted asa separate process(that is, in a subshell).
LISTS
A list isa sequence of one or more pipelinesseparated by one of these operators: ;, &, &&, or ||, and terminated by one of
these: ;, &, or <newline>.
Of these list operators, && and || have equal precedence, followed by ; and &, which have equal precedence.
If a command isterminated by the control operator &, the shell executesthe command in the background in a subshell. The
shell doesnot wait for the command to finish, and the return statusis0. Commandsseparated by a ; are executed sequen-
tially; the shell waitsfor each command to terminate in turn. The return statusisthe exit statusof the last command
executed.
The control operators&& and || denote AND listsand OR lists, respectively. An AND list hasthe form:
command && command2
command2 isexecuted if, and only if, command returnsan exit statusof Zero.
13
An OR list hasthe form
command command2
command2 isexecuted if, and only if, command returnsa nonzero exit status. The return statusof AND and OR listsisthe exit
statusof the last command executed in the list.
COMPOUND COMMANDS
A compound commandisone of the following:
(list)
list isexecuted in a subshell. Variable assignmentsand built-in commandsthat affect the shellsenvironment do not remain
in effect after the command completes. The return statusisthe exit statusof list.
{ l i st ; }
l i st issimply executed in the current shell environment. Thisisknown asa group command. The return statusisthe exit
statusof l i st .
for name [ in wor d;] do l i st ; done
The list of wordsfollowing in isexpanded, generating a list of items. The variable name isset to each element of thislist in
turn, and l i st isexecuted each time. If the in word isomitted, the for command executesl i st once for each positional
parameter that isset. (See Parameters, later in thismanual page.)
select name [ in wor d;] do l i st ; done
The list of wordsfollowing in isexpanded, generating a list of items. The set of expanded wordsisprinted on the standard
error, each preceded by a number. If the in word isomitted, the positional parametersare printed. (See Parameters.) The
PS3 prompt isthen displayed and a line read from the standard input. If the line consistsof the number corresponding to
one of the displayed words, then the value of name isset to that word. If the line isempty, the wordsand prompt are
displayed again. If EOF isread, the command completes. Any other value read causesname to be set to null. The line read is
saved in the variable REPLY. The list isexecuted after each selection until a break or return command isexecuted. The exit
statusof select isthe exit statusof the last command executed in list, or zero if no commandswere executed.
case wor d in [ pat t er n [ | pat t er n ]
A case command first expandswor d, and triesto match it against each pat t er n in turn, using the same matching rulesasfor
pathname expansion. (See Pathname Expansion, later in thismanual page.) When a match isfound, the corresponding list
isexecuted. After the first match, no subsequent matchesare attempted. The exit statusiszero if no patternsare matches.
Otherwise, it isthe exit statusof the last command executed in l i st .
if l i st then l i st [ elif l i st then l i st ] ... [ else l i st ] fi
The if list isexecuted. If itsexit statusiszero, the then list isexecuted. Otherwise, each elif list isexecuted in turn, and if its
exit statusiszero, the corresponding then list isexecuted and the command completes. Otherwise, the else list isexecuted, if
present. The exit statusisthe exit statusof the last command executed, or zero if no condition tested True.
while l i st do l i st done
until l i st do l i st done
The while command continuously executesthe do list aslong asthe last command in l i st returnsan exit statusof zero. The
until command isidentical to the while command, except that the test isnegated; the do list isexecuted aslong asthe last
command in l i st returnsa nonzero exit status. The exit statusof the while and until commandsisthe exit statusof the last
do l i st command executed, or zero if none wasexecuted.
[ function ] name () { l i st ; }
Thisdefinesa function named name. The body of the function isthe list of commandsbetween { and }. Thislist isexecuted
whenever nameisspecified asthe name of a simple command. The exit statusof a function isthe exit statusof the last
command executed in the body. (See Functions, later in thismanual page.)
bash
Part I: User Commands
14
COMMENTS
In a noninteractive shell, or an interactive shell in which the -o interactivecomments option to the set builtin isenabled, a
word beginning with # causesthat word and all remaining characterson that line to be ignored. An interactive shell without
the -o interactivecomments option enabled doesnot allow comments.
QUOTING
Quoting isused to remove the special meaning of certain charactersor wordsto the shell. Quoting can be used to disable
special treatment for special characters, to prevent reserved wordsfrom being recognized assuch, and to prevent parameter
expansion.
Each of the meta characterslisted earlier under Definitions hasspecial meaning to the shell and must be quoted if it isto
represent itself. There are three quoting mechanisms: the escape character, single quotes, and double quotes.
A nonquoted backslash (\) isthe escape character. It preservesthe literal value of the next character that follows, with the
exception of <newline>.If a \<newline> pair appears, and the backslash isnot quoted, the \<newline> istreated asa line
continuation; that is, it iseffectively ignored.
Enclosing charactersin single quotespreservesthe literal value of each character within the quotes. A single quote may not
occur between single quotes, even when preceded by a backslash.
Enclosing charactersin double quotespreservesthe literal value of all characterswithin the quotes, with the exception of $, ,
and \. The characters$ and retain their special meaning within double quotes. The backslash retainsitsspecial meaning
only when followed by one of the following characters: $, , , \, or <newline>. A double quote may be quoted within double
quotesby preceding it with a backslash.
The special parameters* and @ have special meaning when in double quotes. (See Parameters, next.)
PARAMETERS
A parameter isan entity that storesvalues, somewhat like a variable in a conventional programming language. It can be a
name, a number, or one of the special characterslisted under Special Parameters, following. For the shellspurposes, a
variable isa parameter denoted by a name.
A parameter isset if it hasbeen assigned a value. The null string isa valid value. Once a variable isset, it may be unset only
by using the unset built-in command. (See Shell Built-in Commands, later in thismanual page.)
A variable may be assigned to by a statement of the form:
name=[val ue]
If val ue isnot given, the variable isassigned the null string. All valuesundergo tilde expansion, parameter and variable
expansion, command substitution, arithmetic expansion, and quote removal. If the variable hasitsi attribute set (see
declare in Shell Built-in Commands) then val ue issubject to arithmetic expansion even if the $[...] syntax doesnot
appear. Word splitting isnot performed, with the exception of $@, asexplained under Special Parameters. Pathname
expansion isnot performed.
POSITIONAL PARAMETERS
A positional parameter isa parameter denoted by one or more digits, other than the single digit 0. Positional parametersare
assigned from the shellsargumentswhen it isinvoked, and may be reassigned using the set built-in command. Positional
parametersmay not be assigned to with assignment statements. The positional parametersare temporarily replaced when a
shell function isexecuted. (See Functions, later in thismanual page.)
When a positional parameter consisting of more than a single digit isexpanded, it must be enclosed in braces. (See
Expansion, later in thismanual page.)
SPECIAL PARAMETERS
The shell treatsseveral parametersspecially. These parametersmay only be referenced; assignment to them isnot allowed.
15
* Expandsto the positional parameters, starting from one. When the expansion occurswithin double
quotes, it expandsto a single word with the value of each parameter separated by the first character
of the IFS special variable. That is, $* isequivalent to $1c$2c..., where c isthe first character of
the value of the IFS variable. If IFS isnull or unset, the parametersare separated by spaces.
@ Expandsto the positional parameters, starting from one. When the expansion occurswithin double
quotes, each parameter expandsasa separate word. That is, $@ isequivalent to $1$2" ....
When there are no positional parameters, $@ and $@ expand to nothing (in other words, they are
removed).
# Expandsto the number of positional parametersin decimal.
? Expandsto the statusof the most recently executed foreground pipeline.
Expandsto the current option flagsasspecified upon invocation, by the set built-in command, or
those set by the shell itself (such asthe i flag).
$ Expandsto the processID of the shell. In a () subshell, it expandsto the processID of the current
shell, not the subshell.
! Expandsto the processID of the most recently executed background (asynchronous) command.
0 Expandsto the name of the shell or shell script. Thisisset at shell initialization. If bash isinvoked
with a file of commands, isset to the name of that file. If bash isstarted with the c option, then is
set to the first argument after the string to be executed, if one ispresent. Otherwise, it isset to the
pathname used to invoke bash, asgiven by argument zero.
_ Expandsto the last argument to the previouscommand, after expansion. Also set to the full
pathname of each command executed and placed in the environment exported to that command.
SHELL VARIABLES
The following variablesare set by the shell:
PPID The processID of the shellsparent.
PWD The current working directory asset by the cd command.
OLDPWD The previousworking directory asset by the cd command.
REPLY Set to the line of input read by the read built-in command when no argumentsare
supplied.
UID Expandsto the user ID of the current user, initialized at shell startup.
EUID Expandsto the effective user ID of the current user, initialized at shell startup.
BASH Expandsto the full pathname used to invoke thisinstance of bash.
BASH_VERSION Expandsto the version number of thisinstance of bash.
SHLVL Incremented by one each time an instance of bash isstarted.
RANDOM Each time thisparameter isreferenced, a random integer isgenerated. The sequence
of random numbersmay be initialized by assigning a value to RANDOM. If RANDOM is
unset, it losesitsspecial properties, even if it issubsequently reset.
SECONDS Each time thisparameter isreferenced, the number of secondssince shell invocation
isreturned. If a value isassigned to SECONDS, the value returned upon subsequent
referencesisthe number of secondssince the assignment plusthe value assigned. If
SECONDS isunset, it losesitsspecial properties, even if it issubsequently reset.
LINENO Each time thisparameter isreferenced, the shell substitutesa decimal number
representing the current sequential line number (starting with 1) within a script or
function. When not in a script or function, the value substituted isnot guaranteed to
be meaningful. When in a function, the value isnot the number of the source line
that the command appearson (that information hasbeen lost by the time the
function isexecuted), but isan approximation of the number of simple commands
executed in the current function. If LINENO isunset, it losesitsspecial properties, even
if it issubsequently reset.
bash
Part I: User Commands
16
HISTCMD The history number, or index in the history list, of the current command. If HISTCMD
isunset, it losesitsspecial properties, even if it issubsequently reset.
OPTARG The value of the last option argument processed by the getopts built-in command.
(See Shell Built-in Commands, later in thismanual page).
OPTIND The index of the next argument to be processed by the getopts built-in command.
(See Shell Built-in Commands.)
HOSTTYPE Automatically set to a string that uniquely describesthe type of machine on which
bash isexecuting. The default issystem-dependent.
OSTYPE Automatically set to a string that describesthe operating system on which bash is
executing. The default issystem-dependent.
The following variablesare used by the shell. In some cases, bash assignsa default value to a variable; these casesare noted in
the following list:
IFS The internal field separator that isused for word splitting after expansion and to split
linesinto wordswith the read built-in command. The default value is
<space><tab><newline>.
PATH The search path for commands. It isa colon-separated list of directoriesin which the
shell looksfor commands. (See Command Execution, later in thismanual page).
The default path issystemdependent, and isset by the administrator who installs
bash. A common value is/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.
HOME The home directory of the current user; the default argument for the cd built-in
command.
CDPATH The search path for the cd command. Thisisa colon-separated list of directoriesin
which the shell looksfor destination directoriesspecified by the cd command. A
sample value is.::/usr.
ENV If thisparameter isset when bash isexecuting a shell script, itsvalue isinterpreted as
a filename containing commandsto initialize the shell, asin .bashrc. The value of
ENV issubjected to parameter expansion, command substitution, and arithmetic
expansion before being interpreted asa pathname. PATH isnot used to search for the
resultant pathname.
MAIL If thisparameter isset to a filename and the MAILPATH variable isnot set, bash informs
the user of the arrival of mail in the specified file.
MAILCHECK Specifieshow often (in seconds) bash checksfor mail. The default is60 seconds.
When it istime to check for mail, the shell doesso before prompting. If thisvariable
isunset, the shell disablesmail checking.
MAILPATH A colon-separated list of pathnamesto be checked for mail. The message to be
printed may be specified by separating the pathname from the message with a
question mark (?). $_ standsfor the name of the current mailfile.
Example:
MAILPATH\
=/usr/spool/mail/bfox?You have
mail:/shell-mail?$_has mail!
bash suppliesa default value for thisvariable, but the location of the user mail files
that it usesissystem-dependent (for example, /usr/spool/mail/$USER).
MAIL_WARNING If set, and a file that bash ischecking for mail hasbeen accessed since the last time it
waschecked, the message The mail in mail-file hasbeen read isprinted.
PS1 The value of thisparameter isexpanded (see Prompting, later in thismanual page)
and used asthe primary prompt string. The default value isbash\$.
PS2 The value of thisparameter isexpanded and used asthe secondary prompt string.
The default is>.
17
PS3 The value of thisparameter isused asthe prompt for the select command. (See
Shell Grammar, earlier in thismanual page.)
PS4 The value of thisparameter isexpanded and the value isprinted before each
command bash displaysduring an execution trace. The first character of PS4 is
replicated multiple times, asnecessary, to indicate multiple levelsof indirection. The
default is+.
HISTSIZE The number of commandsto remember in the command history, (See History,
later in thismanual page.) The default value is500.
HISTFILE The name of the file in which command history issaved. (See History.) The
default value is/.bash_history. If unset, the command history isnot saved when an
interactive shell exits.
HISTFILESIZE The maximum number of linescontained in the history file. When thisvariable is
assigned a value, the history file istruncated, if necessary, to contain no more than
that number of lines. The default value is500.
OPTERR If set to the value 1, bash displayserror messagesgenerated by the getopts built-in
command. (See Shell Built-in Commands.). OPTERR isinitialized to 1 each time the
shell isinvoked or a shell script isexecuted.
PROMPT_COMMAND If set, the value isexecuted asa command prior to issuing each primary prompt.
IGNOREEOF Controlsthe action of the shell on receipt of an EOF character asthe sole input. If set,
the value isthe number of consecutive EOF characterstyped asthe first characterson
an input line before bash exits. If the variable existsbut doesnot have a numeric
value, or hasno value, the default value is10. If it doesnot exist, EOF signifiesthe end
of input to the shell. Thisisonly in effect for interactive shells.
TMOUT If set to a value greater than zero, the value isinterpreted asthe number of seconds
to wait for input after issuing the primary prompt. bash terminatesafter waiting for
that number of secondsif input doesnot arrive.
FCEDIT The default editor for the fc built-in command.
FIGNORE A colon-separated list of suffixesto ignore when performing filename completion.
(See Readline, later in thismanual page.) A filename whose suffix matchesone of
the entriesin FIGNORE isexcluded from the list of matched filenames. A sample value
is.o:.
INPUTRC The filename for the readline startup file, overriding the default of /.inputrc. (See
Readline.)
notify If set, bash reportsterminated background jobsimmediately, rather than waiting
until before printing the next primary prompt. (See also the b option to the set
built-in command.)
history_control HISTCONTROL If set to a value of ignorespace, linesthat begin with a space character are not entered
on the history list. If set to a value of ignoredups, linesmatching the last history line
are not entered. A value of ignoreboth combinesthe two options. If unset, or if set to
any other value than the preceding, all linesread by the parser are saved on the
history list.
command_oriented_history If set, bash attemptsto save all linesof a multipleline command in the same history
entry. Thisallowseasy reediting of multiline commands.
glob_dot_filenames If set, bash includesfilenamesbeginning with a period (.) in the resultsof pathname
expansion.
allow-null_glob_expansion If set, bash allowspathname patternswhich match no files(see Pathname
Expansion) to expand to a null string, rather than themselves.
histchars The two or three charactersthat control history expansion and tokenization. (See
History Expansion, later in thismanual page.) The first character isthe history
expansion character; that is, the character that signalsthe start of a history expansion,
bash
Part I: User Commands
18
normally !. The second character isthe quick substitution character, which isused as
shorthand for rerunning the previouscommand entered, substituting one string for
another in the command. The default is^. The optional third character isthe
character that signifiesthat the remainder of the line isa comment, when found as
the first character of a word, normally #. The history comment character causes
history substitution to be skipped for the remaining wordson the line. It doesnot
necessarily cause the shell parser to treat the rest of the line asa comment.
nolinks If set, the shell doesnot follow symbolic linkswhen executing commandsthat
change the current working directory. It usesthe physical directory structure instead.
By default, bash followsthe logical chain of directorieswhen performing commands
that change the current directory, such ascd. See also the description of the P
option to the set builtin (Shell Built-in Commands).
hostname_completion_file HOSTFILE Containsthe name of a file in the same format as/etc/hosts that should be read
when the shell needsto complete a hostname. The file may be changed interactively;
the next time hostname completion isattempted bash addsthe contentsof the new
file to the already existing database.
noclobber If set, bash doesnot overwrite an existing file with the >, >&, and <> redirection
operators. Thisvariable may be overridden when creating output filesby using the
redirection operator >| instead of >. (See also the C option to the set built-in
command.)
auto_resume Thisvariable controlshow the shell interactswith the user and job control. If this
variable isset, single word simple commandswithout redirectionsare treated as
candidatesfor resumption of an existing stopped job. There isno ambiguity allowed;
if there ismore than one job beginning with the string typed, the job most recently
accessed isselected. The name of a stopped job, in thiscontext, isthe command line
used to start it. If set to the value exact, the string supplied must match the name of
a stopped job exactly; if set to substring, the string supplied needsto match a
substring of the name of a stopped job. The substring value providesfunctionality
analogousto the %? job ID. (See Job Control, later in thismanual page.) If set to
any other value, the supplied string must be a prefix of a stopped jobsname; this
providesfunctionality analogousto the % job id.
no_exit_on_failed_exec If thisvariable exists, a noninteractive shell will not exit if it cannot execute the file
specified in the exec built-in command. An interactive shell doesnot exit if exec
fails.
cdable_vars If thisisset, an argument to the cd built-in command that isnot a directory is
assumed to be the name of a variable whose value isthe directory to change to.
EXPANSION
Expansion isperformed on the command line after it hasbeen split into words. There are seven kindsof expansion
performed: brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expan-
sion, word splitting, and pathname expansion.
The order of expansionsisasfollows: brace expansion, tilde expansion, parameter, variable, command, and arithmetic
substitution (done in a lefttoright fashion), word splitting, and pathname expansion.
On systemsthat can support it, there isan additional expansion available: processsubstitution.
Only brace expansion, word splitting, and pathname expansion can change the number of wordsof the expansion; other
expansionsexpand a single word to a single word. The single exception to thisisthe expansion of $@, asexplained earlier.
(See Parameters.)
19
BRACE EXPANSION
Braceexpansion isa mechanism by which arbitrary stringsmay be generated. Thismechanism issimilar to pathname
expansion, but the filenamesgenerated need not exist. Patternsto be brace expanded take the form of an optional preamble,
followed by a seriesof comma-separated stringsbetween a pair of braces, followed by an optional postamble. The preamble is
prepended to each string contained within the braces, and the postamble isthen appended to each resulting string,
expanding left to right.
Brace expansionsmay be nested. The resultsof each expanded string are not sorted; left to right order ispreserved. For
example, a{d,c,b}e expandsinto ade ace abe.
Brace expansion isperformed before any other expansions, and any charactersspecial to other expansionsare preserved in the
result. It isstrictly textual. bash doesnot apply any syntactic interpretation to the context of the expansion or the text
between the braces.
A correctly formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma.
Any incorrectly formed brace expansion isleft unchanged.
Thisconstruct istypically used asshorthand when the common prefix of the stringsto be generated islonger than in the
preceding example, such as
mkdir /usr/local/src/bash/{old,new,dist,bugs}
or
chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
Brace expansion introducesa slight incompatibility with traditional versionsof sh, the Bourne shell. sh doesnot treat
opening or closing bracesspecially when they appear aspart of a word, and preservesthem in the output. bash removes
bracesfrom wordsasa consequence of brace expansion. For example, a word entered to sh asfile{1,2} appearsidentically in
the output. The same word isoutput asfile1 file2 after expansion by bash. If strict compatibility with sh isdesired, start
bash with the nobraceexpansion flag (see Options, earlier in thismanual page) or disable brace expansion with the +o
braceexpand option to the set command. (See Shell Built-in Commands.)
TILDE EXPANSION
If a word beginswith a tilde character (), all of the characterspreceding the first slash (or all characters, if there isno slash)
are treated asa possible login name. If thislogin name isthe null string, the tilde isreplaced with the value of the parameter
HOME. If HOME isunset, the home directory of the user executing the shell issubstituted instead.
If a + followsthe tilde, the value of PWD replacesthe tilde and + If a follows, the value of OLDPWD issubstituted. If the value
following the tilde isa valid login name, the tilde and login name are replaced with the home directory associated with that
name. If the name isinvalid, or the tilde expansion fails, the word isunchanged.
Each variable assignment ischecked for unquoted instancesof tildesfollowing a : or =. In these cases, tilde substitution is
also performed. Consequently, one may use pathnameswith tildesin assignmentsto PATH, MAILPATH, and CDPATH, and the shell
assignsthe expanded value.
PARAMETER EXPANSION
The $ character introducesparameter expansion, command substitution, or arithmetic expansion. The parameter name or
symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from
charactersimmediately following it which could be interpreted aspart of the name.
${par amet er } The value of par amet er issubstituted. The bracesare required when par amet er isa positional parameter
with more than one digit, or when par amet er isfollowed by a character that isnot to be interpreted aspart
of itsname.
In each of the following cases, wor d issubject to tilde expansion, parameter expansion, command substitution, and arithmetic
expansion. bash testsfor a parameter that isunset or null; omitting the colon resultsin a test only for a parameter that is
unset.
bash
Part I: User Commands
20
${par amet er :wor d} Use default values. If par amet er isunset or null, the expansion of wor d issubstituted. Otherwise, the
value of par amet er issubstituted.
${par amet er :=wor d} Assign default values. If par amet er isunset or null, the expansion of word isassigned to parameter.
The value of par amet er isthen substituted. Positional parametersand special parametersmay not be
assigned to in thisway.
${par amet er :?wor d} Display Error if null or unset. If par amet er isnull or unset, the expansion of wor d (or a message to
that effect if wor d isnot present) iswritten to the standard error and the shell, if it isnot interactive,
exits. Otherwise, the value of par amet er issubstituted.
${par amet er :+wor d} Use Alternate Value. If par amet er isnull or unset, nothing issubstituted; otherwise, the expansion
of wor d issubstituted.
${#par amet er } The length in charactersof the value of par amet er issubstituted. If parameter is* or @, the length
substituted isthe length of * expanded within double quotes.
${par amet er #wor d} The wor d isexpanded to produce a pattern just asin pathname expansion. If the pattern matches
${par amet er ##wor d} the beginning of the value of par amet er , then the expansion isthe value of par amet er with the
shortest matching pattern deleted (the # case) or the longest matching pattern deleted (the ## case).
${par amet er %wor d} The wor d isexpanded to produce a pattern just asin pathname expansion. If the pattern matchesa
${par amet er %%wor d} trailing portion of the value of par amet er , then the expansion isthe value of par amet er with the
shortest matching pattern deleted (the % case) or the longest matching pattern deleted (the %% case).
COMMAND SUBSTITUTION
Command substitution allowsthe output of a command to replace the command name.
There are two forms:
$(command )
or
command
performsthe expansion by executing command and replacing the command substitution with the standard output of the
command, with any trailing newlinesdeleted.
When the oldstyle backquote form of substitution isused, backslash retainsitsliteral meaning except when followed by $, ,
or \. When using the $(command) form, all charactersbetween the parenthesesmake up the command; none are treated
specially.
Command substitutionsmay be nested. To nest when using the old form, escape the inner backquoteswith backslashes.
If the substitution appearswithin double quotes, word splitting and pathname expansion are not performed on the results.
ARITHMETIC EXPANSION
Arithmetic expansion allowsthe evaluation of an arithmetic expression and the substitution of the result. There are two
formatsfor arithmetic expansion:
$[expression]
$((expression))
The expression istreated asif it were within double quotes, but a double quote inside the bracesor parenthesesisnot treated
specially. All tokensin the expression undergo parameter expansion, command substitution, and quote removal. Arithmetic
substitutionsmay be nested.
The evaluation isperformed according to the ruleslisted under Arithmetic Evaluation, later in thissection. If expr essi on is
invalid, bash printsa message indicating failure and no substitution occurs.
PROCESS SUBSTITUTION
Processsubstitution issupported on systemsthat support named pipes(FIFOs) or the /dev/fd method of naming open files.
It takesthe form of <(l i st ) or >(l i st ). The processlist isrun with itsinput or output connected to a FIFO or some file in /
21
dev/fd. The name of thisfile ispassed asan argument to the current command asthe result of the expansion. If the >(l i st )
form isused, writing to the file will provide input for list. If the <(l i st ) form isused, the file passed asan argument should
be read to obtain the output of list.
On systemsthat support it, processsubstitution isperformed simultaneously with parameter and variable expansion,
command substitution, and arithmetic expansion.
WORD SPLITTING
The shell scansthe resultsof parameter expansion, command substitution, and arithmetic expansion that did not occur
within double quotesfor word splitting.
The shell treatseach character of IFS asa delimiter, and splitsthe resultsof the other expansionsinto wordson these
characters. If the value of IFS isexactly <space><tab><newline>, the default, then any sequence of IFS charactersservesto
delimit words. If IFS hasa value other than the default, then sequencesof the whitespace charactersspace and tab are ignored
at the beginning and end of the word, aslong asthe whitespace character isin the value of IFS (an IFS whitespace character).
Any character in IFS that isnot IFS whitespace, along with any adjacent IFS whitespace characters, delimitsa field. A
sequence of IFS whitespace charactersisalso treated asa delimiter. If the value of IFS isnull, no word splitting occurs. IFS
cannot be unset.
Explicit null arguments( or ) are retained. Implicit null arguments, resulting from the expansion of parametersthat have
no values, are removed.
Note that if no expansion occurs, no splitting isperformed.
PATHNAME EXPANSION
After word splitting, unlessthe f option hasbeen set, bash scanseach word for the characters*, ?, and [. If one of these
charactersappears, then the word isregarded asa pattern and replaced with an alphabetically sorted list of pathnames
matching the pattern. If no matching pathnamesare found, and the shell variable allow_null_glob_expansion isunset, the
word isleft unchanged. If the variable isset, and no matchesare found, the word isremoved. When a pattern isused for
pathname generation, the character (.) at the start of a name or immediately following a slash must be matched explicitly,
unlessthe shell variable glob_dot_filenames isset. The slash character must alwaysbe matched explicitly. In other cases, the
(.) character isnot treated specially.
The special pattern charactershave the following meanings:
* Matchesany string, including the null string.
? Matchesany single character.
[...] Matchesany one of the enclosed characters. A pair of charactersseparated by a minussign denotesa range;
any character lexically between those two characters, inclusive, ismatched. If the first character following
the [ isa ! or a ^, then any character not enclosed ismatched. A or ] may be matched by including it as
the first or last character in the set.
QUOTE REMOVAL
After the preceding expansions, all unquoted occurrencesof the characters\, , and are removed.
REDIRECTION
Before a command isexecuted, itsinput and output may be redirected using a special notation interpreted by the shell.
Redirection may also be used to open and close filesfor the current shell execution environment. The following redirection
operatorsmay precede or appear anywhere within a simple command or may follow a command. Redirectionsare processed
in the order they appear, from left to right.
In the following descriptions, if the file descriptor number isomitted, and the first character of the redirection operator is<,
the redirection refersto the standard input (file descriptor 0). If the first character of the redirection operator is>, the
redirection refersto the standard output (file descriptor 1).
bash
Part I: User Commands
22
The word that followsthe redirection operator in the following descriptionsissubjected to brace expansion, tilde expansion,
parameter expansion, command substitution, arithmetic expansion, quote removal, and pathname expansion. If it expandsto
more than one word, bash reportsan error.
Note that the order of redirectionsissignificant. For example, the command:
ls > di r l i st 2>&1
directsboth standard output and standard error to the file di r l i st , while the command
ls 2>&1 > di r l i st
directsonly the standard output to file di r l i st , because the standard error wasduplicated asstandard output before the
standard output wasredirected to dirlist.
REDIRECTING INPUT
Redirection of input causesthe file whose name resultsfrom the expansion of word to be opened for reading on file
descriptor n, or the standard input (file descriptor 0) if n isnot specified.
The general format for redirecting input is
[n]<wor d
REDIRECTING OUTPUT
Redirection of output causesthe file whose name resultsfrom the expansion of word to be opened for writing on file
descriptor n, or the standard output (file descriptor 1) if n isnot specified. If the file doesnot exist, it iscreated; if it does
exist it istruncated to zero size.
The general format for redirecting output is
[n]>wor d
If the redirection operator is>|, then the value of the -C option to the set built-in command isnot tested, and file creation is
attempted. (See also the description of noclobber under Shell Variables, earlier in thismanual page.)
APPENDING REDIRECTED OUTPUT
Redirection of output in thisfashion causesthe file whose name resultsfrom the expansion of word to be opened for
appending on file descriptor n, or the standard output (file descriptor 1) if n isnot specified. If the file doesnot exist, it is
created.
The general format for appending output is
[n]>>wor d
REDIRECTING STANDARD OUTPUT AND STANDARD ERROR
bash allowsboth the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to
the file whose name isthe expansion of word with thisconstruct.
There are two formatsfor redirecting standard output and standard error:
&>wor d
and
>&wor d
Of the two forms, the first ispreferred. Thisissemantically equivalent to
>wor d 2>&1
HERE-DOCUMENTS
Thistype of redirection instructsthe shell to read input from the current source until a line containing only word (with no
trailing blanks) isseen. All of the linesread up to that point are then used asthe standard input for a command.
23
The format of here-documentsisasfollows:
<<[]wor d her e- doc ument del i mi t er
No parameter expansion, command substitution, pathname expansion, or arithmetic expansion isperformed on wor d. If any
charactersin wor d are quoted, the del i mi t er isthe result of quote removal on wor d, and the linesin the her e- document are not
expanded. Otherwise, all linesof the her e- document are subjected to parameter expansion, command substitution, and
arithmetic expansion. In the latter case, the pair \<newline> isignored, and \ must be used to quote the characters\, $, and .
If the redirection operator is<<, then all leading tab charactersare stripped from input linesand the line containing
delimiter. Thisallowshere-documentswithin shell scriptsto be indented in a natural fashion.
DUPLICATING FILE DESCRIPTORS
The redirection operator:
[n]<&wor d
isused to duplicate input file descriptors. If wor d expandsto one or more digits, the file descriptor denoted by n ismade to be
a copy of that file descriptor. If word evaluatesto , file descriptor n isclosed. If n isnot specified, the standard input (file
descriptor 0) isused.
The operator:
[n]>&wor d
isused similarly to duplicate output file descriptors. If n isnot specified, the standard output (file descriptor 1) isused. Asa
special case, if n isomitted, and word doesnot expand to one or more digits, the standard output and standard error are
redirected asdescribed previously.
OPENING FILE DESCRIPTORS FOR READING AND WRITING
The redirection operator:
[n]<>wor d
causesthe file whose name isthe expansion of word to be opened for both reading and writing on file descriptor n, or asthe
standard input and standard output if n isnot specified. If the file doesnot exist, it iscreated.
FUNCTIONS
A shell function, defined asdescribed above under Shell Grammar, storesa seriesof commandsfor later execution.
Functionsare executed in the context of the current shell; no new processiscreated to interpret them (contrast thiswith the
execution of a shell script). When a function isexecuted, the argumentsto the function become the positional parameters
during itsexecution. The special parameter # isupdated to reflect the change. Positional parameter 0 isunchanged.
Variableslocal to the function may be declared with the local built-in command. Ordinarily, variablesand their valuesare
shared between the function and itscaller.
If the built-in command return isexecuted in a function, the function completesand execution resumeswith the next
command after the function call. When a function completes, the valuesof the positional parametersand the special
parameter # are restored to the valuesthey had prior to function execution.
Function namesmay be listed with the f option to the declare or typeset built-in commands. Functionsmay be exported
so that subshellsautomatically have them defined with the f option to the export builtin.
Functionsmay be recursive. No limit isimposed on the number of recursive calls.
ALIASES
The shell maintainsa list of aliasesthat may be set and unset with the alias and unalias built-in commands. (See Shell
Built-in Commands.). The first word of each command, if unquoted, ischecked to see if it hasan alias. If so, that word is
replaced by the text of the alias. The aliasname and the replacement text may contain any valid shell input, including the
meta characterslisted above, with the exception that the aliasname may not contain =. The first word of the replacement text
bash
Part I: User Commands
24
istested for aliases, but a word that isidentical to an aliasbeing expanded isnot expanded a second time. Thismeansthat
one may aliasls to ls F, for instance, and bash doesnot try to recursively expand the replacement text. If the last character
of the aliasvalue isa blank, then the next command word following the aliasisalso checked for aliasexpansion.
Aliasesare created and listed with the alias command, and removed with the unalias command.
There isno mechanism for using argumentsin the replacement text, asin csh. If argumentsare needed, a shell function
should be used.
Aliasesare not expanded when the shell isnot interactive.
The rulesconcerning the definition and use of aliasesare somewhat confusing. bash alwaysreadsat least one complete line of
input before executing any of the commandson that line. Aliasesare expanded when a command isread, not when it is
executed. Therefore, an aliasdefinition appearing on the same line asanother command doesnot take effect until the next
line of input isread. Thismeansthat the commandsfollowing the aliasdefinition on that line are not affected by the new
alias. Thisbehavior isalso an issue when functionsare executed. Aliasesare expanded when the function definition isread,
not when the function isexecuted, because a function definition isitself a compound command. Asa consequence, aliases
defined in a function are not available until after that function isexecuted. To be safe, alwaysput aliasdefinitionson a
separate line, and do not use aliasin compound commands.
Note that for almost every purpose, aliasesare superseded by shell functions.
JOB CONTROL
Job control refersto the ability to selectively stop (suspend) the execution of processesand continue (resume) their execution
at a later point. A user typically employsthisfacility via an interactive interface supplied jointly by the systemsterminal
driver and bash.
The shell associatesa job with each pipeline. It keepsa table of currently executing jobs, which may be listed with the jobs
command. When bash startsa job asynchronously (in the background), it printsa line that lookslike this:
[1] 25647
indicating that thisjob isjob number 1 and that the processID of the last processin the pipeline associated with thisjob is
25647. All of the processesin a single pipeline are membersof the same job. bash usesthe job abstraction asthe basisfor job
control.
To facilitate the implementation of the user interface to job control, the system maintainsthe notion of a current terminal
processgroup ID. Membersof thisprocessgroup (processeswhose processgroup ID isequal to the current terminal process
group ID) receive keyboard-generated signalssuch asSIGINT. These processesare said to be in the foreground. Background
processesare those whose processgroup ID differsfrom the terminals; such processesare immune to keyboard-generated
signals. Only foreground processesare allowed to read from or write to the terminal. Background processesthat attempt to
read from (write to) the terminal are sent a SIGTTIN (SIGTTOU) signal by the terminal driver, which, unlesscaught, suspends
the process.
If the operating system on which bash isrunning supportsjob control, bash allowsyou to use it. Typing the suspend
character (typically Z, Control-Z) while a processisrunning causesthat processto be stopped and returnsyou to bash.
Typing the delayed suspend character (typically Y, Control-Y) causesthe processto be stopped when it attemptsto read
input from the terminal, and control to be returned to bash. You may then manipulate the state of thisjob, using the bg
command to continue it in the background, the fg command to continue it in the foreground, or the kill command to kill
it. A Ctrl+Z takeseffect immediately, and hasthe additional side effect of causing pending output and typeahead to be
discarded.
There are a number of waysto refer to a job in the shell. The character % introducesa job name. Job number n may be
referred to as%n. A job may also be referred to using a prefix of the name used to start it, or using a substring that appearsin
itscommand line. For example, %ce refersto a stopped ce job. If a prefix matchesmore than one job, bash reportsan error.
Using %?ce, on the other hand, refersto any job containing the string ce in itscommand line. If the substring matchesmore
than one job, bash reportsan error. The symbols%% and %+ refer to the shellsnotion of the current job, which isthe last job
25
stopped while it wasin the foreground. The previousjob may be referenced using %.In output pertaining to jobs(for
example, the output of the jobs command), the current job isalwaysflagged with a +, and the previousjob with a .
Simply naming a job can be used to bring it into the foreground: %1 isa synonym for fg %1, bringing job 1 from the
background into the foreground. Similarly, %1 & resumesjob 1 in the background, equivalent to bg %1.
The shell learnsimmediately whenever a job changesstate. Normally, bash waitsuntil it isabout to print a prompt before
reporting changesin a jobsstatusso asto not interrupt any other output. If the -b option to the set built-in command isset,
bash reportssuch changesimmediately. (See also the description of the notify variable in Shell Variables, earlier in this
manual page.)
If you attempt to exit bash while jobsare stopped, the shell printsa message warning you. You may then use the jobs
command to inspect their status. If you do this, or try to exit again immediately, you are not warned again, and the stopped
jobsare terminated.
SIGNALS
When bash isinteractive, it ignoresSIGTERM (so that kill 0 doesnot kill an interactive shell), and SIGINT iscaught and
handled (so that the wait built-in isinterruptible). In all cases, bash ignoresSIGQUIT. If job control isin effect, bash ignores
SIGTTIN, SIGTTOU, and SIGTSTP.
Synchronousjobsstarted by bash have signalsset to the valuesinherited by the shell from itsparent. When job control isnot
in effect, background jobs(jobsstarted with &) ignore SIGINT and SIGQUIT. Commandsrun asa result of command substitu-
tion ignore the keyboard-generated job control signalsSIGTTIN, SIGTTOU, and SIGTSTP.
COMMAND EXECUTION
After a command hasbeen split into words, if it resultsin a simple command and an optional list of arguments, the
following actionsare taken.
If the command name containsno slashes, the shell attemptsto locate it. If there existsa shell function by that name, that
function isinvoked asdescribed earlier in Functions. If the name doesnot match a function, the shell searchesfor it in the
list of shell builtins. If a match isfound, that builtin isinvoked.
If the name isneither a shell function nor a builtin, and containsno slashes, bash searcheseach element of the PATH for a
directory containing an executable file by that name. If the search isunsuccessful, the shell printsan error message and
returnsa nonzero exit status.
If the search issuccessful, or if the command name containsone or more slashes, the shell executesthe named program.
Argument 0 isset to the name given, and the remaining argumentsto the command are set to the argumentsgiven, if any.
If thisexecution failsbecause the file isnot in executable format, and the file isnot a directory, it isassumed to be a shell
script, a file containing shell commands. A subshell isspawned to execute it. Thissubshell reinitializesitself, so that the effect
isasif a new shell had been invoked to handle the script, with the exception that the locationsof commandsremembered by
the parent (see hash under Shell Built-in Commands) are retained by the child.
If the program isa file beginning with #!, the remainder of the first line specifiesan interpreter for the program. The shell
executesthe specified interpreter on operating systemsthat do not handle thisexecutable format themselves. The arguments
to the interpreter consist of a single optional argument following the interpreter name on the first line of the program,
followed by the name of the program, followed by the command arguments, if any.
ENVIRONMENT
When a program isinvoked, it isgiven an array of stringscalled the environment. Thisisa list of name/value pairs, of the
form name=value.
The shell allowsyou to manipulate the environment in several ways. On invocation, the shell scansitsown environment and
createsa parameter for each name found, automatically marking it for export to child processes. Executed commandsinherit
the environment. The export and declare x commandsallow parametersand functionsto be added to and deleted from the
environment. If the value of a parameter in the environment ismodified, the new value becomespart of the environment,
bash
Part I: User Commands
26
replacing the old. The environment inherited by any executed command consistsof the shellsinitial environment, whose
valuesmay be modified in the shell, lessany pairsremoved by the unset command, plusany additionsvia the export and
declare x commands.
The environment for any simple command or function may be augmented temporarily by prefixing it with parameter
assignments, asdescribed earlier in Parameters. These assignment statementsaffect only the environment seen by that
command.
If the k flag isset (see the set built-in command), then all parameter assignmentsare placed in the environment for a
command, not just those that precede the command name.
When bash invokesan external command, the variable isset to the full path name of the command and passed to that
command in itsenvironment.
EXIT STATUS
For the purposesof the shell, a command which exitswith a zero exit statushassucceeded. An exit statusof zero indicates
success. A nonzero exit statusindicatesfailure. When a command terminateson a fatal signal, bash usesthe value of
128+signal asthe exit status.
If a command isnot found, the child processcreated to execute it returnsa statusof 127. If a command isfound but isnot
executable, the return statusis126.
bash itself returnsthe exit statusof the last command executed, unlessa syntax error occurs, in which case it exitswith a non
zero value. (See also the exit built-in command.)
PROMPTING
When executing interactively, bash displaysthe primary prompt PS1 when it isready to read a command, and the secondary
prompt PS2 when it needsmore input to complete a command. bash allowsthese prompt stringsto be customized by
inserting a number of backslash-escaped special charactersthat are decoded asfollows:
\t The current time in HH: MM: SS format
\d The date in Weekday Month Date format (for example, Tue May 26)
\n Newline
\s The name of the shell, the basename of $0 (the portion following the final slash)
\w The current working directory
\W The basename of the current working directory
\u The username of the current user
\h The hostname
\# The command number of thiscommand
\! The history number of thiscommand
\$ If the effective UID is0, a #, otherwise a $
\nnn The character corresponding to the octal number nnn
\\ A backslash
\[ Begin a sequence of nonprinting characters, which could be used to embed a terminal control sequence
into the prompt
\] End a sequence of nonprinting characters
The command number and the history number are usually different: the history number of a command isitsposition in the
history list, which may include commandsrestored from the history file (see History, later in thismanual page), while the
command number isthe position in the sequence of commandsexecuted during the current shell session. After the string is
decoded, it isexpanded via parameter expansion, command substitution, arithmetic expansion, and word splitting.
27
READLINE
Thisisthe library that handlesreading input when using an interactive shell, unlessthe nolineediting option isgiven. By
default, the line editing commandsare similar to those of emacs. A vi-style line editing interface isalso available.
In thissection, the emacs-style notation isused to denote keystrokes. Control keysare denoted by Ckey ; for example, Cn
meansCtrlN. Similarly, meta keysare denoted by Mkey, so Mx meansMetaX. (On keyboardswithout a meta key, Mx
meansEsc-X; that is, pressthe Escape key, then the X key. ThismakesESC the meta prefix. The combination MCx means
EscControlx, or pressthe Escape key then hold the Control key while pressing the X key.)
The default key-bindingsmay be changed with a /.inputrc file. The value of the shell variable INPUTRC, if set, isused instead
of /.inputrc. Other programsthat use thislibrary may add their own commandsand bindings.
For example, placing
MControlu: uni ver sal ar gument
or
CMetau: uni ver sal ar gument
into the /.inputrc would make MCu execute the readline command universalargument.The following symbolic character
namesare recognized: RUBOUT, DEL, ESC, LFD, NEWLINE, RET, RETURN, SPC, SPACE, and TAB. In addition to command names,
readline allowskeysto be bound to a string that isinserted when the key ispressed (a macro).
Readline iscustomized by putting commandsin an initialization file. The name of thisfile istaken from the value of the
INPUTRC variable. If that variable isunset, the default is/.inputrc. When a program that usesthe readline library startsup,
the init file isread, and the key bindingsand variablesare set. There are only a few basic constructsallowed in the readline
init file. Blank linesare ignored. Linesbeginning with a # are comments. Linesbeginning with a $ indicate conditional
constructs. Other linesdenote key bindingsand variable settings.
The syntax for controlling key bindingsin the /.inputrc file issimple. All that isrequired isthe name of the command or
the text of a macro and a key sequence to which it should be bound. The name may be specified in one of two ways: asa
symbolic key name, possibly with Meta- or Control- prefixes, or asa key sequence. When using the form keyname: f unct i on-
name or macr o, keyname isthe name of a key spelled out in English. For example,
Control-u: uni ver sal ar gument
Meta-Rubout: backward-kill-word
Control-o: >&output
In the preceding example, C-u isbound to the function universalargument, M-DEL isbound to the function backwardkill
word,and C-o isbound to run the macro expressed on the righthand side (that is, to insert the text >&output into the line).
In the second form, keyseq : f unc t i on- name or macr o, keyseq differsfrom keyname in that stringsdenoting an entire key
sequence may be specified by placing the sequence within double quotes. Some GNU emacs-style key escapescan be used, as
in the following example:
\C-u: uni ver sal ar gument
\C-x\C-r: rereadinitfile
\e[11: Function Key 1
In thisexample, C-u isagain bound to the function universalargument. C-x C-r isbound to the function rereadinitfile,
and ESC[11 isbound to insert the text Function Key 1. The full set of escape sequencesis
\C Control prefix
\M- Meta prefix
\e An escape character
\\ Backslash
\ Literal
\ Literal
bash
Part I: User Commands
28
When entering the text of a macro, single or double quotesshould be used to indicate a macro definition. Unquoted text is
assumed to be a function name. Backslash will quote any character in the macro text, including and .
bash allowsthe current readline key bindingsto be displayed or modified with the bind built-in command. The editing
mode may be switched during interactive use by using the o option to the set built-in command. (See Shell Built-in
Commands.)
Readline hasvariablesthat can be used to further customize itsbehavior. A variable may be set in the inputrc file with a
statement of the form:
set variablename value
Except where noted, readline variablescan take the valuesOn or Off. The variablesand their default valuesare asfollows:
horizontalscrollmode (Off) When set to On, makesreadline use a single line for display, scrolling the input
horizontally on a single screen line when it becomeslonger than the screen width
rather than wrapping to a new line.
editingmode (emacs) Controlswhether readline beginswith a set of key bindingssimilar to emacs or vi.
editingmode can be set to either emacs or vi.
markmodifiedlines (Off) If set to On, history linesthat have been modified are displayed with a preceding
asterisk (*).
bellstyle (audible) Controlswhat happenswhen readline wantsto ring the terminal bell. If set to none,
readline never ringsthe bell. If set to visible, readline usesa visible bell if one is
available. If set to audible, readline attemptsto ring the terminalsbell.
commentbegin (#) The string that isinserted in vi mode when the vicomment command isexecuted.
metaflag (Off) If set to On, readline will enable eight-bit input (that is, it will not strip the high bit
from the charactersit reads), regardlessof what the terminal claimsit can support.
convertmeta (On) If set to On, readline will convert characterswith the eighth bit set to an ASCII key
sequence by stripping the eighth bit and prepending an escape character (in effect,
using escape asthe meta prefix).
outputmeta (Off) If set to On, readline will display characterswith the eighth bit set directly rather
than asa meta-prefixed escape sequence.
completionqueryitems (100) Thisdetermineswhen the user isqueried about viewing the number of possible
completionsgenerated by the possiblecompletions command. It may be set to any
integer value greater than or equal to zero. If the number of possible completionsis
greater than or equal to the value of thisvariable, the user isasked whether or not he
wishesto view them; otherwise, they are simply listed on the terminal.
keymap (emacs) Set the current readline keymap. The set of legal keymap namesisemacs, emacs-
standard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command, and vi-insert. vi is
equivalent to vi-command; emacs isequivalent to emacs-standard. The default value is
emacs; the value of editingmode also affectsthe default keymap.
showallifambiguous (Off) Thisaltersthe default behavior of the completion functions. If set to On, words
which have more than one possible completion cause the matchesto be listed
immediately instead of ringing the bell.
expandtilde (Off) If set to On, tilde expansion isperformed when readline attemptsword completion.
Readline implementsa facility similar in spirit to the conditional compilation featuresof the C preprocessor that allowskey
bindingsand variable settingsto be performed asthe result of tests. There are three parser directivesused.
$if The $if construct allowsbindingsto be made based on the editing mode, the
terminal being used, or the application using readline. The text of the test extends
to the end of the line; no charactersare required to isolate it.
29
mode The mode= form of the $if directive isused to test whether
readline isin emacs or vi mode. Thismay be used in conjunction
with the set keymap command, for instance, to set bindingsin the
emacs-standard and emacs-ctlx keymapsonly if readline isstarting
out in emacs mode.
term The term= form may be used to include terminal-specific key
bindings, perhapsto bind the key sequencesoutput by the
terminalsfunction keys. The word on the right side of the = is
tested against the full name of the terminal and the portion of the
terminal name before the first . Thisallowssun to match both
sun and suncmd, for instance.
application The application construct isused to include applicationspecific
settings. Each program using the readline library setsthe
application name, and an initialization file can test for a particular
value. Thiscould be used to bind key sequencesto functions
useful for a specific program. For instance, the following
command addsa key sequence that quotesthe current or previous
word in bash:
$if Bash
# Quot e t he cur r ent or pr evi ous wor d
\C-xq: \eb\\ef\
$endif
$endif Thiscommand, asshown in the preceding example, terminatesan $if command.
$else Commandsin thisbranch of the $if directive are executed if the test fails.
readline commandsmay be given numeric arguments, which normally act asa repeat count. Sometimes, however, it isthe
sign of the argument that issignificant. Passing a negative argument to a command that actsin the forward direction (such as
killline) causesthat command to act in a backward direction. Commandswhose behavior with argumentsdeviatesfrom
thisare noted.
When a command isdescribed askilling text, the text deleted issaved for possible future retrieval (yanking). The killed text
issaved in a killring. Consecutive killscause the text to be accumulated into one unit, which can be yanked all at once.
Commandsthat do not kill text separate the chunksof text on the killring.
The following isa list of the namesof the commandsand the default key sequencesto which they are bound.
Commandsfor Moving
beginningofline (Ca) Move to the start of the current line.
endofline (Ce) Move to the end of the line.
forwardchar (Cf) Move forward a character.
backwardchar (Cb) Move back a character.
forwardword (Mf) Move forward to the end of the next word. Wordsare composed of alphanu-
meric characters(lettersand digits).
backwardword (Mb) Move back to the start of this, or the previous, word. Wordsare composed of
alphanumeric characters(lettersand digits).
clearscreen (Cl) Clear the screen leaving the current line at the top of the screen. With an
argument, refresh the current line without clearing the screen.
redrawcurrentline Refresh the current line. By default, thisisunbound.
bash
Part I: User Commands
30
Commandsfor ManipulatingtheHistory
acceptline (Newline, Return) Accept the line regardlessof where the cursor is. If thisline isnonempty, add it
to the history list according to the state of the HIST-CONTROL variable. If the line is
a modified history line, then restore the history line to itsoriginal state.
previoushistory (Cp) Fetch the previouscommand from the history list, moving back in the list.
nexthistory (Cn) Fetch the next command from the history list, moving forward in the list.
beginningofhistory (M<) Move to the first line in the history.
endofhistory (M>) Move to the end of the input history, that is, the line currently being entered.
reversesearchhistory (Cr) Search backward starting at the current line and moving up through the
history asnecessary. Thisisan incremental search.
forwardsearchhistory (Cs) Search forward starting at the current line and moving down through the
history asnecessary. Thisisan incremental search.
nonincrementalreverse Search backward through the history, starting at the current line using a non
searchhistory (Mp) incremental search for a string supplied by the user.
nonincrementalforward Search forward through the history using a nonincremental search for a string
searchhistory (Mn) supplied by the user.
historysearchforward Search forward through the history for the string of charactersbetween the start
of the current line and the current point. Thisisa nonincremental search. By
default, thiscommand isunbound.
historysearchbackward Search backward through the history for the string of charactersbetween the start
of the current line and the current point. Thisisa nonincremental search. By
default, thiscommand isunbound.
yankntharg (MCy) Insert the first argument to the previouscommand (usually the second word on
the previousline) at point (the current cursor position). With an argument n,
insert the nth word from the previouscommand (the wordsin the previous
command begin with word 0). A negative argument insertsthe nth word from
the end of the previouscommand.
yanklastarg (M., M_) Insert the last argument to the previouscommand (the last word on the previous
line). With an argument, behave exactly like @codefyank-nth-argg.
shellexpandline (MCe) Expand the line the way the shell doeswhen it readsit. Thisperformsaliasand
history expansion aswell asall of the shell word expansions. See History
Expansion, later in thismanual page, for a description of history expansion.
historyexpandline (M) Perform history expansion on the current line. See History Expansion.
insertlastargument (M., M_) A synonym for yanklastarg.
operate-and-get-next (Co) Accept the current line for execution and fetch the next line relative to the
current line from the history for editing. Any argument isignored.
Commandsfor ChangingText
deletechar (Cd) Delete the character under the cursor. If point isat the beginning of the line,
there are no charactersin the line, and the last character typed wasnot Cd, then
return EOF.
backwarddeletechar (Rubout) Delete the character behind the cursor. When given a numeric argument, save
the deleted text on the killring.
quotedinsert (Cq, Cv) Add the next character that you type to the line verbatim. Thisishow to insert
characterslike Cq, for example.
tabinsert (C-v Tab) Insert a tab character.
selfinsert (a, b, A, 1, !, ...) Insert the character typed.
31
transposechars (Ct) Drag the character before point forward over the character at point. Point moves
forward aswell. If point isat the end of the line, then transpose the two
charactersbefore point. Negative argumentsdont work.
transposewords (Mt) Drag the word behind the cursor past the word in front of the cursor, moving
the cursor over that word aswell.
upcaseword (Mu) Uppercase the current (or following) word. With a negative argument, do the
previousword, but do not move point.
downcaseword (Ml) Lowercase the current (or following) word. With a negative argument, do the
previousword, but do not move point.
capitalizeword (Mc) Capitalize the current (or following) word. With a negative argument, do the
previousword, but do not move point.
Killingand Yanking
killline (Ck) Kill the text from the current cursor position to the end of the line.
backwardkillline (Cx CRubout) Kill backward to the beginning of the line.
UNIXlinediscard (Cu) Kill backward from point to the beginning of the line.
killwholeline Kill all characterson the current line, no matter where the cursor is. By default,
thisisunbound.
killword (Md) Kill from the cursor to the end of the current word, or if between words, to the
end of the next word. Word boundariesare the same asthose used by forward
word.
backwardkillword (MRubout) Kill the word behind the cursor. Word boundariesare the same asthose used by
backwardword.
UNIXwordrubout (Cw) Kill the word behind the cursor, using whitespace asa word boundary. The word
boundariesare different from backwardkillword.
deletehorizontalspace Delete all spacesand tabsaround point. By default, thisisunbound.
yank (Cy) Yank the top of the kill ring into the buffer at the cursor.
yankpop (My) Rotate the killring, and yank the new top. Only worksfollowing yank or yank
pop.
NumericArguments
digitargument (M0, M1, ..., M) Add thisdigit to the argument already accumulating, or start a new argument.
M startsa negative argument.
universalargument Each time thisisexecuted, the argument count ismultiplied by four. The
argument count isinitially one, so executing thisfunction the first time makes
the argument count four. By default, thisisnot bound to a key.
Completing
complete (TAB) Attempt to perform completion on the text before point. Bash attempts
completion treating the text asa variable (if the text beginswith $), username (if
the text beginswith ), hostname (if the text beginswith @), or command
(including aliasesand functions) in turn. If none of these producesa match,
filename completion isattempted.
possiblecompletions (M-?) List the possible completionsof the text before point.
insertcompletions Insert all completionsof the text before point that would have been generated by
possiblecompletions. By default, thisisnot bound to a key.
completefilename (M/) Attempt filename completion on the text before point.
continues
bash
Part I: User Commands
32
possiblefilenamecompletions (Cx /) List the possible completionsof the text before point, treating it asa filename.
completeusername (M) Attempt completion on the text before point, treating it asa username.
possibleusernamecompletions (Cx ) List the possible completionsof the text before point, treating it asa username.
completevariable (M$) Attempt completion on the text before point, treating it asa shell variable.
possiblevariablecompletions (Cx $) List the possible completionsof the text before point, treating it asa shell
variable.
completehostname (M@) Attempt completion on the text before point, treating it asa hostname.
possiblehostnamecompletions (Cx @) List the possible completionsof the text before point, treating it asa hostname.
completecommand (M!) Attempt completion on the text before point, treating it asa command name.
Command completion attemptsto match the text against aliases, reserved words,
shell functions, builtins, and finally executable filenames, in that order.
possiblecommandcompletions (Cx !) List the possible completionsof the text before point, treating it asa command
name.
dynamiccompletehistory (M-TAB) Attempt completion on the text before point, comparing the text against lines
from the history list for possible completion matches.
completeintobraces (M{) Perform filename completion and return the list of possible completionsenclosed
within bracesso the list isavailable to the shell. (See Brace Expansion, earlier in
thismanual page.)
Keyboard Macros
startkbdmacro (C-x () Begin saving the characterstyped into the current keyboard macro.
endkbdmacro (C-x )) Stop saving the characterstyped into the current keyboard macro and save the
definition.
calllastkbdmacro (C-x e) Re-execute the last keyboard macro defined, by making the charactersin the
macro appear asif typed at the keyboard.
Miscellaneous
rereadinitfile (Cx Cr) Read in the contentsof your init file, and incorporate any bindingsor variable
assignmentsfound there.
abort (Cg) Abort the current editing command and ring the terminalsbell (subject to the
setting of bellstyle).
douppercaseversion (Ma, Mb, ...) Run the command that isbound to the corresponding uppercase character.
prefixmeta (ESC) Metafy the next character typed. ESC-f isequivalent to Metaf.
undo (C-_, Cx Cu) Incremental undo, separately remembered for each line.
revertline (Mr) Undo all changesmade to thisline. Thisislike typing the undo command
enough timesto return the line to itsinitial state.
tildeexpand (M) Perform tilde expansion on the current word.
dumpfunctions Print all of the functionsand their key bindingsto the readline output stream. If
a numeric argument issupplied, the output isformatted in such a way that it can
be made part of an inputrc file.
displayshellversion (Cx Cv) Display version information about the current instance of bash.
emacseditingmode (Ce) When in vi editing mode, thiscausesa switch to emacs editing mode.
HISTORY
When interactive, the shell providesaccessto the command history, the list of commandspreviously typed. The text of the
last HISTSIZE commands(default 500) issaved in a history list. The shell storeseach command in the history list prior to
Completing
33
parameter and variable expansion (see Expansion, earlier in thismanual page) but after history expansion isperformed,
subject to the valuesof the shell variablescommand_oriented_history and HISTCONTROL. On startup, the history isinitialized
from the file named by the variable HISTFILE (default /.bash_history). HISTFILE istruncated, if necessary, to contain no
more than HISTFILESIZE lines. The built-in command fc (see Shell Built-in Commands, later in thismanual page) may be
used to list or edit and re-execute a portion of the history list. The history builtin can be used to display the history list and
manipulate the history file. When using the command-line editing, search commandsare available in each editing mode that
provide accessto the history list. When an interactive shell exits, the last HISTSIZE linesare copied from the history list to
HISTFILE. If HISTFILE isunset, or if the history file isunwritable, the history isnot saved.
HISTORY EXPANSION
The shell supportsa history expansion feature that issimilar to the history expansion in csh. Thissection describeswhat
syntax featuresare available. Thisfeature isenabled by default for interactive shells, and can be disabled using the H option to
the set built-in command. (See Shell Built-in Commands, later in thismanual page.) Noninteractive shellsdo not perform
history expansion.
History expansion isperformed immediately after a complete line isread, before the shell breaksit into words. It takesplace
in two parts. The first isto determine which line from the previoushistory to use during substitution. The second isto select
portionsof that line for inclusion into the current one. The line selected from the previoushistory isthe event, and the
portionsof that line that are acted upon are words. The line isbroken into wordsin the same fashion aswhen reading input,
so that several meta characterseparated wordssurrounded by quotesare considered asone word. Only the backslash (\) and
single quotescan quote the history escape character, which is! by default.
The shell allowscontrol of the variouscharactersused by the history expansion mechanism. (See the description of histchars
under Shell Variables, earlier in thismanual page.)
EVENT DESIGNATORS
An event designator isa reference to a command line entry in the history list.
! Start a history substitution, except when followed by a blank, newline, =, or (.
!! Refer to the previouscommand. Thisisa synonym for !1.
!n Refer to command line n.
!n Refer to the current command line minusn.
!st r i ng Refer to the most recent command starting with st r i ng.
!?st r i ng[?] Refer to the most recent command containing st r i ng.
st r i ng1st r i ng2 Quick substitution. Repeat the last command, replacing st r i ng1 with st r i ng2. Equivalent to !!:s/
st r i ng1/st r i ng2/. (See Modifiers, later in thismanual page.)
!# The entire command line typed so far.
WORD DESIGNATORS
A colon (:) separatesthe event specification from the word designator. It can be omitted if the word designator beginswith a
^, $, *, or %. Wordsare numbered from the beginning of the line, with the first word being denoted by a 0 (zero).
0 (zero) The zeroth word. For the shell, thisisthe command word.
n The nth word.
The first argument. That is, word 1.
$ The last argument.
% The word matched by the most recent ?string? search.
xy A range of words; y abbreviates0y.
* All of the wordsbut the zeroth. Thisisa synonym for 1$. It isnot an error to use * if there isjust
one word in the event; the empty string isreturned in that case.
x* Abbreviatesx$.
x Abbreviatesx$ like x*, but omitsthe last word.
bash
Part I: User Commands
34
MODIFIERS
After the optional word designator, you can add a sequence of one or more of the following modifiers, each preceded by a :
h Remove a trailing pathname component, leaving only the head.
r Remove a trailing suffix of the form .xxx, leaving the basename.
e Remove all but the trailing suffix.
t Remove all leading pathname components, leaving the tail.
p Print the new command but do not execute it.
q Quote the substituted words, escaping further substitutions.
x Quote the substituted wordsaswith q, but break into wordsat blanksand newlines.
s/ol d/new/ Substitute new for the first occurrence of ol d in the event line. Any delimiter can be used in place of
/. The final delimiter isoptional if it isthe last character of the event line. The delimiter may be
quoted in old and new with a single backslash. If & appearsin new, it isreplaced by ol d. A single
backslash will quote the &.
& Repeat the previoussubstitution.
g Cause changesto be applied over the entire event line. Thisisused in conjunction with :s (for
example, :gs/ol d/new/) or :&. If used with :s, any delimiter can be used in place of /, and the final
delimiter isoptional if it isthe last character of the event line.
ARITHMETIC EVALUATION
The shell allowsarithmetic expressionsto be evaluated, under certain circumstances. (See the let built-in command and
Arithmetic Expansion.) Evaluation isdone in long integerswith no check for overflow, though division by 0 istrapped and
flagged asan error. The following list of operatorsisgrouped into levelsof equal-precedence operators. The levelsare listed
in order of decreasing precedence.
+ Unary minusand plus
! Logical and bitwise negation
* / % Multiplication, division, remainder
+ Addition, subtraction
<< >> Left and right bitwise shifts
<= >= <> Comparison
== != Equality and inequality
& Bitwise AND
^ Bitwise exclusive OR
| Bitwise OR
&& Logical AND
|| Logical OR
= *= /= %= += = <<= >>=&==|= Assignment
Shell variablesare allowed asoperands; parameter expansion isperformed before the expression isevaluated. The value of a
parameter iscoerced to a long integer within an expression. A shell variable need not have itsinteger attribute turned on to
be used in an expression.
Constantswith a leading 0 are interpreted asoctal numbers. A leading 0x or 0X denoteshexadecimal. Otherwise, numbers
take the form [base#]n, where base isa decimal number between 2 and 36 representing the arithmetic base, and n isa
number in that base. If base isomitted, then base 10 isused.
Operatorsare evaluated in order of precedence. Subexpressionsin parenthesesare evaluated first and may override the
precedence rules.
35
SHELL BUILT-IN COMMANDS
: [ar gument s] No effect; the command doesnothing beyond expanding argumentsand performing
any specified redirections. A zero exit code isreturned.
. f i l ename [ar gument s] Read and execute commandsfrom f i l ename in the current shell environment and
source f i l ename [ar gument s] return the exit statusof the last command executed from f i l ename. If f i l ename does
not contain a slash, pathnamesin PATH are used to find the directory containing
filename. The file searched for in PATH need not be executable. The current directory
issearched if no file isfound in PATH. If any argumentsare supplied, they become the
positional parameterswhen file isexecuted. Otherwise, the positional parameters
are unchanged. The return statusisthe statusof the last command exited within the
script (0 if no commandsare executed), and False if filename isnot found.
alias [name[=val ue] ...] alias with no argumentsprintsthe list of aliasesin the form name=val ue on standard
output. When argumentsare supplied, an aliasisdefined for each name whose value
isgiven. A trailing space in value causesthe next word to be checked for alias
substitution when the aliasisexpanded. For each name in the argument list for
which no value issupplied, the name and value of the aliasisprinted. alias returns
True unlessa name isgiven for which no aliashasbeen defined.
bg [j obspec ] Place j obspec in the background, asif it had been started with &. If j obspec isnot
present, the shellsnotion of the current job isused. bg jobspec returns0 unlessrun
when job control isdisabled or, when run with job control enabled, if jobspec was
not found or started without job control.
bind [m keymap][lvd][-q name] Display current readline key and function bindings, or bind a key sequence to a
bind [m keymap] -f f i l ename readline function or macro. The binding syntax accepted isidentical to that of
bind [m keymap] .inputrc, but each binding must be passed asa separate argument; for example,
keyseq: f unct i on- name \C-x\C-r: rereadinitfile. Options, if supplied, have the following meanings:
m keymap Use keymap asthe keymap to be affected by the subsequent
bindings. Acceptable keymap namesare emacs, emacs-standard,
emacs-meta, emacs-ctlx, vi, vi-move, vi-command, and vi-insert.
vi isequivalent to vi-command; emacs isequivalent to emacs-
standard.
l List the namesof all readline functions.
v List current function namesand bindings.
d Dump function namesand bindingsin such a way that they
can be reread.
f f i l ename Read key bindingsfrom filename.
q f unct i on Query about which keysinvoke the named function.
The return value is0 unlessan unrecognized option isgiven or an error occurred.
break [n] Exit from within a for, while, or until loop. If n isspecified, break n levels. n must
be 1. If n isgreater than the number of enclosing loops, all enclosing loopsare
exited. The return value is0 unlessthe shell isnot executing a loop when break is
executed.
builtin shel l bui l t i n [ar gument s] Execute the specified shell builtin, passing it arguments, and return itsexit status.
Thisisuseful when you wish to define a function whose name isthe same asa shell
builtin, but need the functionality of the builtin within the function itself. The cd
builtin iscommonly redefined thisway. The return statusisFalse if shel l bui l t i n is
not a shell builtin command.
cd [di r ] Change the current directory to di r . The variable HOME isthe default di r . The
variable CDPATH definesthe search path for the directory containing di r . Alternative
directory namesare separated by a colon (:). A null directory name in CDPATH isthe
same asthe current directory, that is, (.). If di r beginswith a slash (/), then CDPATH is
bash
Part I: User Commands
36
not used. An argument of isequivalent to $OLDPWD. The return value isTrue if the
directory wassuccessfully changed; False otherwise.
command [-pVv] command [ar g ...] Run command with args suppressing the normal shell function lookup. Only built-
in commandsor commandsfound in the PATH are executed. If the p option isgiven,
the search for command isperformed using a default value for PATH that isguaranteed
to find all of the standard utilities. If either the V or v option issupplied, a
description of command isprinted. The v option causesa single word indicating the
command or pathname used to invoke command to be printed; the V option
producesa more verbose description. An argument of disablesoption checking for
the rest of the arguments. If the V or v option issupplied, the exit statusis0 if
command wasfound, and 1 if not. If neither option issupplied and an error occurred
or command cannot be found, the exit statusis127. Otherwise, the exit statusof the
command builtin isthe exit statusof command.
continue [n] Resume the next iteration of the enclosing for, while, or until loop. If n isspecified,
resume at the nth enclosing loop. n must be 1. If n isgreater than the number of
enclosing loops, the last enclosing loop (the toplevel loop) isresumed. The return
value is0 unlessthe shell isnot executing a loop when continue isexecuted.
declare [frxi][name[=val ue]] Declare variablesand/or give them attributes. If no namesare given, then display the
typeset [frxi][name[=val ue]] valuesof variablesinstead. The optionscan be used to restrict output to variables
with the specified attribute.
f Use function namesonly.
-r Make namesread-only. These namescannot then be assigned
valuesby subsequent assignment statements.
x Mark namesfor export to subsequent commandsvia the
environment.
i The variable istreated asan integer; arithmetic evaluation (see
Arithmetic Evaluation) isperformed when the variable is
assigned a value.
Using + instead of turnsoff the attribute instead. When used in a function, makes
nameslocal, aswith the local command. The return value is0 unlessan illegal
option isencountered, an attempt ismade to define a function using -f foo=bar,
one of the namesisnot a legal shell variable name, an attempt ismade to turn off
read-only statusfor a read-only variable, or an attempt ismade to display a
nonexistent function with -f.
dirs [-l][+/n] Display the list of currently remembered directories. Directoriesare added to the list
with the pushd command; the popd command movesback up through the list.
+n Displaysthe nth entry counting from the left of the list shown
by dirs when invoked without options, starting with zero.
n Displaysthe nth entry counting from the right of the list
shown by dirs when invoked without options, starting with
zero.
l Producesa longer listing; the default listing format usesa tilde
to denote the home directory.
The return value is0 unlessan illegal option issupplied or n indexesbeyond the end
of the directory stack.
echo [neE][ar g ...] Output the args, separated by spaces. The return statusisalways0. If n isspecified,
the trailing newline issuppressed. If the e option isgiven, interpretation of the
following backslash-escaped charactersisenabled. The E option disablesthe
interpretation of these escape characters, even on systemswhere they are interpreted
by default.
37
\a Alert (bell)
\b Backspace
\c Suppresstrailing newline
\f Form feed
\n Newline
\r Carriage return
\t Horizontal tab
\v Vertical tab
\\ Backslash
\nnn The character whose ASCII code isnnn (octal)
enable [n][all][name ...] Enable and disable builtin shell commands. Thisallowsthe execution of a disk
command that hasthe same name asa shell builtin without specifying a full
pathname. If n isused, each name isdisabled; otherwise, namesare enabled. For
example, to use the test binary found via the PATH instead of the shell builtin version,
type enable -n test. If no argumentsare given, a list of all enabled shell builtinsis
printed. If only n issupplied, a list of all disabled builtinsisprinted. If only all is
supplied, the list printed includesall builtins, with an indication of whether or not
each isenabled. enable acceptsa asa synonym for all. The return value is0 unless
a name isnot a shell builtin.
eval [ar g ...] The args are read and concatenated together into a single command. Thiscommand
isthen read and executed by the shell, and itsexit statusisreturned asthe value of
the eval command. If there are no args, or only null arguments, eval returnsTrue.
exec [[] command [ar gument s]] If command isspecified, it replacesthe shell. No new processiscreated. The arguments
become the argumentsto command. If the first argument is, the shell placesa dash in
the zeroth arg passed to command. Thisiswhat login does. If the file cannot be
executed for some reason, a noninteractive shell exits, unlessthe shell variable
no_exit_on_failed_exec exists, in which case it returnsfailure. An interactive shell
returnsfailure if the file cannot be executed. If command isnot specified, any
redirectionstake effect in the current shell, and the return statusis0.
exit [n] Cause the shell to exit with a statusof n. If n isomitted, the exit statusisthat of the
last command executed. A trap on exit isexecuted before the shell terminates.
export [nf][name[=wor d]] ... The supplied namesare marked for automatic export to the environment of
export p subsequently executed commands. If the f option isgiven, the namesrefer to
functions. If no namesare given, or if the p option issupplied, a list of all names
that are exported in thisshell isprinted. The n option causesthe export property to
be removed from the named variables. An argument of disablesoption checking
for the rest of the arguments. export returnsan exit statusof 0 unlessan illegal
option isencountered, one of the namesisnot a legal shell variable name, or f is
supplied with a name that isnot a function.
fc [e ename][nlr][f i r st ][l ast ] Fix command. In the first form, a range of commandsfrom f i r st to l ast isselected
fc s [pat =r ep][cmd] from the history list. f i r st and l ast may be specified asa string (to locate the last
command beginning with that string) or asa number (an index into the history list,
where a negative number isused asan offset from the current command number). If
l ast isnot specified, it isset to the current command for listing (so that fc l
10 printsthe last 10 commands) and to first otherwise. If first isnot specified, it
isset to the previouscommand for editing and 16 for listing.
The n flag suppressesthe command numberswhen listing. The -r flag reversesthe
order of the commands. If the l flag isgiven, the commandsare listed on standard
output. Otherwise, the editor given by ename isinvoked on a file containing those
commands. If ename isnot given, the value of the FCEDIT variable isused, and the
bash
Part I: User Commands
38
value of EDITOR if FCEDIT isnot set. If neither variable isset, vi isused. When editing
iscomplete, the edited commandsare echoed and executed.
In the second form, command isreexecuted after each instance of pat isreplaced by
r ep. A useful aliasto use with thisisr=fc s, so that typing r cc runsthe last
command beginning with cc and typing r reexecutesthe last command.
If the first form isused, the return value is0 unlessan illegal option isencountered
or f i r st or l ast specify history linesout of range. If the e option issupplied, the
return value isthe value of the last command executed or failure if an error occurs
with the temporary file of commands. If the second form isused, the return statusis
that of the command reexecuted, unlesscmd doesnot specify a valid history line, in
which case fc returnsfailure.
fg [j obspec ] Place j obspec in the foreground, and make it the current job. If j obspec isnot
present, the shellsnotion of the current job isused. The return value isthat of the
command placed into the foreground, or failure if run when job control isdisabled
or, when run with job control enabled, if j obspec doesnot specify a valid job or
j obspec specifiesa job that wasstarted without job control.
getopts opt st r i ng name [ar gs] getopts isused by shell proceduresto parse positional parameters. opt st r i ng contains
the option lettersto be recognized; if a letter isfollowed by a colon, the option is
expected to have an argument, which should be separated from it by whitespace.
Each time it isinvoked, getopts placesthe next option in the shell variable name,
initializing name if it doesnot exist, and the index of the next argument to be
processed into the variable OPTIND. OPTIND isinitialized to 1 each time the shell or a
shell script isinvoked. When an option requiresan argument, getopts placesthat
argument into the variable OPTARG. The shell doesnot reset OPTIND automatically; it
must be manually reset between multiple callsto getopts within the same shell
invocation if a new set of parametersisto be used.
getopts can report errorsin two ways. If the first character of opt st r i ng isa colon,
silent error reporting isused. In normal operation, diagnostic messagesare printed
when illegal optionsor missing option argumentsare encountered. If the variable
OPTERR isset to 0, no error message will be displayed, even if the first character of
opt st r i ng isnot a colon.
If an illegal option isseen, getopts placesa question mark (?) into name and, if not
silent, printsan error message and unsetsOPTARG. If getopts issilent, the option
character found isplaced in OP-TARG and no diagnostic message isprinted.
If a required argument isnot found, and getopts isnot silent, a question mark (?) is
placed in name, OPTARG isunset, and a diagnostic message isprinted. If getopts is
silent, then a colon (:) isplaced in name and OPTARG isset to the option character
found.
getopts normally parsesthe positional parameters, but if more argumentsare given
in args, getopts parsesthose instead. getopts returnsTrue if an option, specified or
unspecified, isfound. It returnsFalse if the end of optionsisencountered or an error
occurs.
hash [r][name] For each name, the full pathname of the command isdetermined and remembered.
The -r option causesthe shell to forget all remembered locations. If no arguments
are given, information about remembered commandsisprinted. An argument of
disablesoption checking for the rest of the arguments. The return statusisTrue
unlessa name isnot found or an illegal option issupplied.
help [pat t er n] Display helpful information about built-in commands. If pat t er n isspecified, help
givesdetailed help on all commandsmatching pattern; otherwise, a list of the
builtinsisprinted. The return statusis 0 unlessno command matchespattern.
39
history [n] With no options, display the command history list with line numbers. Lineslisted
history rwan [f i l ename] with a * have been modified. An argument of n listsonly the last n lines. If a
nonoption argument issupplied, it isused asthe name of the history file; if not, the
value of HISTFILE isused. Options, if supplied, have the following meanings:
a Append the new history lines(history linesentered since the
beginning of the current bash session) to the history file.
n Read the history linesnot already read from the history file
into the current history list. These are linesappended to the
history file since the beginning of the current bash session.
-r Read the contentsof the history file and use them asthe
current history.
w Write the current history to the history file, overwriting the
history filescontents.
The return value is0 unlessan illegal option isencountered or an error occurswhile
reading or writing the history file.
jobs [lnp][j obspec ... ] The first form liststhe active jobs. The l option listsprocessIDsin addition to
jobs x command [ ar gs ... ] the normal information; the p option listsonly the processID of the jobsprocess
group leader. The n option displaysonly jobsthat have changed statussince last
notified. If j obspec isgiven, output isrestricted to information about that job. The
return statusis0 unlessan illegal option isencountered or an illegal j obspec is
supplied.
If the x option issupplied, jobs replacesany j obspec found in command or ar gs with
the corresponding processgroup ID, and executescommand, passing it ar gs , returning
itsexit status.
kill [-s sigspec | si gspec] Send the signal named by sigspec to the processesnamed by pi d or j obspec. si gspec
[pi d | j obspec ] ... iseither a signal name such asSIGKILL or a signal number. If si gspec isa signal
kill l [si gnum] name, the name isnot case sensitive and may be given with or without the SIG
prefix. If sigspec isnot present, then SIGTERM isassumed. An argument of l liststhe
signal names. If any argumentsare supplied when l isgiven, the namesof the
specified signalsare listed, and the return statusis0. An argument of disables
option checking for the rest of the arguments. kill returnsTrue if at least one signal
wassuccessfully sent, or False if an error occursor an illegal option isencountered.
let ar g [ar g ...] Each ar g isan arithmetic expression to be evaluated. (See Arithmetic Evaluation.)
If the last ar g evaluatesto 0, let returns1; 0 isreturned otherwise.
local [name[ =val ue] ...] For each argument, create a local variable named name, and assign it val ue. When
local isused within a function, it causesthe variable name to have a visible scope
restricted to that function and itschildren. With no operands, local writesa list of
local variablesto the standard output. It isan error to use local when not within a
function. The return statusis0 unlesslocal isused outside a function, or an illegal
name issupplied.
logout Exit a login shell.
popd [+/n] Removesentriesfrom the directory stack. With no arguments, removesthe top
directory from the stack, and performsa cd to the new top directory.
+n Removesthe nth entry counting from the left of the list shown
by dirs, starting with zero. For example, popd +0 removesthe
first directory, popd +1 the second.
n Removesthe nth entry counting from the right of the list
shown by dirs, starting with zero. For example, popd -0
removesthe last directory, popd -1 the next to last.
bash
Part I: User Commands
40
If the popd command issuccessful, a dirs isperformed aswell, and the return status
is0. popd returnsFalse if an illegal option isencountered, the directory stack is
empty, a nonexistent directory stack entry isspecified, or the directory change fails.
pushd [di r ] pushd +/n Addsa directory to the top of the directory stack, or rotatesthe stack, making the
new top of the stack the current working directory. With no arguments, exchanges
the top two directoriesand returns0, unlessthe directory stack isempty.
+n Rotatesthe stack so that the nth directory (counting from the
left of the list shown by dirs) isat the top.
n Rotatesthe stack so that the nth directory (counting from the
right) isat the top.
di r Addsdi r to the directory stack at the top, making it the new
current working directory.
If the pushd command issuccessful, a dirs isperformed aswell. If the first form is
used, pushd returns0 unlessthe cd to di r fails. With the second form, pushd returns0
unlessthe directory stack isempty, a nonexistent directory stack element isspecified,
or the directory change to the specified new current directory fails.
pwd Print the absolute pathname of the current working directory. The path printed
containsno symbolic linksif the P option to the set builtin command isset. (See
also the description of nolinks under Shell Variables, earlier in thismanual page.)
The return statusis0 unlessan error occurswhile reading the pathname of the
current directory.
read [r][name ...] One line isread from the standard input, and the first word isassigned to the first
name, the second word to the second name, and so on, with leftover wordsassigned
to the last name. Only the charactersin IFS are recognized asword delimiters. If no
namesare supplied, the line read isassigned to the variable REPLY. The return code is
zero, unlessend-of-file isencountered. If the -r option isgiven, a backslash-newline
pair isnot ignored, and the backslash isconsidered to be part of the line.
readonly [f][name ...] The given namesare marked readonly and the valuesof these namesmay not be
readonly -p changed by subsequent assignment. If the f option issupplied, the functions
corresponding to the namesare so marked. If no argumentsare given, or if the
p option issupplied, a list of all readonly namesisprinted. An argument of
disablesoption checking for the rest of the arguments. The return statusis0 unless
an illegal option isencountered, one of the namesisnot a legal shell variable name,
or f issupplied with a name that isnot a function.
return [n] Causesa function to exit with the return value specified by n. If n isomitted, the
return statusisthat of the last command executed in the function body. If used
outside a function, but during execution of a script by the . (source) command, it
causesthe shell to stop executing that script and return either n or the exit statusof
the last command executed within the script asthe exit statusof the script. If used
outside a function and not during execution of a script by (. , the return statusis
False.
set [abefhkmnptuvxldCHP]
[-o option][arg ...]
a Automatically mark variablesthat are modified or created for
export to the environment of subsequent commands.
b Cause the statusof terminated background jobsto be reported
immediately, rather than before the next primary prompt.
(Also see notify under Shell Variables.)
e Exit immediately if a simple command (see Shell Grammar,
earlier in thismanual page) exitswith a nonzero status. The
shell doesnot exit if the command that failsispart of an until
41
or while loop, part of an if statement, part of a && or || list, or
if the commandsreturn value isbeing inverted via !.
f Disable pathname expansion.
h Locate and remember function commandsasfunctionsare
defined. Function commandsare normally looked up when
the function isexecuted.
k All keyword argumentsare placed in the environment for a
command, not just those that precede the command name.
m Monitor mode. Job control isenabled. Thisflag ison by
default for interactive shellson systemsthat support it. (See
Job Control, earlier in thismanual page.) Background
processesrun in a separate processgroup and a line containing
their exit statusisprinted upon their completion.
n Read commandsbut do not execute them. Thismay be used
to check a shell script for syntax errors. Thisisignored for
interactive shells.
o opt i on- name The opt i on- name can be one of the following:
allexportSame asa.
braceexpandThe shell performsbrace expansion. (See Brace
Expansion, earlier in thismanual page.) Thisison by default.
emacsUse an emacs-style command line editing interface.
Thisisenabled by default when the shell isinteractive, unless
the shell isstarted with the nolineediting option.
errexitSame ase.
histexpandSame asH.
ignoreeofThe effect isasif the shell command
IGNOREEOF=10 had been executed. (See Shell Variables.)
interactivecommentsAllow a word beginning with # to
cause that word and all remaining characterson that line to be
ignored in an interactive shell. (See Comments, earlier in
thismanual page.)
monitorSame asm.
noclobberSame asC.
noexecSame asn.
noglobSame asf.
nohashSame asd.
notifySame asb.
nounsetSame asu.
physicalSame asP.
posixChange the behavior of bash where the default
operation differsfrom the POSIX 1003.2 standard to match
the standard.
privilegedSame asp.
verboseSame asv.
viUse a vi-style command line editing interface.
xtraceSame asx.
If no opt i on- name issupplied, the valuesof the current options
are printed.
bash
Part I: User Commands
42
p Turn on privileged mode. In thismode, the $ENV file isnot
processed, and shell functionsare not inherited from the
environment. Thisisenabled automatically on startup if the
effective user (group) ID isnot equal to the real user (group)
ID. Turning thisoption off causesthe effective user and group
IDsto be set to the real user and group IDs.
t Exit after reading and executing one command.
u Treat unset variablesasan error when performing parameter
expansion. If expansion isattempted on an unset variable, the
shell printsan error message, and, if not interactive, exitswith
a nonzero status.
v Print shell input linesasthey are read.
x After expanding each simple command, bash displaysthe
expanded value of PS4, followed by the command and its
expanded arguments.
l Save and restore the binding of name in a for name [in word]
command. (See Shell Grammar, earlier in thismanual page.)
d Disable the hashing of commandsthat are looked up for
execution. Normally, commandsare remembered in a hash
table, and once found, do not have to be looked up again.
C The effect isasif the shell command noclobber= had been
executed. (See Shell Variables.)
H Enable ! style history substitution. Thisflag ison by default
when the shell isinteractive.
P If set, do not follow symbolic linkswhen performing
commandssuch ascd that change the current directory. The
physical directory isused instead.
If no argumentsfollow thisflag, then the positional parameters
are unset. Otherwise, the positional parametersare set to the
args, even if some of them begin with a .
Signal the end of options, cause all remaining args to be
assigned to the positional parameters. The x and v options
are turned off. If there are no args, the positional parameters
remain unchanged.
The flagsare off by default unlessotherwise noted. Using +
rather than causesthese flagsto be turned off. The flagscan
also be specified asoptionsto an invocation of the shell. The
current set of flagsmay be found in $. After the option
argumentsare processed, the remaining n args are treated as
valuesfor the positional parametersand are assigned, in order,
to $1, $2, ... $n. If no optionsor args are supplied, all shell
variablesare printed. The return statusisalwaysTrue unlessan
illegal option isencountered.
shift [n] The positional parametersfrom n+1 ... are renamed to .... Parametersrepresented
by the numbers$# down to $#n+1 are unset. If n is0, no parametersare changed. If
n isnot given, it isassumed to be 1. n must be a non-negative number lessthan or
equal to $#. If n isgreater than $#, the positional parametersare not changed. The
return statusisgreater than 0 if n isgreater than or lessthan 0; otherwise 0.
suspend [f] Suspend the execution of thisshell until it receivesa SIG-CONT signal. The f option
saysnot to complain if thisisa login shell; just suspend anyway. The return statusis
43
0 unlessthe shell isa login shell and f isnot supplied, or if job control isnot
enabled.
test expr[expr ] Return a statusof 0 (True) or 1 (False) depending on the evaluation of the
conditional expression expr. Expressionsmay be unary or binary. Unary expressions
are often used to examine the statusof a file. There are string operatorsand numeric
comparison operatorsaswell. Each operator and operand must be a separate
argument. If file isof the form /dev/fd/n, then file descriptor n ischecked.
b f i l eTrue if f i l e existsand isblock special.
c f i l eTrue if f i l e existsand ischaracter special.
d f i l eTrue if f i l e existsand isa directory.
e f i l eTrue if f i l e exists.
f f i l eTrue if f i l e existsand isa regular file.
g f i l eTrue if f i l e existsand isset-group-id.
k f i l eTrue if f i l e hasitssticky bit set.
L f i l eTrue if f i l e existsand isa symbolic link.
p f i l eTrue if f i l e existsand isa named pipe.
r f i l eTrue if f i l e existsand isreadable.
s f i l eTrue if f i l e existsand hasa size greater than zero.
S f i l eTrue if f i l e existsand isa socket.
t f dTrue if f d isopened on a terminal.
u f i l eTrue if f i l e existsand itsset-user-id bit isset.
w f i l eTrue if f i l e existsand iswritable.
x f i l eTrue if f i l e existsand isexecutable.
O f i l eTrue if f i l e existsand isowned by the effective user ID.
G f i l eTrue if f i l e existsand isowned by the effective group ID.
f i l e1 nt f i l e2True if f i l e1 isnewer (according to modification date) than
f i l e2.
f i l e1 ot f i l e2True if f i l e1 isolder than f i l e2.
f i l e1 ef f i l eTrue if f i l e1 and f i l e2 have the same device and inode
numbers.
z st r i ngTrue if the length of st r i ng iszero.
- n st r i ngTrue if the length of st r i ng isnonzero.
st r i ng1 = st r i ng2True if the stringsare equal.
st r i ng1 != st r i ng2True if the stringsare not equal.
! expr True if expr isFalse.
expr 1 a expr 2True if both expr 1 AND expr 2 are True.
expr 1 o expr 2True if either expr 1 OR expr 2 isTrue.
ar g1 OP ar g2 OP isone of eq, ne, lt, le, gt, or ge. These arithmetic binary
operatorsreturn True if ar g1 isequal, not-equal, less-than, less-than-or-equal,
greater-than, or greater-than-or-equal than ar g2, respectively. Ar g1 and ar g2 may
be positive integers, negative integers, or the special expression l st r i ng, which
evaluatesto the length of st r i ng.
times Print the accumulated user and system timesfor the shell and for processesrun from
the shell. The return statusis0.
trap [l][ar g][si gspec ] The command ar g isto be read and executed when the shell receivessignal(s)
si gspec. If ar g isabsent or , all specified signalsare reset to their original values(the
bash
Part I: User Commands
44
valuesthey had upon entrance to the shell). If ar g isthe null string, thissignal is
ignored by the shell and by the commandsit invokes. si gspec iseither a signal name
defined in <signal.h>, or a signal number. If si gspec isEXIT (0), the command ar g
isexecuted on exit from the shell. With no arguments, trap printsthe list of
commandsassociated with each signal number. The l option causesthe shell to
print a list of signal namesand their corresponding numbers. An argument of
disablesoption checking for the rest of the arguments. Signalsignored upon entry to
the shell cannot be trapped or reset. Trapped signalsare reset to their original values
in a child processwhen it iscreated. The return statusisFalse if either the trap name
or number isinvalid; otherwise, trap returnsTrue.
type [all][type | path] With no options, indicate how each name would be interpreted if used asa
name [name ...] command name. If the type flag isused, type printsa phrase that isone of alias,
keyword, function, builtin, or file if name isan alias, shell reserved word, function,
builtin, or disk file, respectively. If the name isnot found, then nothing isprinted,
and an exit statusof False isreturned. If the path flag isused, type either returns
the name of the disk file that would be executed if name were specified asa command
name, or nothing if type would not return file. If a command ishashed, path
printsthe hashed value, not necessarily the file that appearsfirst in PATH. If the all
flag isused, type printsall of the placesthat contain an executable named name. This
includesaliasesand functions, if and only if the path flag isnot also used. The table
of hashed commandsisnot consulted when using all. type acceptsa, t, and p in
place of all, type, and path, respectively. An argument of disablesoption
checking for the rest of the arguments. type returnsTrue if any of the argumentsare
found, False if none are found.
ulimit [SHacdfmstpnuv [l i mi t ]] ulimit providescontrol over the resourcesavailable to the shell and to processes
started by it, on systemsthat allow such control. The value of limit can be a number
in the unit specified for the resource, or the value unlimited. The H and S options
specify that the hard or soft limit isset for the given resource. A hard limit cannot be
increased once it isset; a soft limit may be increased up to the value of the hard
limit. If neither H nor S isspecified, the command appliesto the soft limit. If limit is
omitted, the current value of the soft limit of the resource isprinted, unlessthe H
option isgiven. When more than one resource isspecified, the limit name and unit
isprinted before the value. Other optionsare interpreted asfollows:
a All current limitsare reported.
c The maximum size of core filescreated.
d The maximum size of a processsdata segment.
f The maximum size of filescreated by the shell.
m The maximum resident set size.
s The maximum stack size.
t The maximum amount of cpu time in seconds.
p The pipe size in 512-byte blocks. (Thismay not be set.)
n The maximum number of open file descriptors. (Most systems
do not allow thisvalue to be set, only displayed.)
u The maximum number of processesavailable to a single user.
v The maximum amount of virtual memory available to the
shell.
An argument of disablesoption checking for the rest of the arguments. If limit is
given, it isthe new value of the specified resource (the a option isdisplay only). If
no option isgiven, then f isassumed. Valuesare in 1024-byte increments, except
for t, which isin seconds; p, which isin unitsof 512-byte blocks; and n and u,
45
which are unscaled values. The return statusis0 unlessan illegal option isencoun-
tered, a non-numeric argument other than unlimited issupplied aslimit, or an error
occurswhile setting a new limit.
umask [S][mode] The user file-creation mask isset to mode. If mode beginswith a digit, it isinterpreted
asan octal number; otherwise, it isinterpreted asa symbolic mode mask similar to
that accepted by chmod(1). If mode isomitted, or if the S option issupplied, the
current value of the mask isprinted. The S option causesthe mask to be printed in
symbolic form; the default output isan octal number. An argument of disables
option checking for the rest of the arguments. The return statusis0 if the mode was
successfully changed or if no mode argument wassupplied, and False otherwise.
unalias [a][name ...] Remove namesfrom the list of defined aliases. If a issupplied, all aliasdefinitions
are removed. The return value isTrue unlessa supplied name isnot a defined alias.
unset [fv][name ...] For each name, remove the corresponding variable or, given the f option, function.
An argument of disablesoption checking for the rest of the arguments. Note that
PATH, IFS, PPID, PS1, PS2, UID, and EUID cannot be unset. If any of RANDOM, SECONDS,
LINENO, or HISTCMD are unset, they lose their special properties, even if they are
subsequently reset. The exit statusisTrue unlessa name doesnot exist or isnon-
unsettable.
wait [n] Wait for the specified processand return itstermination status. n may be a process
ID or a job specification; if a job spec isgiven, all processesin that jobspipeline are
waited for. If n isnot given, all currently active child processesare waited for, and the
return statusiszero. If n specifiesa nonexistent processor job, the return statusis
127. Otherwise, the return statusisthe exit statusof the last processor job waited
for.
INVOCATION
A login shell isone whose first character of argument zero isa , or one started with the login flag.
An interactiveshell isone whose standard input and output are both connected to terminals(asdetermined by isatty(3)), or
one started with the i option. PS1 isset and includesi if bash isinteractive, allowing a shell script or a startup file to test this
state.
Login shells:
On login (subject to the noprofile option):
if /etc/profile exists, source it.
if /.bash_profile exists, source it,
else if /.bash_login exists, source it,
else if /.profile exists, source it.
On exit:
if /.bash_logout exists, source it.
Non-login interactive shells:
On startup (subject to the norc and rcfile options):
if /.bashrc exists, source it.
Non-interactive shells:
On startup:
if the environment variable ENV is non-null, expand
it and source the file it names, as if the command
if [ $ENV ]; then . $ENV; fi
had been executed, but do not use PATH to search
for the pathname. When not started in Posix mode, bash
looks for BASH_ENV before ENV.
If Bash isinvoked assh, it triesto mimic the behavior of sh asclosely aspossible. For a login shell, it attemptsto source only /
etc/profile and /.profile, in that order. The noprofile option may still be used to disable thisbehavior. A shell invoked
assh doesnot attempt to source any other startup files.
bash
Part I: User Commands
46
When bash isstarted in posix mode, aswith the posix command line option, it followsthe POSIX standard for startup files.
In thismode, the ENV variable isexpanded and that file sourced; no other startup filesare read.
SEE ALSO
Bash Features, Brian Fox and Chet Ramey
TheGnu ReadlineLibrary, Brian Fox and Chet Ramey
TheGnu HistoryLibrary, Brian Fox and Chet Ramey
A SystemV CompatibleImplementation of 4.2BSD Job Control, David Lennert
PortableOperatingSystemInterface(POSIX) Part 2: Shell and Utilities, IEEE
sh(1), ksh(1), csh(1), emacs(1), vi(1) readline(3)
FILES
/bin/bash The bash executable
/etc/profile The systemwide initialization file, executed for login shells
/.bash_profile The personal initialization file, executed for login shells
/.bashrc The individual per-interactive-shell startup file
/.inputrc Individual readline initialization file
AUTHORS
Brian Fox (Free Software Foundation; primary author; bfox@ai.MIT.Edu), Chet Ramey (Case Western Reserve University;
chet@ins.CWRU.Edu)
COPYRIGHT
Copyright 1989, 1991 by the Free Software Foundation, Inc.
BUG REPORTS
If you find a bug in bash, you should report it. But first, you should make sure that it really isa bug, and that it appearsin
the latest version of bash that you have.
Once you have determined that a bug actually exists, mail a bug report to bashmaintainers@prep.ai.MIT.Edu. If you have a
fix, you are welcome to mail that aswell! Suggestionsand philosophical bug reportsmay be mailed to bug-
bash@prep.ai.MIT.Edu or posted to the Usenet newsgroup gnu.bash.bug.
ALL bug reportsshould include the following:
The version number of bash
The hardware and operating system
The compiler used to compile
A description of the bug behavior
A short script or recipe that exercisesthe bug
Commentsand bug reportsconcerning thismanual page should be directed to chet@ins.cwru.edu.
BUGS
Itstoo big and too slow.
There are some subtle differencesbetween bash and traditional versionsof sh, mostly because of the POSIX specification.
Aliasesare confusing in some uses.
GNU, 9 March 1995
47
bdftopcf
bdftopcfConvert X font from Bitmap Distribution Format to Portable Compiled Format
SYNOPSIS
bdftopcf [ pn ][un ][m ][l ][M ][L ][t ][i ][o out put f i l e ] fontfile.bdf
DESCRIPTION
bdftopcf isa font compiler for the X server and font server. Fontsin Portable Compiled Format can be read by any
architecture, although the file isstructured to allow one particular architecture to read them directly without reformatting.
Thisallowsfast reading on the appropriate machine, but the filesare still portable (but read more slowly) on other machines.
OPTIONS
pn Setsthe font glyph padding. Each glyph in the font will have each scanline padded in to a multiple
of n bytes, where n is1, 2, 4, or 8.
un Setsthe font scanline unit. When the font bit order isdifferent from the font byte order, the
scanline unit n describeswhat unit of data (in bytes) are to be swapped; the unit i can be 1, 2, or 4
bytes.
m Setsthe font bit order to MSB (most significant bit) first. Bitsfor each glyph will be placed in this
order; that is, the leftmost bit on the screen will be in the highest valued bit in each unit.
l Setsthe font bit order to LSB (least significant bit) first. The leftmost bit on the screen will be in the
lowest valued bit in each unit.
M Setsthe font byte order to MSB first. All multibyte data in the file (metrics, bitmaps, and everything
else) will be written most significant byte first.
L Setsthe font byte order to LSB first. All multibyte data in the file (metrics, bitmaps, and everything
else) will be written least significant byte first.
t When thisoption isspecified, bdftopcf will convert fontsinto terminal fontswhen possible. A
terminal font haseach glyph image padded to the same size; the X server can usually render these
typesof fontsmore quickly.
i Thisoption inhibitsthe normal computation of ink metrics. When a font hasglyph imagesthat do
not fill the bitmap image (that is, the on pixelsdont extend to the edgesof the metrics), bdftopcf
computesthe actual ink metricsand placesthem in the PCF file; the t option inhibitsthisbehavior.
o out put - f i l e- name By default bdftopcf writesthe PCF file to standard output; thisoption givesthe name of a file to be
used instead.
SEE ALSO
X(1)
AUTHOR
Keith Packard, MIT X Consortium
X Version 11 Release6
beforelight
beforelightScreen saver
SYNOPSIS
beforelight [ t ool ki t opt i on ... ]
beforelight
Part I: User Commands
48
DESCRIPTION
The beforelight program isa sample implementation of a screen saver for X serverssupporting the MIT-SCREEN-SAVER
extension.
AUTHORS
Keith Packard (MIT X Consortium)
X Version 11 Release6
biff
biffBe notified if mail arrivesand who it isfrom
SYNOPSIS
biff [ny]
DESCRIPTION
biff informsthe system whether you want to be notified when mail arrivesduring the current terminal session.
Optionssupported by biff:
n Disablesnotification
y Enablesnotification
When mail notification isenabled, the header and first few linesof the message will be printed on your screen whenever mail
arrives. A
biff y
command isoften included in the file .login or .profile to be executed at each login.
Biff operatesasynchronously. For synchronousnotification use the MAIL variable of sh(1) or the mail variable of csh(1).
SEE ALSO
csh(1), mail(1), sh(1), comsat(8)
HISTORY
The biff command appeared in BSD 4.0.
BSD 4, 14 March 1991
bioradtopgm
bioradtopgmConvert a Biorad confocal file into a portable graymap
SYNOPSIS
bioradtopgm [-image#][i magedat a]
DESCRIPTION
Readsa Biorad confocal file asinput. Producesa portable graymap asoutput. If the resulting image isupside down, run it
through pnmflip -tb.
49
OPTIONS
-image# A Biorad image file may contain more than one image. With thisflag, you can specify which image to
extract (only one at a time). The first image in the file hasnumber zero. If no image number issupplied,
only information about the image size and the number of imagesin the input isprinted out. No output is
produced.
BUGS
A Biorad image may be in word format. If PbmPlus isnot compiled with the BIGGRAYS flag, word filescannot be converted. See
the makefile.
SEE ALSO
pgm(5), pnmflip(1)
AUTHORS
Copyright 1993 by Oliver Trepte
28 June1993
bitmap, bmtoa, atobm
bitmap, bmtoa, atobmBitmap editor and converter utilitiesfor the X Window System
SYNOPSIS
bitmap [ opt i ons ...][f i l ename ][basename ]
bmtoa [ chars ...][f i l ename ]
atobm [ chars cc ][name var i abl e ][xhot number ][yhot number ][f i l ename ]
DESCRIPTION
The bitmap program isa rudimentary tool for creating or editing rectangular imagesmade up of 1sand 0s. Bitmapsare used
in X for defining clipping regions, cursor shapes, icon shapes, and tile and stipple patterns.
The bmtoa and atobm filtersconvert bitmap files(FILE FORMAT) to and from ASCII strings. They are most commonly used to
quickly print out bitmapsand to generate versionsfor including in text.
COMMAND-LINE OPTIONS
Bitmap supportsthe standard X Toolkit command-line arguments; see X(1). The following additional argumentsare
supported aswell:
size WI DTHxHEI GHT Specifiessize of the grid in squares.
sw di mensi on Specifiesthe width of squaresin pixels.
sh di mensi on Specifiesthe height of squaresin pixels.
gt di mensi on Grid tolerance. If the square dimensionsfall below the specified value, grid will be
automatically turned off.
grid, +grid Turnson or off the grid lines.
axes, +axes Turnson or off the major axes.
dashed, +dashed Turnson or off dashing for the frame and grid lines.
stippled, +stippled Turnson or off stippling of highlighted squares.
bitmap, bmtoa, atobm
Part I: User Commands
50
proportional, +proportional Turnsproportional mode on or off. If proportional mode ison, square width is
equal to square height. If proportional mode isoff, bitmap will use the smaller square
dimension, if they were initially different.
dashes f i l ename Specifiesthe bitmap to be used asa stipple for dashing.
stipple f i l ename Specifiesthe bitmap to be used asa stipple for highlighting.
hl col or Specifiesthe color used for highlighting.
fr col or Specifiesthe color used for the frame and grid lines.
filename Specifiesthe bitmap to be initially loaded into the program. If the file doesnot exist,
bitmap will assume it isa new file.
basename Specifiesthe basename to be used in the C code output file. If it isdifferent than the
basename in the working file, bitmap will change it when saving the file.
bmtoa acceptsthe following option:
chars cc Thisoption specifiesthe pair of charactersto use in the string version of the bitmap.
The first character isused for 0 bitsand the second character isused for 1 bits. The
default isto use dashes(-) for 0sand number signs(#) for 1s.
atobm acceptsthe following options:
chars cc Thisoption specifiesthe pair of charactersto use when converting string bitmaps
into arraysof numbers. The first character representsa 0 bit and the second
character representsa 1 bit. The default isto use dashes() for 0sand number signs
(#) for 1s.
name var i abl e Thisoption specifiesthe variable name to be used when writing out the bitmap file.
The default isto use the basename of the filename command-line argument or leave
it blank if the standard input isread.
xhot number Thisoption specifiesthe X coordinate of the hot spot. Only positive valuesare
allowed. By default, no hot spot information isincluded.
yhot number Thisoption specifiesthe Y coordinate of the hot spot. Only positive valuesare
allowed. By default, no hot spot information isincluded.
USAGE
bitmap displaysgrid in which each square representsa single bit in the picture being edited. Actual size of the bitmap image,
asit would appear normally and inverted, can be obtained by pressing Meta-I. You are free to move the image pop-up out of
the way to continue editing. Pressing the left mouse button in the pop-up window or Meta-I again will remove the real size
bitmap image.
If the bitmap isto be used for defining a cursor, one of the squaresin the imagesmay be designated asthe hot spot. This
determineswhere the cursor isactually pointing. For cursorswith sharp tips(such asarrowsor fingers), thisisusually at the
end of the tip; for symmetric cursors(such ascrossesor bulls-eyes), thisisusually at the center.
Bitmapsare stored assmall C code fragmentssuitable for including in applications. They provide an array of bitsaswell as
symbolic constantsgiving the width, height, and hot spot (if specified) that may be used in creating cursors, icons, and tiles.
EDITING
To edit a bitmap image, simply click on one of the buttonswith drawing commands(Point, Curve, Line, Rectangle, and so
on) and move the pointer into the bitmap grid window. Pressone of the buttonson your mouse and the appropriate action
will take place. You can either set, clear, or invert the grid squares. Setting a grid square correspondsto setting a bit in the
bitmap image to 1. Clearing a grid square correspondsto setting a bit in the bitmap image to 0. Inverting a grid square
correspondsto changing a bit in the bitmap image from 0 to 1 or 1 to 0, depending what itspreviousstate was. The default
behavior of mouse buttonsisasfollows:
51
MouseButton1 Set
MouseButton2 Invert
MouseButton3 Clear
MouseButton4 Clear
MouseButton5 Clear
Thisdefault behavior can be changed by setting the button function resources. Here isan example:
bitmap*button1Function: Set
bitmap*button2Function: Clear
bitmap*button3Function: Invert
etc.
The button function appliesto all drawing commands, including copying, moving and pasting, flood filling, and setting the
hot spot.
DRAWING COMMANDS
Here isthe list of drawing commandsaccessible through the buttonsat the left side of the applicationswindow. Some
commandscan be aborted by pressing A inside the bitmap window, allowing the user to select different guiding pointswhere
applicable.
Clear Thiscommand clearsall bitsin the bitmap image. The grid squareswill be set to the
background color. Pressing C inside the bitmap window hasthe same effect.
Set Thiscommand setsall bitsin the bitmap image. The grid squareswill be set to the
foreground color. Pressing Sinside the bitmap window hasthe same effect.
Invert Thiscommand invertsall bitsin the bitmap image. The grid squareswill be inverted
appropriately. Pressing I inside the bitmap window hasthe same effect.
Mark Thiscommand isused to mark an area of the grid by dragging out a rectangular
shape in the highlighting color. After the area ismarked, it can be operated on by a
number of commands(see Up, Down, Left, Right, Rotate, Flip, Cut, and so on).
Only one marked area can be present at any time. If you attempt to mark another
area, the old mark will vanish. The same effect can be achieved by pressing Shift-
MouseButton1 and dragging out a rectangle in the grid window. Pressing Shift-
MouseButton2 will mark the entire grid area.
Unmark Thiscommand will cause the marked area to vanish. The same effect can be
achieved by pressing Shift-MouseButton3.
Copy Thiscommand isused to copy an area of the grid from one location to another. If
there isno marked grid area displayed, Copy behavesjust like Mark. Once there isa
marked grid area displayed in the highlighting color, thiscommand hastwo
alternative behaviors. If you click a mouse button inside the marked area, you will be
able to drag the rectangle that representsthe marked area to the desired location.
After you release the mouse button, the area will be copied. If you click outside the
marked area, Copy will assume that you wish to mark a different region of the
bitmap image, thusit will behave like Mark again.
Move Thiscommand isused to move an area of the grid from one location to another. Its
behavior resemblesthe behavior of Copy command, except that the marked area will
be moved instead of copied.
Flip Horizontally Thiscommand will flip the bitmap image with respect to the horizontal axes. If a
marked area of the grid ishighlighted, it will operate only inside the marked area.
Pressing H inside the bitmap window hasthe same effect.
Up Thiscommand movesthe bitmap image one pixel up. If a marked area of the grid is
highlighted, it will operate only inside the marked area. Pressing UpArrow inside the
bitmap window hasthe same effect.
bitmap, bmtoa, atobm
Part I: User Commands
52
Flip Vertically Thiscommand will flip the bitmap image with respect to the vertical axes. If a
marked area of the grid ishighlighted, it will operate only inside the marked area.
Pressing V inside the bitmap window hasthe same effect.
Left Thiscommand movesthe bitmap image one pixel to the left. If a marked area of the
grid ishighlighted, it will operate only inside the marked area. Pressing LeftArrow
inside the bitmap window hasthe same effect.
Fold Thiscommand will fold the bitmap image so that the opposite cornersbecome
adjacent. Thisisuseful when creating bitmap imagesfor tiling. Pressing F inside the
bitmap window hasthe same effect.
Right Thiscommand movesthe bitmap image one pixel to the right. If a marked area of
the grid ishighlighted, it will operate only inside the marked area. Pressing the right
arrow inside the bitmap window hasthe same effect.
Rotate Left Thiscommand rotatesthe bitmap image 90 degreesto the left (counter clockwise.)
If a marked area of the grid ishighlighted, it will operate only inside the marked
area. Pressing L inside the bitmap window hasthe same effect.
Down Thiscommand movesthe bitmap image one pixel down. If a marked area of the grid
ishighlighted, it will operate only inside the marked area. Pressing the down arrow
inside the bitmap window hasthe same effect.
Rotate Right Thiscommand rotatesthe bitmap image 90 degreesto the right (clockwise.) If a
marked area of the grid ishighlighted, it will operate only inside the marked area.
Pressing R inside the bitmap window hasthe same effect.
Point Thiscommand will change the grid squaresunderneath the mouse pointer if a
mouse button isbeing pressed down. If you drag the mouse button continuously,
the line may not be continuous, depending on the speed of your system and
frequency of mouse motion events.
Curve Thiscommand will change the grid squaresunderneath the mouse pointer if a
mouse button isbeing pressed down. If you drag the mouse button continuously, it
will make sure that the line iscontinuous. If your system isslow or bitmap receives
very few mouse motion events, it might behave quite strangely.
Line Thiscommand will change the grid squaresin a line between two squares. Once you
pressa mouse button in the grid window, bitmap will highlight the line from the
square where the mouse button wasinitially pressed to the square where the mouse
pointer islocated. By releasing the mouse button, you will cause the change to take
effect, and the highlighted line will disappear.
Rectangle Thiscommand will change the grid squaresin a rectangle between two squares.
Once you pressa mouse button in the grid window, bitmap will highlight the
rectangle from the square where the mouse button wasinitially pressed to the square
where the mouse pointer islocated. By releasing the mouse button you will cause the
change to take effect, and the highlighted rectangle will disappear.
Filled Rectangle Thiscommand isidentical to Rectangle, except at the end the rectangle will be filled
rather than outlined.
Circle Thiscommand will change the grid squaresin a circle between two squares. Once
you pressa mouse button in the grid window, bitmap will highlight the circle from
the square where the mouse button wasinitially pressed to the square where the
mouse pointer islocated. By releasing the mouse button you will cause the change to
take effect, and the highlighted circle will disappear.
Filled Circle Thiscommand isidentical to Circle, except at the end the circle will be filled rather
than outlined.
Flood Fill Thiscommand will flood fill the connected area underneath the mouse pointer
when you click on the desired square. Diagonally adjacent squaresare not considered
to be connected.
53
Set Hot Spot Thiscommand designatesone square in the grid asthe hot spot if thisbitmap image
isto be used for defining a cursor. Pressing a mouse button in the desired square will
cause a diamond shape to be displayed.
Clear Hot Spot Thiscommand removesany designated hot spot from the bitmap image.
Undo Thiscommand will undo the last executed command. It hasdepth one, that is,
pressing Undo after Undo will undo itself.
FILE MENU
The File menu commandscan be accessed by pressing the File button and selecting the appropriate menu entry, or by
pressing the Ctrl key with another key. These commandsdeal with filesand global bitmap parameters, such assize,
basename, filename, and so forth.
New Thiscommand will clear the editing area and prompt for the name of the new file to
be edited. It will not load in the new file.
Load Thiscommand isused to load a new bitmap file into the bitmap editor. If the
current image hasnot been saved, user will be asked whether to save or ignore the
changes. The editor can edit only one file at a time. If you need interactive editing,
run a number of editorsand use the cut and paste mechanism asdescribed later in
thissection. (See Cut and Paste.)
Insert Thiscommand isused to insert a bitmap file into the image being currently edited.
After being prompted for the filename, click inside the grid window and drag the
outlined rectangle to the location where you want to insert the new file.
Save Thiscommand will save the bitmap image. It will not prompt for the filename
unlessit issaid to be <none>. If you leave the filename undesignated or , the output
will be piped to stdout.
Save As Thiscommand will save the bitmap image after prompting for a new filename. It
should be used if you want to change the filename.
Resize Thiscommand isused to resize the editing area to the new number of pixels. The
size should be entered in the widthheight format. The information in the image
being edited will not be lost unlessthe new size issmaller that the current image size.
The editor wasnot designed to edit huge files.
Rescale Thiscommand isused to rescale the editing area to the new width and height. The
size should be entered in the widthheight format. It will not do antialiasing and
information will be lost if you rescale to the smaller sizes. Feel free to add you own
algorithmsfor better rescaling.
Filename Thiscommand isused to change the filename without changing the basename nor
saving the file. If you specify for a filename, the output will be piped to stdout.
Basename Thiscommand isused to change the basename, if a different one from the specified
filename isdesired.
Quit Thiscommand will terminate the bitmap application. If the file wasnot saved, user
will be prompted and asked whether to save the image or not. Quit ispreferred over
killing the process.
EDIT MENU
The Edit menu commandscan be accessed by pressing the Edit button and selecting the appropriate menu entry, or by
pressing Meta key with another key. These commandsdeal with editing facilitiessuch asgrid, axes, zooming, cut and paste,
and so on.
Image Thiscommand will display the image being edited and itsinverse in itsactual size in
a separate window. The window can be moved away to continue with editing.
Pressing the left mouse button in the image window will cause it to disappear from
the screen.
bitmap, bmtoa, atobm
Part I: User Commands
54
Grid Thiscommand controlsthe grid in the editing area. If the grid spacing isbelow the
value specified by gridTolerance resource (8 by default), the grid will be automati-
cally turned off. It can be enforced by explicitly activating thiscommand.
Dashed Thiscommand controlsthe stipple for drawing the grid lines. The stipple specified
by dashesresource can be turned on or off by activating thiscommand.
Axes Thiscommand controlsthe highlighting of the main axesof the image being edited.
The actual linesare not part of the image. They are provided to aid user when
constructing symmetrical images, or whenever having the main axeshighlighted
helpsyour editing.
Stippled Thiscommand controlsthe stippling of the highlighted areasof the bitmap image.
The stipple specified by stipple resource can be turned on or off by activating this
command.
Proportional Thiscommand controlsthe proportional mode. If the proportional mode ison,
width and height of all image squaresare forced to be equal, regardlessof the
proportionsof the bitmap window.
Zoom Thiscommand controlsthe zoom mode. If there isa marked area of the image
already displayed, bitmap will automatically zoom into it. Otherwise, the user will
have to highlight an area to be edited in the zoom mode and bitmap will automati-
cally switch into it. You can use all the editing commandsand other utilitiesin the
zoom mode. When you zoom out, undo command will undo the whole zoom
session.
Cut Thiscommandscutsthe contentsof the highlighted image area into the internal cut
and paste buffer.
Copy Thiscommand copiesthe contentsof the highlighted image area into the internal
cut and paste buffer.
Paste Thiscommand will check if there are any other bitmap applicationswith a
highlighted image area, or if there issomething in the internal cut and paste buffer
and copy it to the image. To place the copied image, click in the editing window and
drag the outlined image to the position where you want to place i, and then release
the button.
CUT AND PASTE
Bitmap supportstwo cut and paste mechanisms; the internal cut and paste and the global X selection cut and paste. The
internal cut and paste isused when executing copy and move drawing commandsand also cut and copy commandsfrom the
Edit menu. The global X selection cut and paste isused whenever there isa highlighted area of a bitmap image displayed
anywhere on the screen. To copy a part of image from another bitmap editor, simply highlight the desired area by using the
Mark command or pressing the shift key and dragging the area with the left mouse button. When the selected area becomes
highlighted, any other applications(such asxterm) that use primary selection will discard their selection valuesand
unhighlight the appropriate information. Now, use the Paste command from the Edit menu or control mouse button to
copy the selected part of image into another (or the same) bitmap application. If you attempt to do thiswithout a visible
highlighted image area, the bitmap will fall back to the internal cut and paste buffer and paste whatever wasstored there at
the moment.
WIDGETS
Following isthe widget structure of the bitmap application. The widget classname isgiven first, followed by the widget
instance name. All widgetsexcept the bitmap widget are from the standard Athena widget set.
Bitmap bitmap
TransientShell image
Box box
Label normalImage
Label invertedImage
TransientShell input
55
Dialog dialog
Command okay
Command cancel
TransientShell error
Dialog dialog
Command abort
Command retry
TransientShell qsave
Dialog dialog
Command yes
Command no
Command cancel
Paned parent
Form formy
MenuButton fileButton
SimpleMenu fileMenu
SmeBSB new
SmeBSB load
SmeBSB insert
SmeBSB save
SmeBSB saveAs
SmeBSB resize
SmeBSB rescale
SmeBSB filename
SmeBSB basename
SmeLine line
SmeBSB quit
MenuButton editButton
SimpleMenu editMenu
SmeBSB image
SmeBSB grid
SmeBSB dashed
SmeBSB axes
SmeBSB stippled
SmeBSB proportional
SmeBSB zoom
SmeLine line
SmeBSB cut
SmeBSB copy
SmeBSB paste
Label status
Pane pane
Bitmap bitmap
Form form
Command clear
Command set
Command invert
Toggle mark
Command unmark
Toggle copy
Toggle move
Command flipHoriz
Command up
Command flipVert
Command left
Command fold
Command right
Command rotateLeft
Command down
Command rotateRight
bitmap, bmtoa, atobm
Part I: User Commands
56
Toggle point
Toggle curve
Toggle line
Toggle rectangle
Toggle filledRectangle
Toggle circle
Toggle filledCircle
Toggle floodFill
Toggle setHotSpot
Command clearHotSpot
Command undo
COLORS
If you would like bitmap to be viewable in color, include the following in the #ifdef COLOR section of the file you read with
xrdb:
*customization: color
Thiswill cause bitmap to pick up the colorsin the app-defaultscolor customization file:
<XRoot>/lib/X11/app-defaults/Bitmap-color
where <XRoot> refersto the root of the X11 install tree.
BITMAP WIDGET
Bitmap widget isa standalone widget for editing raster images. It isnot designed to edit large images, although it may be
used in that purpose aswell. It can be freely incorporated with other applicationsand used asa standard editing tool. The
following are the resourcesprovided by the bitmap widget:
Header file Bitmap.h
Class bitmapWidgetClass
ClassName Bitmap
Superclass Bitmap
All the Simple Widget resourcesplus
Name Class Type Default Value
foreground Foreground Pixel XtDefaultForeground
highlight Highlight Pixel XtDefaultForeground
framing Framing Pixel XtDefaultForeground
gridTolerance GridTolerance Dimension 8
size Size String 32x32
dashed Dashed Boolean True
grid Grid Boolean True
stippled Stippled Boolean True
proportional Proportional Boolean True
axes Axes Boolean False
squareWidth SquareWidth Dimension 16
squareHeight SquareHeight Dimension 16
margin Margin Dimension 16
xHot XHot Position NotSet (1)
yHot YHot Position NotSet (1)
button1Function Button1Function DrawingFunction Set
57
button2Function Button2Function DrawingFunction Invert
button3Function Button3Function DrawingFunction Clear
button4Function Button4Function DrawingFunction Invert
button5Function Button5Function DrawingFunction Invert
filename Filename String None ()
basename Basename String None ()
AUTHOR
Davor Matic (MIT X Consortium)
X Version 11 Release6
bmptoppm
bmptoppmConvert a BMP file into a portable pixmap
SYNOPSIS
bmptoppm [bmpfile]
DESCRIPTION
bmptoppm readsa Microsoft Windowsor OS/2 BMP file asinput and producesa portable pixmap asoutput.
SEE ALSO
ppmtobmp(1), ppm(5)
AUTHOR
Copyright 1992 by David W. Sanderson
26 October 1992
brushtopbm
brushtopbmConvert a doodle brush file into a portable bitmap
SYNOPSIS
brushtopbm [br ushf i l e]
DESCRIPTION
brushtopbm readsa Xerox doodle brush file asinput and producesa portable bitmap asoutput.
Note that there iscurrently no pbmtobrush tool.
SEE ALSO
pbm(5)
AUTHOR
Copyright 1988 by Jef Poskanzer
28 August 1988
Name Class Type Default Value
brushtopbm
Part I: User Commands
58
cal
calDisplaysa calendar
SYNOPSIS
cal [jy] [mont h [year ]]
DESCRIPTION
cal displaysa simple calendar. If argumentsare not specified, the current month isdisplayed. The optionsare asfollows:
j Display Julian dates(daysone-based, numbered from January 1)
y Display a calendar for the current year
A single parameter specifiesthe year (19999) to be displayed; note the year must be fully specified:
cal 89
will not display a calendar for 1989. Two parametersdenote the month (112) and year. If no parametersare specified, the
current monthscalendar isdisplayed.
A year startson Jan 1.
The Gregorian Reformation isassumed to have occurred in 1752 on the 3rd of September. By thistime, most countrieshad
recognized the reformation (although a few did not recognize it until the early 1900s.) Ten daysfollowing that date were
eliminated by the reformation, so the calendar for that month isa bit unusual.
HISTORY
A cal command appeared in version 6 AT&T UNIX
6 June1993
cat
catConcatenate filesand print on the standard output
SYNOPSIS
cat [benstuvAET] [number] [number-nonblank] [squeeze-blank]
[show-nonprinting] [show-ends] [show-tabs] [show-all]
[help] [version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of cat. cat writesthe contentsof each given file, or the standard input if
none are given or when a file named isgiven, to the standard output.
OPTIONS
b, number-nonblank Number all nonblank output lines, starting with 1.
e Equivalent to vE.
n, number Number all output lines, starting with 1.
s, squeeze-blank Replace multiple adjacent blank lineswith a single blank line.
t Equivalent to vT.
u Ignored; for UNIX compatibility.
59
v, show-nonprinting Display control charactersexcept for LFD and TAB using notation and precede charactersthat
have the high bit set with M-.
A, show-all Equivalent to vET.
E, show-ends Display a $ after the end of each line.
T, show-tabs Display tab charactersasI.
help Print a usage message and exit with a nonzero status.
version Print version information on standard output then exit.
GNU Text Utilities
chattr
chattrChange file attributeson a Linux second extended file system
SYNOPSIS
chattr [ RV ][-v version ] [ mode ] f i l es...
DESCRIPTION
chattr changesthe filesattributeson an second extended file system. The format of a symbolic mode is+-=[Sacdisu].
The operator + causesthe selected attributesto be added to the existing attributesof the files; - causesthem to be removed;
and = causesthem to be the only attributesthat the fileshave. The lettersSacdisu select the new attributesfor the files:
synchronousupdates(S), append only (a), compressed (), immutable(i), nodump (d), securedeletion (s), and undeletable
(u).
OPTIONS
-R Recursively change attributesof directoriesand their contents.
-V Verbosely describe changed attributes.
-v version Set the filesversion.
ATTRIBUTES
A file with the a attribute set can only be open in append mode for writing.
A file with the c attribute set isautomatically compressed on the disk by the kernel. A read from thisfile returns
uncompressed data. A write to thisfile compressesdata before storing them on the disk.
A file with the d attribute set isnot candidate for backup when the dump(8) program isrun.
A file with the i attribute cannot be modified: it cannot be deleted or renamed, no link can be created to thisfile and no data
can be written to the file. Only the superuser can set or clear thisattribute.
When a file with the s attribute set isdeleted, itsblocksare zeroed and written back to the disk.
When a file with the u attribute set ismodified, the changesare written synchronously on the disk; thisisequivalent to the
syn mount option applied to a subset of the files.
When a file with the u attribute set isdeleted, itscontentsissaved. Thisallowsthe user to ask for itsundeletion.
AUTHOR
chattr hasbeen written by Remy Card, <card@masi.ibp.fr>, the developer and maintainer of the ext2 fs.
BUGS AND LIMITATIONS
Asof ext2 fs 0.5a, the c and u attributesare not honored by the kernel code.
These attributeswill be implemented in a future ext2 fs version.
chattr
Part I: User Commands
60
AVAILABILITY
chattr isavailable for anonymousftp from ftp.ibp.fr and tsx-11.mit.edu in /pub/linux/packages/ext2fs.
SEE ALSO
lsattr(1)
Version 0.5b, November 1994
chfn
chfnChange your finger information
SYNOPSIS
chfn [ f f ul l - name ][o of f i ce][p of f i ce- phone ] [ h home- phone ] [ u ] [ v ]
[user name ]
DESCRIPTION
chfn isused to change your finger information. Thisinformation isstored in the /etc/passwd file, and isdisplayed by the
finger program. The Linux finger command will display four piecesof information that can be changed by chfn: your real
name, your work room and phone, and your home phone.
COMMAND LINE
Any of the four piecesof information can be specified on the command line. If no information isgiven on the command
line, chfn entersinteractive mode.
INTERACTIVE MODE
In interactive mode, chfn will prompt for each field. At a prompt, you can enter the new information, or just pressreturn to
leave the field unchanged. Enter the keyword none to make the field blank.
OPTIONS
f, full-name Specify your real name.
o, office Specify your office room number.
p, office-phone Specify your office phone number.
h, home-phone Specify your home phone number.
u, help Print a usage message and exit.
-v, version Print version information and exit.
SEE ALSO
finger(1), passwd(5)
AUTHOR
Salvatore Valente (<svalente@mit.edu>)
chfn, October 13 1994
61
chgrp
chgrpChange the group ownership of files
SYNOPSIS
chgrp [Rcfv] [recursive] [changes] [silent] [quiet] [verbose] [help]
[version] gr oup f i l e...
DESCRIPTION
Thismanual page documentsthe GNU version of chgrp. chgrp changesthe group ownership of each given file to the named
group, which can be either a group name or a numeric group ID.
OPTIONS
c, changes Verbosely describe only fileswhose ownership actually changes.
f, silent, quiet Do not print error messagesabout fileswhose ownership cannot be changed.
v, verbose Verbosely describe ownership changes.
R, recursive Recursively change ownership of directoriesand their contents.
help Print a usage message on standard output and exit successfully.
version Print version information on standard output, then exit successfully.
GNU FileUtilities
chkdupexe
chkdupexeFind duplicate executables
SYNOPSIS
chkdupexe
DESCRIPTION
chkdupexe will scan many standard directoriesthat hold executable, and report duplicates.
AUTHOR
Nicolai Langfeldt
BUGS
RequiresGNU ls(1).
Search pathsthat point to the same directory will cause many bogusduplicatesto be found. You might want to edit the
script to eliminate some pathsthat are equivalent on your machine.
11 March 1995
chmod
chmodChange the accesspermissionsof files
SYNOPSIS
chmod [Rcfv] [recursive] [changes] [silent] [quiet] [verbose] [help]
[version] mode f i l e...
chmod
Part I: User Commands
62
DESCRIPTION
Thismanual page documentsthe GNU version of chmod. chmod changesthe permissionsof each given file according to mode,
which can be either a symbolic representation of changesto make, or an octal number representing the bit pattern for the
new permissions.
The format of a symbolic mode is[ugoa...][[+-=][rwxXstugo...]...][,...]. Multiple symbolic operationscan be given,
separated by commas.
A combination of the lettersugoa controlswhich users accessto the file will be changed: the user who ownsit (u), other users
in the filesgroup (g), other usersnot in the filesgroup (o), or all users(a). If none of these are given, the effect isasif a were
given, but bitsthat are set in the umask are not affected.
The operator + causesthe permissionsselected to be added to the existing permissionsof each file; - causesthem to be
removed; and = causesthem to be the only permissionsthat the file has.
The lettersrwxXstugo select the new permissionsfor the affected users: read (r), write (w), execute (or accessfor directories)
(x), execute only if the file isa directory or already hasexecute permission for some user (X), set user or group ID on
execution (s), save program text on swap device (t), the permissionsthat the user who ownsthe file currently hasfor it (u),
the permissionsthat other usersin the filesgroup have for it (g), and the permissionsthat other usersnot in the filesgroup
have for it (o).
A numeric mode isfrom one to four octal digits(07), derived by adding up the bitswith values4, 2, and 1. Any omitted
digitsare assumed to be leading zeros. The first digit selectsthe set user ID (4) and set group ID (2) and save text image (1)
attributes. The second digit selectspermissionsfor the user who ownsthe file: read (4), write (2), and execute (1); the third
selectspermissionsfor other usersin the filesgroup, with the same values; and the fourth for other usersnot in the files
group, with the same values.
chmod never changesthe permissionsof symbolic links; the chmod system call cannot change their permissions. Thisisnot a
problem since the permissionsof symbolic linksare never used. However, for each symbolic link listed on the command line,
chmod changesthe permissionsof the pointed-to file. In contrast, chmod ignoressymbolic linksencountered during recursive
directory traversals.
OPTIONS
c, changes Verbosely describe only fileswhose permissionsactually change.
f, silent, quiet Do not print error messagesabout fileswhose permissionscannot be changed.
v, verbose Verbosely describe changed permissions.
R, recursive Recursively change permissionsof directoriesand their contents.
help Print a usage message on standard output and exit successfully.
version Print version information on standard output, then exit successfully.
GNU FileUtilities
chown
chownChange the user and group ownership of files
SYNOPSIS
chown [Rcfv] [recursive] [changes] [help] [version] [silent] [quiet]
[verbose] [user ][:.][gr oup] f i l e...
63
DESCRIPTION
Thismanual page documentsthe GNU version of chown. chown changesthe user and/or group ownership of each given file,
according to itsfirst nonoption argument, which isinterpreted asfollows. If only a username (or numeric user ID) isgiven,
that user ismade the owner of each given file, and the files group isnot changed. If the username isfollowed by a colon or
dot and a group name (or numeric group ID), with no spacesbetween them, the group ownership of the filesischanged as
well. If a colon or dot but no group name followsthe username, that user ismade the owner of the filesand the group of the
filesischanged to that userslogin group. If the colon or dot and group are given, but the username isomitted, only the
group of the filesischanged; in thiscase, chown performsthe same function aschgrp.
OPTIONS
c, changes Verbosely describe only fileswhose ownership actually changes.
f, silent, quiet Do not print error messagesabout fileswhose ownership cannot be changed.
v, verbose Verbosely describe ownership changes.
R, recursive Recursively change ownership of directoriesand their contents.
help Print a usage message on standard output and exit successfully.
version Print version information on standard output then exit successfully.
GNU FileUtilities
chsh
chshChange your login shell
SYNOPSIS
chsh [ s shell ] [ l ] [ u ] [ v ] [ user name ]
DESCRIPTION
chsh isused to change your login shell. If a shell isnot given on the command line, chsh promptsfor one.
VALID SHELLS
chsh will accept the full pathname of any executable file on the system. However, it will issue a warning if the shell isnot
listed in the /etc/shells file.
OPTIONS
s, shell Specify your login shell.
l, list-shells Print the list of shellslisted in /etc/shells and exit.
u, help Print a usage message and exit.
-v, version Print version information and exit.
SEE ALSO
login(1), passwd(5), shells(5)
AUTHOR
Salvatore Valente (<svalente@mit.edu>)
chsh, 13 October 1994
chsh
Part I: User Commands
64
ci
ciCheck in RCS revisions
SYNOPSIS
ci [opt i ons ] f i l e ...
DESCRIPTION
ci storesnew revisionsinto RCSfiles. Each pathname matching an RCSsuffix istaken to be an RCS file. All othersare
assumed to be working filescontaining new revisions. ci depositsthe contentsof each working file into the corresponding
RCS file. If only a working file isgiven, ci triesto find the corresponding RCS file in an RCS subdirectory and then in the
working filesdirectory. (For more details, see File Naming, later in thismanual page.)
For ci to work, the callerslogin must be on the accesslist, unlessthe accesslist isempty or the caller isthe superuser or the
owner of the file. To append a new revision to an existing branch, the tip revision on that branch must be locked by the
caller. Otherwise, only a new branch can be created. Thisrestriction isnot enforced for the owner of the file if non-strict
locking isused; see rcs(1). A lock held by someone else can be broken with the rcscommand.
Unlessthe f option isgiven, ci checkswhether the revision to be deposited differsfrom the preceding one. If not, instead of
creating a new revision ci revertsto the preceding one. To revert, ordinary ci removesthe working file and any lock; ci l
keepsand ci u removesany lock, and then they both generate a new working file much asif co l or co u had been applied
to the preceding revision. When reverting, any n and -s optionsapply to the preceding revision.
For each revision deposited, ci promptsfor a log message. The log message should summarize the change and must be
terminated by end-of-file or by a line containing . by itself. If several filesare checked in, ci askswhether to reuse the
previouslog message. If the standard input isnot a terminal, ci suppressesthe prompt and usesthe same log message for all
files. (See also m.)
If the RCS file doesnot exist, ci createsit and depositsthe contentsof the working file asthe initial revision (default
number: 1.1). The accesslist isinitialized to empty. Instead of the log message, ci requestsdescriptive text (See t.)
The number rev of the deposited revision can be given by any of the optionsf, i, I, j, k, l, M, q, r, or u. rev can be
symbolic, numeric, or mixed. Symbolic namesin rev must already be defined; see the n and N optionsfor assigning names
during checkin. If rev is$, ci determinesthe revision number from keyword valuesin the working file.
If rev beginswith a period, then the default branch (normally the trunk) isprepended to it. If rev isa branch number
followed by a period, then the latest revision on that branch isused.
If rev isa revision number, it must be higher than the latest one on the branch to which rev belongs, or must start a new
branch.
If rev isa branch rather than a revision number, the new revision isappended to that branch. The level number isobtained
by incrementing the tip revision number of that branch. If rev indicatesa nonexistent branch, that branch iscreated with the
initial revision numbered rev.1.
If rev isomitted, ci triesto derive the new revision number from the callerslast lock. If the caller haslocked the tip revision
of a branch, the new revision isappended to that branch. The new revision number isobtained by incrementing the tip
revision number. If the caller locked a nontip revision, a new branch isstarted at that revision by incrementing the highest
branch number at that revision. The default initial branch and level numbersare 1.
If rev isomitted and the caller hasno lock, but ownsthe file and locking isnot set to strict, then the revision isappended to
the default branch. (Normally the trunk; see the b option of rcs(1).)
Exception: On the trunk, revisionscan be appended to the end, but not inserted.
65
OPTIONS
rr ev Check in revision r ev.
r The bare r option (without any revision) hasan unusual meaning in ci. With other RCS
commands, a bare -r option specifiesthe most recent revision on the default branch, but with ci, a
bare -r option reestablishesthe default behavior of releasing a lock and removing the working file,
and isused to override any default l or u optionsestablished by shell aliasesor scripts.
l[r ev] Workslike -r, except it performsan additional co l for the deposited revision. Thus, the
deposited revision isimmediately checked out again and locked. Thisisuseful for saving a revision
although one wantsto continue editing it after the checkin.
u[r ev] Workslike l, except that the deposited revision isnot locked. Thisletsone read the working file
immediately after checkin.
The l, bare -r, and u optionsare mutually exclusive and silently override each other. For example, ci u -r isequivalent
to ci -r because bare -r overridesu.
f[r ev] Forcesa deposit; the new revision isdeposited even it isnot different from the preceding one.
k[r ev] Searchesthe working file for keyword valuesto determine itsrevision number, creation date, state,
and authorsee co(1)and assignsthese valuesto the deposited revision, rather than computing
them locally. It also generatesa default login message noting the login of the caller and the actual
checkin date. Thisoption isuseful for software distribution. A revision that issent to several sites
should be checked in with the k option at these sitesto preserve the original number, date, author,
and state. The extracted keyword valuesand the default log message can be overridden with the
optionsd, m, s, w, and any option that carriesa revision number.
q[r ev] Quiet mode; diagnostic output isnot printed. A revision that isnot different from the preceding
one isnot deposited, unlessf isgiven.
-i[r ev] Initial checkin; report an error if the RCS file already exists. Thisavoidsrace conditionsin certain
applications.
j[r ev] Just check in and do not initialize; report an error if the RCS file doesnot already exist.
I[r ev] Interactive mode; the user isprompted and questioned even if the standard input isnot a terminal.
d[dat e] Usesdate for the checkin date and time. The date isspecified in free format asexplained in co(1).
Thisisuseful for lying about the checkin date, and for k if no date isavailable. If date isempty,
the working filestime of last modification isused.
M[r ev] Set the modification time on any new working file to be the date of the retrieved revision. For
example, ci d M u f doesnot alter fsmodification time, even if fscontentschange due to
keyword substitution. Use thisoption with care; it can confuse make(1).
mmsg Usesthe string msg asthe log message for all revisionschecked in. By convention, log messagesthat
start with # are commentsand are ignored by programslike GNU emacssvc package. Also, log
messagesthat start with clumpname (followed by whitespace) are meant to be clumped together if
possible, even if they are associated with different files; the clumpname label isused only for
clumping, and isnot considered to be part of the log message itself.
nname Assignsthe symbolic name to the number of the checked-in revision. ci printsan error message if
that name isalready assigned to another number.
Nname Same asn, except that it overridesa previousassignment of name.
sst at e Setsthe state of the checked-in revision to the identifier state. The default state isExp.
tf i l e Writesdescriptive text from the contentsof the named file into the RCSfile, deleting the existing
text. The file cannot begin with .
tst r i ng Write descriptive text from the string into the RCS file, deleting the existing text.
The t option, in both itsforms, haseffect only during an initial checkin; it issilently ignored otherwise.
During the initial checkin, if t isnot given, ci obtainsthe text from standard input, terminated by end-of-file or by a line
containing a dot (.) by itself. The user isprompted for the text if interaction ispossible; see I.
ci
Part I: User Commands
66
For backwardscompatibility with older versionsof RCS, a bare t option isignored.
T Set the RCS filesmodification time to the new revisionstime if the former precedesthe latter and
there isa new revision; preserve the RCS filesmodification time otherwise. If you have locked a
revision, ci usually updatesthe RCS filesmodification time to the current time, because the lock is
stored in the RCSfile and removing the lock requireschanging the RCSfile. Thiscan create an
RCS file newer than the working file in one of two ways: first, ci M can create a working file with
a date before the current time; second, when reverting to the previousrevision the RCS file can
change while the working file remainsunchanged. These two casescan cause excessive
recompilation caused by a make(1) dependency of the working file on the RCS file. The T option
inhibitsthisrecompilation by lying about the RCS filesdate. Use thisoption with care; it can
suppressrecompilation even when a checkin of one working file should affect another working file
associated with the same RCS file. For example, suppose the RCS filestime is01:00, the (changed)
working filestime is02:00, some other copy of the working file hasa time of 03:00, and the
current time is04:00. Then ci d T setsthe RCS filestime to 02:00 instead of the usual 04:00;
thiscausesmake(1) to think (incorrectly) that the other copy isnewer than the RCSfile.
wl ogi n Useslogin for the author field of the deposited revision. Useful for lying about the author, and for
k if no author isavailable.
V Print RCSsversion number.
Vn Emulate RCSversion n. See co(1) for details.
xsuf f i xes Specifiesthe suffixesfor RCSfiles. A nonempty suffix matchesany pathname ending in the suffix.
An empty suffix matchesany pathname of the form RCS/path or path1/RCS/path2. The x option
can specify a list of suffixesseparated by /. For example, x,v/ specifiestwo suffixes: ,v and the
empty suffix. If two or more suffixesare specified, they are tried in order when looking for an RCS
file; the first one that worksisused for that file. If no RCS file isfound but an RCS file can be
created, the suffixesare tried in order to determine the new RCS filesname. The default for
suffixesisinstallation-dependent; normally it is,v/ for hostslike UNIX that permit commasin
filenames, and isempty (that is, just the empty suffix) for other hosts.
zzone Specifiesthe date output format in keyword substitution, and specifiesthe default time zone for
date in the ddate option. The zone should be empty, a numeric UTC offset, or the special string
LT for local time. The default isan empty zone, which usesthe traditional RCS format of UTC
without any time-zone indication and with slashesseparating the partsof the date; otherwise, times
are output in ISO 8601 format with time zone indication. For example, if local time isJanuary 11,
1990, 8 p.m. Pacific Standard Time, eight hourswest of UTC, then the time isoutput asfollows:
Option TimeOutput
z 1990/01/12 04:00:00 (default)
zLT 1990-01-11 20:00:0008
z+05:30 1990-01-12 09:30:00+05:30
The z option doesnot affect datesstored in RCSfiles, which are alwaysUTC.
FILE NAMING
Pairsof RCSfilesand working filescan be specified in three ways. (See also Examples, next.)
1. Both the RCSfile and the working file are given. The RCS pathname isof the form path1/workfileX and the working
pathname isof the form path2/workfile where path1/ and path2/ are (possibly different or empty) paths, workfile isa
filename, and X isan RCS suffix. If X isempty, path1/ must start with RCS/ or must contain /RCS/.
2. Only the RCSfile isgiven. Then the working file iscreated in the current directory and itsname isderived from the
name of the RCS file by removing path1/ and the suffix X.
67
3. Only the working file isgiven. Then ci considerseach RCSsuffix X in turn, looking for an RCS file of the form path2/
RCS/workfileX or (if the former isnot found and X isnonempty) path2/workfileX.
If the RCSfile isspecified without a path in one of the first two preceding scenarios, ci looksfor the RCS file first in the
directory ./RCS and then in the current directory.
ci reportsan error if an attempt to open an RCS file failsfor an unusual reason, even if the RCSfilespathname isjust one
of several possibilities. For example, to suppressuse of RCS commandsin a directory d, create a regular file named d/RCS so
that casual attemptsto use RCScommandsin d fail because d/RCS isnot a directory.
EXAMPLES
Suppose ,v isan RCSsuffix and the current directory containsa subdirectory RCS with an RCS file io.c,v. Then each of
the following commandschecksin a copy of io.c into RCS/io.c,v asthe latest revision, removing io.c:
ci io.c; ci RCS/io.c,v; ci io.c,v;
ci io.c RCS/io.c,v; ci io.c io.c,v;
ci RCS/io.c,v io.c; ci io.c,v io.c;
Suppose instead that the empty suffix isan RCS suffix and the current directory containsa subdirectory RCS with an RCS
file io.c. Then each of the following commandschecksin a new revision:
ci io.c; ci RCS/io.c;
ci io.c RCS/io.c;
ci RCS/io.c io.c;
FILE MODES
An RCS file created by ci inheritsthe read and execute permissionsfrom the working file. If the RCS file existsalready, ci
preservesitsread and execute permissions. ci alwaysturnsoff all write permissionsof RCS files.
FILES
Temporary filesare created in the directory containing the working file, and also in the temporary directory. (See TMPDIR
under Environment.) A semaphore file or filesare created in the directory containing the RCS file. With a nonempty
suffix, the semaphore namesbegin with the first character of the suffix; therefore, do not specify an suffix whose first
character could be that of a working filename. With an empty suffix, the semaphore namesend with an underscore (_), so
working filenamesshould not end in _. ci never changesan RCS or working file. Normally, ci unlinksthe file and createsa
new one; but instead of breaking a chain of one or more symbolic linksto an RCS file, it unlinksthe destination file instead.
Therefore, ci breaksany hard or symbolic linksto any working file it changes; and hard linksto RCSfilesare ineffective, but
symbolic linksto RCSfilesare preserved.
The effective user must be able to search and write the directory containing the RCS file. Normally, the real user must be
able to read the RCSand working filesand to search and write the directory containing the working file; however, some
older hostscannot easily switch between real and effective users, so on these hoststhe effective user isused for all accesses.
The effective user isthe same asthe real user unlessyour copiesof ci and co have setuid privileges. These privilegesyield
extra security if the effective user ownsall RCS filesand directories, and if only the effective user can write RCS directories.
Userscan control accessto RCS filesby setting the permissionsof the directory containing the files; only userswith write
accessto the directory can use RCS commandsto change itsRCS files. For example, in hoststhat allow a user to belong to
several groups, one can make a groupsRCS directorieswritable to that group only. Thisapproach sufficesfor informal
projects, but it meansthat any group member can arbitrarily change the groupsRCS files, and can even remove them
entirely. Hence, more formal projectssometimesdistinguish between an RCS administrator, who can change the RCS files
at will, and other project members, who can check in new revisionsbut cannot otherwise change the RCS files.
setuid USE
To prevent anybody but their RCS administrator from deleting revisions, a set of userscan employ setuid privilegesas
follows:
ci
Part I: User Commands
68
I Check that the host supportsRCS setuid use. Consult a trustworthy expert if there are any doubts. It isbest if the
setuid system callsworksasdescribed in POSIX 1003.1a Draft 5, because RCS can switch back and forth easily
between real and effective users, even if the real user isroot. If not, the second best isif the setuid system call supports
saved setuid (the {_POSIX_SAVED_IDS} behavior of POSIX 1003.1-1990); thisfailsonly if the real or effective user isroot.
If RCS detectsany failure in setuid, it quitsimmediately.
I Choose a user A to serve asRCSadministrator for the set of users. Only A can invoke the rcscommand on the users
RCS files. A should not be root or any other user with special powers. Mutually suspicioussetsof usersshould use
different administrators.
I Choose a pathname B to be a directory of filesto be executed by the users.
I Have A set up B to contain copiesof ci and co that are setuid to A by copying the commandsfrom their standard
installation directory D asfollows:
mkdir B cp D/c[io] B chmod gow,u+s B/c[io]
I Have each user prepend B to his/her path asfollows:
PATH=B:$PATH; export PATH # ordinary shell
set path=(B $path) # C shell
I Have A create each RCSdirectory R with write accessonly to A asfollows:
mkdir R chmod gow R
I If you want to let only certain usersread the RCS files, put the usersinto a group G, and have A further protect the RCS
directory asfollows:
chgrp G Rchmod gw,orwx R
I Have A copy old RCS files(if any) into R, to ensure that A ownsthem.
I An RCS filesaccesslist limitswho can check in and lock revisions. The default accesslist isempty, which grants
checkin accessto anyone who can read the RCSfile. If you want limit checkin access, have A invoke rcs a on the file;
see rcs(1). In particular, rcs e aA limitsaccessto just A.
I Have A initialize any new RCS fileswith rcs -i before initial checkin, adding the a option if you want to limit checkin
access.
I Give setuid privilegesonly to ci, co, and rcsclean; do not give them to rcs or to any other command.
I Do not use other setuid commandsto invoke RCS commands; setuid istrickier than you think!
ENVIRONMENT
RCSINIT Optionsprepended to the argument list, separated by spaces. A backslash escapesspaceswithin an option.
The RCSINIT optionsare prepended to the argument listsof most RCS commands. Useful RCSINIT options
include q, V, x, and z.
TMPDIR Name of the temporary directory. If not set, the environment variablesTMP and TEMPs0 are inspected
instead and the first value found istaken; if none of them are set, a host-dependent default isused,
typically /tmp.
DIAGNOSTICS
For each revision, ci printsthe RCSfile, the working file, and the number of both the deposited and the preceding revision.
The exit statusiszero if and only if all operationswere successful.
IDENTIFICATION
Author: Walter F. Tichy.
Manual page revision: 5.17; Release date 16 June 1995
Copyright 1982, 1988, 1989 Walter F. Tichy
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
69
SEE ALSO
co(1), emacs(1), ident(1), make(1), rcs(1), rcsclean(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1), setuid(2), rcsfile(5)
Walter F. Tichy, RCSA System for Version Control, SoftwarePractice& Experience15, 7 (July 1985), 637654.
GNU, 16 June1995
cidentd
cidentdidentd server
SYNOPSIS
cidentd [usqvnah] [f file] [l file] [t seconds]
DESCRIPTION
cidentd givesauthentication information.
cidentd isan RFC 1314- and 931-compliant identd daemon. It acceptsconnectionson a port (113 default) and answers
queriesfor port owner of a connection. command;
cidentd normally terminateswhen the remote command does. The optionsare asfollows:
u Turnson the use of the .authlie file in the usershome directory to give the requesting system whatever
information the user provides. Thisfile isoverridden by the -a option and the system file the format isas
follows:
mynameis name-to-be-given # give this userid
hideme # hide user id
host-ip name-to-be-given # userid for them
host-ip no-info # hide you to them
host-ip can be an ip in dot notation or a name. The file isset so that whatever comeslast iswhat they get.
s Closesthe connection after a single query.
q Quitsthe daemon after 1 connection (default in 1.0b).
v Turnson verbose logging to the syslogs.
n Makescident act like the old school identd with nothing special.
a Enablesthe /etc/cident.users file for options, which overridesthe user filesif -u isspecified. The format
isasfollows:
username name-to-send # send this for username
username # must send there username
all name-to-send # send for every query
all no-info # send nothing every query
host-ip name-to-send # send to that host
host-ip no-info # send nothing to them
host-ip can be an ip in dot notation or a name. The file isset so that whatever comeslast iswhat they get.
h Displaysthe help list to the screen you might not want to do thisfrom some terminal types.
f Setsthe file to find the portsand idsof connections. Use thisto specify a file other than /proc/net/tcp.
l Used to specify a file other than /etc/cident.users must be used with the -a option unlessyou like
redundancy.
t Setsthe time out of a connection in seconds. Thisdoesnot work in thisversion to cidentd.
cidentd
Part I: User Commands
70
If no argumentsare specified, the program just runsasnormal, almost like the n.
cidentd t 30 a setstimer to 30 secondsand tellsit to look at .authlie files.
FILES
/etc/cidentd.users
$(HOME)/.authlie
SEE ALSO
identd(1)
BUGS
None that I know of.
Linux/FreeBSD, May1996
cksum
cksumChecksum and count the bytesin a file
SYNOPSIS
cksum [help] [version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of cksum. cksum computesa cyclic redundancy check (CRC) for each named
file, or the standard input if none are given or when a file named isgiven. It printsthe CRC for each file along with the
number of bytesin the file, and the filename unlessno argumentswere given.
cksum istypically used to make sure that filestransferred by unreliable means(such asnetnews) have not been corrupted. This
isaccomplished by comparing the cksum output for the received fileswith the cksum output for the original files. The CRC
algorithm isspecified by the POSIX.2 standard. It isnot compatible with the BSD or System V sum programs; it ismore
robust.
Available optionsare
help Print a usage message and exit with a nonzero status.
version Print version information on standard output then exit.
GNU Text Utilities
clear
clearClear terminal screen
SYNOPSIS
clear
DESCRIPTION
clear callstput(1) with the clear argument. Thiscausestput to attempt to clear the screen, checking the data in /etc/termcap
(for the GNU or BSD tput) or in the terminfo database (for the ncurses tput) and sending the appropriate sequence to the
terminal. Thiscommand can be redirected to clear the screen of some other terminal.
71
SEE ALSO
reset(1), stty(1), tput(1)
AUTHOR
Rik Faith (faith@cs.unc.edu)
Linux 0.99, 10 October 1993
cmuwmtopbm
cmuwmtopbmConvert a CMU window manager bitmap into a portable bitmap
SYNOPSIS
cmuwmtopbm [cmuwmfile]
DESCRIPTION
Readsa CMU window manager bitmap asinput. Producesa portable bitmap asoutput.
SEE ALSO
pbmtocmuwm(1), pbm(5)
AUTHOR
Copyright 1989 by Jef Poskanzer
15 April 1989
co
coCheck out RCS revisions
SYNOPSIS
co [options] file ...
DESCRIPTION
co retrievesa revision from each RCS file and storesit into the corresponding working file.
Pathnamesmatching an RCS suffix denote RCS files; all othersdenote working files. Namesare paired asexplained in ci(1).
Revisionsof an RCS file can be checked out locked or unlocked. Locking a revision preventsoverlapping updates. A revision
checked out for reading or processing (for example, compiling) need not be locked. A revision checked out for editing and
later checkin must normally be locked. Checkout with locking failsif the revision to be checked out iscurrently locked by
another user. (A lock can be broken with rcs(1).) Checkout with locking also requiresthe caller to be on the accesslist of the
RCS file, unlesshe isthe owner of the file or the superuser, or the accesslist isempty. Checkout without locking isnot
subject to accesslist restrictions, and isnot affected by the presence of locks.
A revision isselected by optionsfor revision or branch number, checkin date/time, author, or state. When the selection
optionsare applied in combination, co retrievesthe latest revision that satisfiesall of them. If none of the selection optionsis
specified, co retrievesthe latest revision on the default branch, normally the trunk; see the b option of rcs(1). A revision or
branch number can be attached to any of the optionsf, I, l, M, p, q, -r, or u. The optionsd (date), s (state), and w
(author) retrieve from a single branch, the selected branch (which isspecified by f or u), or the default branch.
A co command applied to an RCSfile with no revisionscreatesa zero-length working file. co alwaysperformskeyword
substitution.
co
Part I: User Commands
72
OPTIONS
-r[r ev] Retrievesthe latest revision whose number islessthan or equal to r ev. If r ev indicatesa branch
rather than a revision, the latest revision on that branch isretrieved. If r ev isomitted, the latest
revision on the default branch isretrieved; see the b option of rcs(1). If r ev is$, co determinesthe
revision number from keyword valuesin the working file. Otherwise, a revision iscomposed of one
or more numeric or symbolic fieldsseparated by periods. If r ev beginswith a period, then the
default branch (normally the trunk) isprepended to it. If r ev isa branch number followed by a
period, then the latest revision on that branch isused. The numeric equivalent of a symbolic field is
specified with the n option of the commandsci(1) and rcs(1).
l[r ev] Same as-r, except that it also locksthe retrieved revision for the caller.
u[r ev] Same as-r, except that it unlocksthe retrieved revision if it waslocked by the caller. If r ev is
omitted, u retrievesthe revision locked by the caller, if there isone; otherwise, it retrievesthe latest
revision on the default branch.
f[r ev] Forcesthe overwriting of the working file; useful in connection with q. (See also File Modes,
later in thismanual page.)
kkv Generate keyword stringsusing the default form, for example, $Revision: 5.13 $ for the Revision
keyword. A lockersname isinserted in the value of the Header, Id, and Locker keyword stringsonly
asa file isbeing locked, that is, by ci l and co l. Thisisthe default.
kkvl Like kkv, except that a lockersname isalwaysinserted if the given revision iscurrently locked.
kk Generate only keyword namesin keyword strings; omit their values. (See Keyword Substitution,
later in thismanual page.) For example, for the Revision keyword, generate the string $Revision$
instead of $Revision: 5.13 $. Thisoption isuseful to ignore differencesdue to keyword substitu-
tion when comparing different revisionsof a file. Log messagesare inserted after $Log$ keywords
even if kk isspecified, since thistendsto be more useful when merging changes.
ko Generate the old keyword string, present in the working file just before it waschecked in. For
example, for the Revision keyword, generate the string $Revision: 1.1 $ instead of $Revision: 5.13
$ if that ishow the string appeared when the file waschecked in. Thiscan be useful for file formats
that cannot tolerate any changesto substringsthat happen to take the form of keyword strings.
kb Generate a binary image of the old keyword string. Thisactslike ko, except it performsall
working file input and output in binary mode. Thismakeslittle difference on POSIX and UNIX
hosts, but on DOS-like hostsone should use rcs -i kb to initialize an RCS file normally refuses
to merge fileswhen kb isin effect.
kv Generate only keyword valuesfor keyword strings. For example, for the Revision keyword, generate
the string 5.13 instead of $Revision: 5.13 $. Thiscan help generate filesin programming languages
where it ishard to strip keyword delimiterslike $Revision: $ from a string. However, further
keyword substitution cannot be performed once the keyword namesare removed, so thisoption
should be used with care. Because of thisdanger of losing keywords, thisoption cannot be
combined with l, and the owner write permission of the working file isturned off; to edit the file
later, check it out again without kv.
p[r ev] Printsthe retrieved revision on the standard output rather than storing it in the working file. This
option isuseful when co ispart of a pipe.
q[r ev] Quiet mode; diagnosticsare not printed.
I[r ev] Interactive mode; the user isprompted and questioned even if the standard input isnot a terminal.
ddat e Retrievesthe latest revision on the selected branch whose checkin date/time islessthan or equal to
date. The date and time can be given in free format. The time zone LT standsfor local time; other
common time zone namesare understood. For example, the following datesare equivalent if local
time isJanuary 11, 1990, 8 p.m. Pacific Standard Time, eight hourswest of Coordinated Universal
Time (UTC):
8:00 PM lt
4:00 AM, Jan. 12, 1990 Default isUTC
73
1990-01-12 04:00:00+00 ISO 8601 (UTC)
1990-01-11 20:00:0008 ISO 8601 (local time)
1990/01/12 04:00:00 Traditional RCSformat
Thu Jan 11 20:00:00 1990 LT Output of ctime(3) + LT
Thu Jan 11 20:00:00 PST 1990 Output of date(1)
Fri Jan 12 04:00:00 GMT 1990
Thu, 11 Jan 1990 20:00:00 0800 Internet RFC 822
12-January-1990, 04:00 WET
Most fieldsin the date and time can be defaulted. The default time zone isnormally UTC, but thiscan be overridden by the
z option. The other defaultsare determined in the order year, month, day, hour, minute, and second (most to least
significant). At least one of these fieldsmust be provided. For omitted fieldsthat are of higher significance than the highest
provided field, the time zonescurrent valuesare assumed. For all other omitted fields, the lowest possible valuesare
assumed. For example, without z, the date 20, 10:30 defaultsto 10:30:00 UTC of the 20th of the UTC time zonescurrent
month and year. The date/time must be quoted if it containsspaces.
M[r ev] Setsthe modification time on the new working file to be the date of the retrieved revision. Use this
option with care; it can confuse make(1).
sst at e Retrievesthe latest revision on the selected branch whose state isset to state.
T Preservesthe modification time on the RCS file even if the RCS file changesbecause a lock is
added or removed. Thisoption can suppressextensive recompilation caused by a make(1) depen-
dency of some other copy of the working file on the RCSfile. Use thisoption with care; it can
suppressrecompilation even when it isneeded, in other words, when the change of lock would
mean a change to keyword stringsin the other working file.
w[l ogi n] Retrievesthe latest revision on the selected branch that waschecked in by the user with login name
l ogi n. If the argument l ogi n isomitted, the callerslogin isassumed.
jj oi nl i st Generatesa new revision which isthe join of the revisionson j oi nl i st . Thisoption islargely made
obsolete by rcsmerge(1), but isretained for backwardscompatibility.
The j oi nl i st isa comma-separated list of pairsof the form r ev2: r ev3, where r ev2 and r ev3 are
(symbolic or numeric) revision numbers. For the initial such pair, r ev1 denotesthe revision selected
by the optionsf, w. For all other pairs, r ev1 denotesthe revision generated by the previouspair.
(Thus, the output of one join becomesthe input to the next.)
For each pair, co joinsrevisionsr ev1 and r ev3 with respect to r ev2. Thismeansthat all changesthat
transform r ev2 into r ev1 are applied to a copy of r ev3. Thisisparticularly useful if r ev1 and r ev3
are the endsof two branchesthat have r ev2 asa common ancestor. If r ev1<r ev2<r ev 3 on the same
branch, joining generatesa new revision which islike r ev3, but with all changesthat lead from r ev1
to r ev2 undone. If changesfrom r ev2 to r ev1 overlap with changesfrom r ev2 to r ev3, co reports
overlapsasdescribed in merge(1).
For the initial pair, r ev2 can be omitted. The default isthe common ancestor. If any of the
argumentsindicate branches, the latest revisionson those branchesare assumed. The optionsl
and u lock or unlock r ev1.
V PrintsRCSsversion number.
Vn EmulatesRCSversion n, where n can be 3, 4, or 5. Thiscan be useful when interchanging RCS
fileswith otherswho are running older versionsof RCS. To see which version of RCS your
correspondentsare running, have them invoke rcs V; thisworkswith newer versionsof RCS. If it
doesnt work, have them invoke rlog on an RCS file; if none of the first few linesof output contain
the string branch:, it isversion 3; if the dates yearshave just two digits, it isversion 4; otherwise, it
isversion 5. An RCS file generated while emulating version 3 losesitsdefault branch. An RCS
revision generated while emulating version 4 or earlier hasa timestamp that isoff by up to 13
hours. A revision extracted while emulating version 4 or earlier containsabbreviated datesof the
form yy/mm/dd and can also contain different whitespace and line prefixesin the substitution for
$Log$.
co
Part I: User Commands
74
xsuf f i xes Usessuffixesto characterize RCS files. See ci(1) for details.
zzone Specifiesthe date output format in keyword substitution, and specifiesthe default time zone for
date in the ddat e option. The zone should be empty, a numeric UTC offset, or the special string
LT for local time. The default isan empty zone, which usesthe traditional RCS format of UTC
without any time zone indication and with slashesseparating the partsof the date; otherwise, times
are output in ISO 8601 format with time zone indication. For example, if local time isJanuary 11,
1990, 8 p.m. Pacific Standard Time, eight hourswest of UTC, then the time isoutput asfollows:
Option TimeOutput
z 1990/01/12 04:00:00 (default)
zLT 1990-01-11 20:00:0008
z+05:30 1990-01-12 09:30:00+05:30
The z option doesnot affect datesstored in RCSfiles, which are alwaysUTC.
KEYWORD SUBSTITUTION
Stringsof the form $ keywor d $ and $ keywor d : ... $ embedded in the text are replaced with stringsof the form $ keywor d
: val ue $, where keywor d and val ue are pairsin the following list. Keywordscan be embedded in literal stringsor comments
to identify a revision.
Initially, the user entersstringsof the form $keywor d$. On checkout, co replacesthese stringswith stringsof the form
$keywor d : val ue$. If a revision containing stringsof the latter form ischecked back in, the val ue fieldswill be replaced
during the next checkout. Thus, the keyword valuesare automatically updated on checkout. Thisautomatic substitution can
be modified by the k options.
Keywordsand their corresponding values:
$Aut hor $ The login name of the user who checked in the revision.
$Dat e$ The date and time the revision waschecked in. With zzone, a numeric time zone offset is
appended; otherwise, the date isUTC.
$Header $ A standard header containing the full pathname of the RCSfile, the revision number, the date and
time, the author, the state, and the locker (if locked). With zzone, a numeric time zone offset is
appended to the date; otherwise, the date isUTC.
$I d$ Same as$Header $, except that the RCS filename iswithout a path.
$Locker $ The login name of the user who locked the revision (empty if not locked).
$Log$ The log message supplied during checkin, preceded by a header containing the RCSfilename, the
revision number, the author, and the date and time. With zzone a numeric time zone offset is
appended; otherwise, the date isUTC. Existing log messagesare not replaced. Instead, the new log
message isinserted after $Log: ... $ . Thisisuseful for accumulating a complete change log in a
source file.
Each inserted line isprefixed by the string that prefixesthe $Log$ line. For example, if the $Log$ line is// $Log: tan.cc $,
RCS prefixeseach line of the log with //. Thisisuseful for languageswith commentsthat go to the end of the line. The
convention for other languagesisto use a * prefix inside a multiline comment. For example, the initial log comment of a C
program conventionally isof the following form:
/*
* $Log$
*/
For backwardscompatibility with older versionsof RCS, if the log prefix is/* or (* surrounded by optional whitespace,
inserted log linescontain a space instead of / or (; however, thisusage isobsolescent and should not be relied on.
$Name$ The symbolic name used to check out the revision, if any. For example, co -r Joe generates$Name:
Joe $. Plain co generatesjust $Name: $.
75
$RCSf i l e$ The name of the RCS file without a path.
$Revi si on$ The revision number assigned to the revision.
$Sour ce$ The full pathname of the RCS file.
$St at e$ The state assigned to the revision with the s option of rcs(1) or ci(1).
The following charactersin keyword valuesare represented by escape sequencesto keep keyword stringswell-formed.
Character EscapeSequence
tab \t
newline \n
space \040
$ \044
\ \\
FILE MODES
The working file inheritsthe read and execute permissionsfrom the RCS file. In addition, the owner write permission is
turned on, unlesskv isset or the file ischecked out unlocked and locking isset to strict; see rcs(1).
If a file with the name of the working file existsalready and haswrite permission, co abortsthe checkout, asking beforehand
if possible. If the existing working file isnot writable or f isgiven, the working file isdeleted without asking.
FILES
co accessesfilesmuch asci(1) does, except that it doesnot need to read the working file unlessa revision number of $ is
specified.
ENVIRONMENT
RCSINIT Optionsprepended to the argument list, separated by spaces. See ci(1) for details.
DIAGNOSTICS
The RCS pathname, the working pathname, and the revision number retrieved are written to the diagnostic output. The exit
statusiszero if and only if all operationswere successful.
IDENTIFICATION
Author: Walter F. Tichy.
Manual Page Revision: 5.13; Release Date: 1995/06/01.
Copyright 1982, 1988, 1989 Walter F. Tichy.
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert.
SEE ALSO
rcsintro(1), ci(1), ctime(3), date(1), ident(1), make(1), rcs(1), rcsclean(1), rcsdiff(1), rc-smerge(1), rlog(1), rcsfile(5)
Walter F. Tichy, RCSA System for Version Control, SoftwarePractice& Experience15, 7 (July 1985), 637-654.
LIMITS
Linksto the RCSand working filesare not preserved.
There isno way to selectively suppressthe expansion of keywords, except by writing them differently. In nroff and troff,
thisisdone by embedding the null-character \& into the keyword.
GNU, 1 June1995
co
Part I: User Commands
76
col
colFilter reverse line feedsfrom input
SYNOPSIS
col [-bfx] [-l num]
DESCRIPTION
col filtersout reverse (and half-reverse) line feedsso the output isin the correct order with only forward and half-forward
line feeds, and replaceswhitespace characterswith tabswhere possible. Thiscan be useful in processing the output of
nroff(1) and tbl(1). col readsfrom standard input and writesto standard output.
The optionsare asfollows:
-b Do not output any backspaces, printing only the last character written to each column position.
-f Forward half-line feedsare permitted (fine mode). Normally charactersprinted on a half-line boundary
are printed on the following line.
-x Output multiple spacesinstead of tabs.
-lnum Buffer at least num linesin memory. By default, 128 linesare buffered.
The control sequencesfor carriage motion that col understandsand their decimal valuesare listed in the following table:
Control Sequence Decimal Value
Esc+7 Reverse line feed (escape then 7)
Esc+8 Half-reverse line feed (escape then 8)
Esc+9 Half-forward line feed (escape then 9)
Backspace Movesback one column (8); ignored in the first column
Carriage return (13)
Newline Forward line feed (10); also doescarriage return
Shift in Shift to normal character set (15)
Shift out Shift to alternate character set (14)
Space Movesforward one column (32)
Tab Movesforward to next tab stop (9)
Vertical tab Reverse line feed (11)
All unrecognized control charactersand escape sequencesare discarded.
col keepstrack of the character set ascharactersare read and makessure the character set iscorrect when they are output.
If the input attemptsto back up to the last flushed line, col will display a warning message.
SEE ALSO
expand(1), nroff(1), tbl(1)
HISTORY
A col command appeared in version 6 AT&T UNIX.
17 June1991
77
colcrt
colcrtFilter nroff output for CRT previewing
SYNOPSIS
colcrt [] [2] [f i l e ...]
DESCRIPTION
colcrt providesvirtual half-line and reverse-line feed sequencesfor terminalswithout such capability, and on which
overstriking isdestructive. Half-line charactersand underlining (changed to dashing ) are placed on new linesin between
the normal output lines.
Available options:
Suppressall underlining. Thisoption isespecially useful for previewing all boxed tablesfrom tbl(1).
2 Causesall half-linesto be printed, effectively double spacing the output. Normally, a minimal space
output format isused which will suppressempty lines. The program never suppressestwo consecutive
empty lines, however. The -2 option isuseful for sending output to the line printer when the output
containssuperscriptsand subscriptsthat would otherwise be invisible.
EXAMPLES
A typical use of colcrt would be
tbl exum2.n | nroff -ms | colcrt - | more
SEE ALSO
nroff(1), troff(1), col(1), more(1), ul(1)
BUGS
Should fold underlinesonto blankseven with the - option so that a true underline character would show.
Cant back up more than 102 lines.
General overstriking islost; asa special case | overstruck with or underline becomes+. Linesare trimmed to 132
characters.
Some provision should be made for processing superscriptsand subscriptsin documentsthat are already double-spaced.
HISTORY
The colcrt command appeared in BSD 3.0.
BSD 3, 30 June1993
colrm
colrmRemove columnsfrom a file
SYNOPSIS
colrm [st ar t col [endcol ]]
DESCRIPTION
colrm removesselected columnsfrom a file. Input istaken from standard input. Output issent to standard output.
If called with one parameter, the columnsof each line will be removed starting with the specified column. If called with two
parameters, the columnsfrom the first column to the last column will be removed.
Column numbering startswith column 1.
colrm
Part I: User Commands
78
SEE ALSO
awk(1), column(1), expand(1), paste(1)
HISTORY
The colrm command appeared in BSD 3.0.
BSD 3, 14 March 1991
column
columnColumnate lists
SYNOPSIS
column [tx] [ccol umns ] [ssep] [...f i l e]
DESCRIPTION
The column utility formatsitsinput into multiple columns. Rowsare filled before columns. Input istaken from file operands,
or, by default, from the standard input. Empty linesare ignored.
The optionsare asfollows:
c Output isformatted for a display columnswide.
-s Specify a set of charactersto be used to delimit columnsfor the -t option.
-t Determine the number of columnsthe input containsand create a table. Columnsare delimited with
whitespace, by default, or with the characterssupplied using the -s option. Useful for pretty-printing
displays.
-x Fill columnsbefore filling rows.
Column exits0 on success, >0 if an error occurred.
ENVIRONMENT
The environment variable COLUMNS isused to determine the size of the screen if no other information isavailable.
EXAMPLES
(printf PERM LINKS OWNER SIZE MONTH DAY HH:MM/YEAR NAME; ls -l j sed 1d) j column -t
SEE ALSO
colrm(1), ls(1), paste(1), sort(1)
HISTORY
The column command appeared in BSD 4.3 Reno.
6 June1993
comm
commCompare two sorted filesline by line
SYNOPSIS
comm [123] [help] [version] f i l e1 f i l e2
79
DESCRIPTION
Thismanual page documentsthe GNU version of comm. comm printslinesthat are common, and linesthat are unique, to two
input files. The two filesmust be sorted before comm can be used. The filename meansthe standard input.
With no options, comm producesthree column output. Column one containslinesunique to f i l e1, column two contains
linesunique to f i l e2, and column three containslinescommon to both files.
OPTIONS
The options1, 2, and 3 suppressprinting of the corresponding columns.
help Print a usage message and exit with a nonzero status.
version Print version information on standard output then exit.
GNU Text Utilities
convdate
convdateConvert time/date stringsand numbers
SYNOPSIS
convdate [ c ][n ][s ] ar g...
DESCRIPTION
convdate translatesthe date/time stringsspecified asargumentson itscommand line, outputting the resultsone to a line.
If the s flag isused, then each argument istaken asa date string to be parsed by parse-date(3) and isoutput asa string
formatted by ctime(3). Thisisthe default.
If the n flag isused, then each argument isconverted the same way but isoutput asa time t; see time(2).
If the c flag isused, then each argument istaken to be a time t and isoutput in ctime format.
Heresan example:
% convdate feb 10 10am
Sun Feb 10 10:00:00 1991
% convdate 12pm 5/4/90
Fri Dec 13 00:00:00 1991
Fri May 4 00:00:00 1990
% convdate -n feb 10 10am 12pm 5/4/90'
666198000
641880000
% convdate -c 666198000
Sun Feb 10 10:00:00 1991
HISTORY
Written by Rich $alz (rsalz@uunet.uu.net).
SEE ALSO
parsedate(3)
convdate
Part I: User Commands
80
cp
cpCopy files
SYNOPSIS
cp [options] source dest
cp [options] source... directory
Options:
[abdfilprsuvxPR] [S backup-suffix] [V fnumbered,existing,simpleg] [backup]
[no-dereference] [force] [interactive] [one-file-system] [preserve]
[recursive][update] [verbose] [suffix=backup-suffix]
[version-control=fnumbered,existing,simpleg] [archive] [parents] [link]
[symbolic-link] [help] [version]
DESCRIPTION
Thismanual page documentsthe GNU version of cp. If the last argument namesan existing directory, cp copieseach other
given file into a file with the same name in that directory. Otherwise, if only two filesare given, it copiesthe first onto the
second. It isan error if the last argument isnot a directory and more than two filesare given. By default, it doesnot copy
directories.
OPTIONS
a, archive Preserve asmuch aspossible of the structure and attributesof the original filesin the copy.
The same asdpR.
b, backup Make backupsof filesthat are about to be overwritten or removed.
d, no-dereference Copy symbolic linksassymbolic linksrather than copying the filesthat they point to, and
preserve hard link relationshipsbetween source filesin the copies.
f, force Remove existing destination files.
-i, interactive Prompt whether to overwrite existing regular destination files.
l, link Make hard linksinstead of copiesof nondirectories.
P, parents Form the name of each destination file by appending to the target directory a slash and the
specified name of the source file. The last argument given to cp must be the name of an
existing directory. For example, the command cp parents a/b/c existing_dir copiesthe
file a/b/c to existing_dir/a/b/c, creating any missing intermediate directories.
p, preserve Preserve the original files owner, group, permissions, and timestamps.
-r Copy directoriesrecursively, copying all nondirectoriesasif they were regular files.
s, symbolic-link Make symbolic linksinstead of copiesof nondirectories. All source filenamesmust be
absolute (starting with /) unlessthe destination filesare in the current directory. This
option producesan error message on systemsthat do not support symbolic links.
u, update Do not copy a nondirectory that hasan existing destination with the same or newer
modification time.
v, verbose Print the name of each file before copying it.
x, one-file-system Skip subdirectoriesthat are on different filesystemsfrom the one that the copy started on.
R, recursive Copy directoriesrecursively.
help Print a usage message on standard output and exit successfully.
version Print version information on standard output then exit successfully.
S, suffix backup-suffix The suffix used for making simple backup filescan be set with the SIMPLE_BACKUP_SUFFIX
environment variable, which can be overridden by thisoption. If neither of those isgiven,
the default is~, asit isin emacs.
81
V, version-control The type of backupsmade can be set with the VERSION_CONTROL environment variable, which
{numbered,existing,simple} can be overridden by thisoption. If VERSION_CONTROL isnot set and thisoption isnot given,
the default backup type isexisting. The value of the VERSION_CONTROL environment variable
and the argument to thisoption are like the GNU emacs version- control variable; they
also recognize synonymsthat are more descriptive. The valid valuesare (unique abbrevia-
tionsare accepted) the following:
t or numbered Alwaysmake numbered backups
nil or existing Make numbered backupsof filesthat already have them,
simple backupsof the others
never or simple Alwaysmake simple backups
cccp, cpp
cccp, cppThe GNU C-compatible compiler preprocessor
SYNOPSIS
cccp [$][A pr edi cat e [( val ue )]] [ C ][D name [ = def i ni t i on ]]
[dD][dM][I\ di r ect or y ][H ][I ][imacros f i l e ][
include f i l e ][idirafter di r ][iprefix pr ef i x ][iwithprefix di r ]
[ langc][langc++][langobjc ][langobjc++ ][lint ][
M[MG ]] [ MM[MG ]] [ MD f i l e ][MMD f i l e ][nostdinc ]
[ nostdinc++][P][pedantic ][pedanticerrors ][traditional ]
[ trigraphs ][U name ][undef ][Wtrigraphs ][Wcomment ]
[ Wall ][Wtraditional ]
[ i nf i l e | ][ out f i l e | ]
DESCRIPTION
The C preprocessor isa macro processor that isused automatically by the C compiler to transform your program before
actual compilation. It iscalled a macro processor because it allowsyou to define macros, which are brief abbreviationsfor
longer constructs.
The C preprocessor providesfour separate facilitiesthat you can use asyou see fit:
I Inclusion of header files. These are filesof declarationsthat can be substituted into your program.
I Macro expansion. You can define macros, which are abbreviationsfor arbitrary fragmentsof C code, and then the C
preprocessor will replace the macroswith their definitionsthroughout the program.
I Conditional compilation. Using special preprocessing directives, you can include or exclude partsof the program
according to variousconditions.
I Line control. If you use a program to combine or rearrange source filesinto an intermediate file which isthen compiled,
you can use line control to inform the compiler of where each source line originally came from.
C preprocessorsvary in some details. For a full explanation of the GNU C preprocessor, see the info file cpp.info, or the
manual TheC Preprocessor . Both of these are built from the same documentation source file, cpp.texinfo. The GNU C
preprocessor providesa superset of the featuresof ANSI Standard C.
ANSI Standard C requiresthe rejection of many harmlessconstructscommonly used by todaysC programs. Such
incompatibility would be inconvenient for users, so the GNU C preprocessor isconfigured to accept these constructsby
default. Strictly speaking, to get ANSI Standard C, you must use the optionstrigraphs, undef, and pedantic, but in
practice the consequencesof having strict ANSI Standard C make it undesirable to do this.
When you use the C preprocessor, you will usually not have to invoke it explicitly: the C compiler will do so automatically.
However, the preprocessor issometimesuseful individually.
When you call the preprocessor individually, either name (cpp or cccp) will do; they are completely synonymous.
cccp, cpp
Part I: User Commands
82
The C preprocessor expectstwo filenamesasarguments, infile and outfile. The preprocessor readsinfile together with
any other filesit specifieswith #include. All the output generated by the combined input filesiswritten in outfile. Either
infile or outfile may be , which asinfile meansto read from standard input and asoutfile meansto write to standard
output. Also, if outfile or both filenamesare omitted, the standard output and standard input are used for the omitted
filenames.
OPTIONS
Here isa table of command optionsaccepted by the C preprocessor. These optionscan also be given when compiling a C
program; they are passed along automatically to the preprocessor when it isinvoked by the compiler.
P Inhibit generation of # lineswith line-number information in the output from the preprocessor.
Thismight be useful when running the preprocessor on something that isnot C code and will be
sent to a program which might be confused by the # lines.
C Do not discard comments: passthem through to the output file. Commentsappearing in
argumentsof a macro call will be copied to the output before the expansion of the macro call.
traditional Try to imitate the behavior of old-fashioned C, asopposed to ANSI C.
trigraphs ProcessANSI standard trigraph sequences. These are three-character sequences, all starting with ??,
that are defined by ANSI C to stand for single characters. For example, ??/ standsfor \, so ??/n isa
character constant for a newline. Strictly speaking, the GNU C preprocessor doesnot support all
programsin ANSI Standard C unlesstrigraphs isused, but if you ever notice the difference, it
will be with relief. You dont want to know any more about trigraphs.
pedantic Issue warningsrequired by the ANSI C standard in certain casessuch aswhen text other than a
comment follows#else or #endif.
pedanticerrors Like pedantic, except that errorsare produced rather than warnings.
Wtrigraphs Warn if any trigraphsare encountered (assuming they are enabled).
Wcomment Warn whenever a comment-start sequence /* appearsin a comment. (Both formshave the
Wcomments same effect.)
Wall Requestsboth Wtrigraphs and Wcomment (but not Wtraditional).
Wtraditional Warn about certain constructsthat behave differently in traditional and ANSI C.
I di r ect or y Add the directory di r ect or y to the end of the list of directoriesto be searched for header files. This
can be used to override a system header file, substituting your own version, since these directories
are searched before the system header file directories. If you use more than one I option, the
directoriesare scanned in left-to-right order; the standard system directoriescome after.
I Any directoriesspecified with I optionsbefore the I option are searched only for the case of
#include file ; they are not searched for #include < file >.
If additional directoriesare specified with I optionsafter the I, these directoriesare searched for
all #include directives.
In addition, the I option inhibitsthe use of the current directory asthe first search directory for
#include file . Therefore, the current directory issearched only if it isrequested explicitly with
I followed by a period (.). Specifying both I and I. allowsyou to control precisely which
directoriesare searched before the current one and which are searched after.
nostdinc Do not search the standard system directoriesfor header files. Only the directoriesyou have
specified with I options(and the current directory, if appropriate) are searched.
nostdinc++ Do not search for header filesin the C++-specific standard directories, but do still search the other
standard directories. (Thisoption isused when building libg++.)
D name Predefine name asa macro, with definition 1.
D name=def i ni t i on Predefine name asa macro, with definition def i ni t i on. There are no restrictionson the contentsof
definition, but if you are invoking the preprocessor from a shell or shell-like program, you may
need to use the shellsquoting syntax to protect characterssuch asspacesthat have a meaning in
the shell syntax. If you use more than one D for the same name, the rightmost definition takes
effect.
83
U name Do not predefine name. If both U and D are specified for one name, the U beatsthe D and the
name isnot predefined.
undef Do not predefine any nonstandard macros.
A name(value) Assert (in the same way asthe #assert directive) the predicate name with tokenlist value .
Remember to escape or quote the parentheseson shell command lines. You can use A- to disable
all predefined assertions; it also undefinesall predefined macros.
dM Instead of outputting the result of preprocessing, output a list of #define directivesfor all the
macrosdefined during the execution of the preprocessor, including predefined macros. Thisgives
you a way of finding out what ispredefined in your version of the preprocessor; assuming you have
no file foo.h, the command
touch foo.h; cpp dM foo.h
will show the valuesof any predefined macros.
dD Like dM except in two respects: it doesnot include the predefined macros, and it outputsboth the
#define directivesand the result of preprocessing. Both kindsof output go to the standard output
file.
M[MG] Instead of outputting the result of preprocessing, output a rule suitable for make describing the
dependenciesof the main source file. The preprocessor outputsone make rule containing the
object filename for that source file, a colon, and the namesof all the included files. If there are
many included filesthen the rule issplit into several linesusing \\ (newline).
MG saysto treat missing header filesasgenerated filesand assume they live in the same directory as
the source file. It must be specified in addition to M.
Thisfeature isused in automatic updating of makefiles.
MM[MG] Like M but mention only the filesincluded with #include file . System header filesincluded
with #include < file > are omitted.
MDf i l e Like M but the dependency information iswritten to file. Thisisin addition to compiling the file
asspecified. MD doesnot inhibit ordinary compilation the way M does.
When invoking gcc, do not specify the f i l e argument. gcc will create filenamesmade by replacing
.c with .d at the end of the input filenames.
In Mach, you can use the utility md to merge multiple filesinto a single dependency file suitable for
using with the make command.
MMDf i l e Like M except mention only user header files, not system header files.
H Print the name of each header file used, in addition to other normal activities.
imacros f i l e Processfile asinput, discarding the resulting output, before processing the regular input file.
Because the output generated from file isdiscarded, the only effect of imacros file isto make the
macrosdefined in file available for use in the main input. The preprocessor evaluatesany D and U
optionson the command line before processing imacrosfile.
include f i l e Processf i l e asinput, and include all the resulting output, before processing the regular input file.
-idirafter di r Add the directory di r to the second include path. The directorieson the second include path are
searched when a header file isnot found in any of the directoriesin the main include path (the one
that I addsto).
-iprefix pr ef i x Specify pr ef i x asthe prefix for subsequent iwithprefix options.
-iwithprefix di r Add a directory to the second include path. The directorysname ismade by concatenating prefix
and di r , where prefix wasspecified previously with iprefix.
lang-c Specify the source language. lang-c++ makesthe preprocessor handle C++ comment syntax,
lang-c++ and includesextra default include directoriesfor C++, and lang-objc enablesthe Objective C
lang-objc #import directive. lang-c explicitly turnsoff both of these extensions, and lang-objc++ enables
lang-objc++ both. These optionsare generated by the compiler driver gcc, but not passed from the gcc
command line.
lint Look for commandsto the program checker lint embedded in comments, and emit them preceded
by #pragma lint. For example, the comment /* NOTREACHED */ becomes #pragma lint NOTREACHED.
Thisoption isavailable only when you call cpp directly; gcc will not passit from itscommand line.
cccp, cpp
Part I: User Commands
84
$ Forbid the use of $ in identifiers. Thisisrequired for ANSI conformance. gcc automatically
suppliesthisoption to the preprocessor if you specify ansi, but gcc doesnt recognize the $
option itself; to use it without the other effectsof ansi, you must call the preprocessor directly.
SEE ALSO
cpp entry in info; TheC Preprocessor, Richard M. Stallman.
gcc(1); gcc entry in info; Usingand PortingGNU CC (for version 2.0), Richard M. Stallman.
COPYING
Copyright 1991, 1992, 1993 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim
copiesof thismanual provided the copyright notice and thispermission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
GNU Tools, 30 April 1993
crontab
crontabManipulate per-user crontabs(DillonsCron)
SYNOPSIS
crontab file [-u user ] Replace crontab from file
crontab - [-u user ] Replace crontab from stdin
crontab -l [user ] List crontab for user
crontab -e [user ] Edit crontab for user
crontab -d [user ] Delete crontab for user
crontab -c di r Specify crontab directory
DESCRIPTION
crontab manipulatesthe crontab for a particular user. Only the superuser may specify a different user and/or crontab
directory. Generally, the -e option isused to edit your crontab. crontab will use /usr/bin/vi or the editor specified by your
VISUAL environment variable to edit the crontab.
Unlike other crond/crontabs, thiscrontab doesnot try to do everything under the sun. Frankly, a shell script ismuch more
able to manipulate the environment than cron, and I see no particular reason to use the usersshell (from hispassword entry)
to run cron commandswhen thisrequiresspecial casing of nonuser crontabs, such asthose for UUCP. When a crontab
command isrun, thiscrontab runsit with /bin/sh and setsup only three environment variables: USER, HOME, and SHELL.
crond automatically detectschangesin the time. Reverse-indexed time changeslessthen an hour old will NOT rerun crontab
commandsalready issued in the recovered period. Forward-indexed changeslessthen an hour into the future will issue
missed commandsexactly once. Changesgreater then an hour into the past or future cause crond to resynchronize and not
issue missed commands. No attempt will be made to issue commandslost due to a reboot, and commandsare not reissued if
the previously issued command isstill running. For example, if you have a crontab command sleep 70 that you wish to run
once a minute, cron will only be able to issue the command once every two minutes. If you do not like thisfeature, you can
run your commandsin the background with an &.
85
The crontab format isroughly similar to that used by vixiecron, but without complex features. Individual fieldsmay contain
a time, a time range, a time range with a skip factor, a symbolic range for the day of week and month in year, and additional
subrangesdelimited with commas. Blank linesin the crontab or linesthat begin with a hash (#) are ignored. If you specify
both a day in the month and a day of week, the result iseffectively ORd; the crontab entry will be run on the specified day of
week and on the specified day in the month.
# MIN HOUR DAY MONTH DAYOFWEEK COMMAND
# at 6:10 a.m. every day
10 6 ***date
# every two hours at the top of the hour
0 */2 ***date
# every two hours from 11p.m. to 7a.m., and at 8a.m.
0 23-7/2,8 ***date
# at 11:00 a.m. on the 4th and on every mon, tue, wed
0 11 4 * mon-wed date
# 4:00 a.m. on january 1st
0 4 1 jan *date
# once an hour, all output appended to log file
0 4 1 jan *date>>/var/log/messages 2>&1
The command portion of the line isrun with /bin/sh c <command>, and may therefore contain any valid Bourne shell
command. A common practice isto run your command with exec to keep the processtable uncluttered. It isalso common to
redirect output to a log file. If you do not, and the command generatesoutput on stdout or stderr, the result will be mailed
to the user in question. If you use thismechanism for special users, such asUUCP, you may want to create an aliasfor the
user to direct the mail to someone else, such asroot or postmaster.
Internally, thiscron usesa quick indexing system to reduce CPU overhead when looking for commandsto execute. Several
hundred crontabswith several thousand entriescan be handled without using noticeable CPU resources.
BUGS
Ought to be able to have several crontab filesfor any given user, asan organizational tool.
AUTHOR
Matthew Dillon (dillon@apollo.west.oic.com)
1 May1994
csplit
csplitSplit a file into sectionsdetermined by context lines
SYNOPSIS
csplit [sqkz] [f prefix] [b suffix] [n digits] [prefix=prefix]
[suffixformat=suffix] [digits=digits] [quiet] [silent]
[keep-files] [elideemptyfiles] [help] [version]
file pattern...
DESCRIPTION
Thismanual page documentsthe GNU version of csplit. csplit createszero or more output filescontaining sectionsof the
given input file, or the standard input if the name isgiven. By default, csplit printsthe number of byteswritten to each
output file after it hasbeen created.
csplit
Part I: User Commands
86
The contentsof the output filesare determined by the pattern arguments. An error occursif a pattern argument refersto a
nonexistent line of the input file, such asif no remaining line matchesa given regular expression. After all the given patterns
have been matched, any remaining output iscopied into one last output file. The typesof pattern argumentsare
line Create an output file containing the current line up to (but not including) line line (a positive
integer) of the input file. If followed by a repeat count, also create an output file containing the
next line linesof the input file once for each repeat.
/regexp/[offset] Create an output file containing the current line up to (but not including) the next line of the
input file that containsa match for regexp. The optional offset isa + or followed by a positive
integer. If it isgiven, the input up to the matching line plusor minusoffset isput into the output
file, and the line after that beginsthe next section of input.
%regexp%[offset] Like the previoustype, except that it doesnot create an output file, so that section of the input file
iseffectively ignored.
{repeat-count} Repeat the previouspattern repeat-count (a positive integer) additional times. An asterisk may be
given in place of the (integer) repeat count, in which case the preceding pattern isrepeated asmany
timesasnecessary until the input isexhausted.
The output filenamesconsist of a prefix followed by a suffix. By default, the suffix ismerely an ascending linear sequence of
two-digit decimal numbersstarting with 00 and ranging up to 99; however, thisdefault may be overridden by either the
digits option or by the suffixformat option. (See Options, next.) In any case, concatenating the output filesin sorted
order by filename producesthe original input file, in order. The default output filename prefix isxx.
By default, if csplit encountersan error or receivesa hangup, interrupt, quit, or terminate signal, it removesany output files
that it hascreated so far before it exits.
OPTIONS
f, prefix=pr ef i x Use pr ef i x asthe output filename prefix string.
b, suffixformat=suf f i x Use suf f i x asthe output filename suffix string. When thisoption isspecified, the suffix string
must include exactly one printf(3) style conversion specification (such as%d, possibly including
format specification flags, a field width, a precision specifications, or all of these kindsof
modifiers). The conversion specification must be suitable for converting a binary integer
argument to readable form. Thus, only d, i, u, o, x, and X format specifiersare allowed. The
entire suffix string isgiven (with the current output file number) to sprintf(3) to form the
filename suffixesfor each of the individual output filesin turn. Note that when thisoption is
used, the digits option isignored.
n, digits=di gi t s Use output filenamescontaining numbersthat are di gi t s digitslong instead of the default 2.
k, keep-files Do not remove output fileswhen errorsare encountered.
z, elideemptyfiles Suppressthe generation of zero-length output files. (In caseswhere the section delimitersof the
input file are supposed to mark the first linesof each of the sections, the first output file will
generally be a zero-length file unlessyou use thisoption.) Note that the output file sequence
numberswill alwaysrun consecutively, starting from 0, even in caseswhere zero-length output
sectionsare suppressed due to the use of thisoption.
s, q, silent, quiet Do not print countsof output file sizes.
help Print a usage message and exit with a nonzero status.
version Print version information on standard output, then exit.
GNU Text Utilities
87
ctags
ctagsGeneratestags and (optionally) refs files
SYNOPSIS
ctags [-BSstvraT] f i l esnames...
DESCRIPTION
ctags generatesthe tagsand refsfilesfrom a group of C source files. The tags file isused by the elvis :tag command,
control-] command, and -t option. The refs file issometimesused by the ref(1) program.
Each C source file isscanned for #define statementsand global function definitions. The name of the macro or function
becomesthe name of a tag. For each tag, a line isadded to the tags file that containsthe following:
I The name of the tag
I A tab character
I The name of the file containing the tag
I A tab character
I A way to find the particular line within the file
The f i l enames list will typically be the namesof all C source filesin the current directory, like this:
$ ctags -stv *.[ch]
OPTIONS
-B Normally, ctags enclosesregular expressionsin slashes(/regexp/), which causeselvis to search from the
top of the file. The -B flag causesctags to enclose the regular expressionsin question marks(?regexp?) so
elvis will search backward from the bottom of the file. Thisrarely matters.
-t Include typedefs. A tag will be generated for each user-defined type. Also tagswill be generated for struct
and enum names. Typesare considered to be global if they are defined in a header file, and static if they are
defined in a C source file.
-v Include variable declarations. A tag will be generated for each variable, except for those that are declared
inside the body of a function.
-s Include static tags. ctags will normally put global tagsin the tags file, and silently ignore the static tags.
Thisflag causesboth global and static tagsto be added. The name of a static tag isgenerated by prefixing
the name of the declared item with the name of the file where it isdefined, with a colon in between. For
example, static foo(){} in bar.c resultsin a tag named bar.c:foo.
-S Include static tags, but make them look like global tags. Most tags-aware programsdont like the
filename:tagname tagsproduced by the -s flag, so -S wasadded asan alternative. If elvis and ref are the
only programsthat read the tags file, then you dont need -S; otherwise, you do.
-r Thiscausesctags to generate both tags and refs. Without -r, it would only generate tags.
-a Append to tags, and maybe refs. Normally, ctags overwritesthese fileseach time it isinvoked. Thisflag is
useful when you have too many filesin the current directory for you to list them on a single command
line; it allowsyou to split the argumentsamong several invocations.
-T Thisflag isnt available on all systems. UNIX hasit, but most othersdont. The -T flag preventsctags
from generating a tags file. Thisisuseful when you want to generate a refs without changing tags.
FILES
tags A cross-reference that listseach tag name, the name of the source file that containsit, and a way to locate a
particular line in the source file.
refs The refs file containsthe definitionsfor each tag in the tags file, and very little else. Thisfile can be
useful, for example, when licensing restrictionsprevent you from making the source code to the standard
C library readable by everybody, but you still want everybody to know what argumentsthe library
functionsneed.
ctags
Part I: User Commands
88
BUGS
ctags issensitive to indenting and line breaks. Consequently, it might not discover all of the tagsin a file that isformatted in
an unusual way.
SEE ALSO
elvis(1), refs(1)
AUTHOR
Steve Kirkendall (kirkenda@cs.pdx.edu)
cu
cuCall up another system
SYNOPSIS
cu [ options ] [ system | phone | di r ]
DESCRIPTION
The cu command isused to call up another system and act asa dial in terminal. It can also do simple file transferswith no
error checking.
cu takesa single argument, besidesthe options. If the argument isthe string di r , cu will make a direct connection to the port.
Thismay only be used by userswith write accessto the port, asit permitsreprogramming the modem.
Otherwise, if the argument beginswith a digit, it istaken to be a phone number to call. Otherwise, it istaken to be the name
of a system to call. The z or system option may be used to name a system beginning with a digit, and the c or phone
option may be used to name a phone number that doesnot begin with a digit.
cu locatesa port to use in the UUCP configuration files. If a simple system name isgiven, it will select a port appropriate for
that system. The p, port, l, line, s, and speed optionsmay be used to control the port selection.
When a connection ismade to the remote system, cu forksinto two processes. One readsfrom the port and writesto the
terminal, while the other readsfrom the terminal and writesto the port.
cu providesseveral commandsthat may be used during the conversation. The commandsall begin with an escape character,
initially (tilde). The escape character isonly recognized at the beginning of a line. To send an escape character to the
remote system at the start of a line, it must be entered twice. All commandsare either a single character or a word beginning
with % (percent sign).
cu recognizesthe following commands:
. Terminate the conversation.
! command Run command in a shell. If command isempty, startsup a shell.
$ command Run command, sending the standard output to the remote system.
| command Run command, taking the standard input from the remote system.
+ command Run command, taking the standard input from the remote system and sending the standard
output to the remote system.
#, %br eak Send a break signal, if possible.
c di r ect or y, %cd di r ect or y Change the local directory.
> f i l e Send a file to the remote system. Thisjust dumpsthe file over the communication line. It is
assumed that the remote system isexpecting it.
< Receive a file from the remote system. Thispromptsfor the local filename and for the
remote command to execute to begin the file transfer. It continuesaccepting data until the
contentsof the eofread variable are seen.
89
p from to, %put from to Send a file to a remote UNIX system. Thisrunsthe appropriate commandson the remote
system.
t from to, %take from to Retrieve a file from a remote UNIX system. Thisrunsthe appropriate commandson the
remote system.
s var i abl e val ue Set a cu variable to the given val ue. If val ue isnot given, the variable isset to True.
! var i abl e Set a cu variable to False.
z Suspend the cu session. Thisisonly supported on some systems. On systemsfor which Z
may be used to suspend a job, Z will also suspend the session.
%nostop Turn off XON/XOFF handling.
%stop Turn on XON/XOFF handling.
v List all the variablesand their values.
? List all commands.
cu also supportsseveral variables. They may be listed with the v command, and set with the
s or ! commands.
escape The escape character. Initially (tilde).
delay If thisvariable isTrue, cu will delay for a second after recognizing the escape character before
printing the name of the local system. The default isTrue.
eol The list of characterswhich are considered to finish a line. The escape character isonly
recognized after one of these isseen. The default iscarriage return, U, C, O, D, S, Q, R.
binary Whether to transfer binary data when sending a file. If thisisFalse, then newlinesin the file
being sent are converted to carriage returns. The default isFalse.
binary-prefix A string used before sending a binary character in a file transfer, if the binary variable is
True. The default isZ.
echo-check Whether to check file transfersby examining what the remote system echoesback. This
probably doesnt work very well. The default isFalse.
echonl The character to look for after sending each line in a file. The default iscarriage return.
timeout The timeout to use, in seconds, when looking for a character, either when doing echo
checking or when looking for the echonl character. The default is30.
kill The character to use to delete a line if the echo check fails. The default isU.
resend The number of timesto resend a line if the echo check continuesto fail. The default is10.
eofwrite The string to write after sending a file with the > command. The default isD.
eofread The string to look for when receiving a file with the < command. The default is$, which is
intended to be a typical shell prompt.
verbose Whether to print accumulated information during a file transfer. The default isTrue.
OPTIONS
The following optionsmay be given to cu:
e, parity=even Use even parity.
o, parity=odd Use odd parity.
parity=none Use no parity. No parity isalso used if both e and o are given.
h, halfduplex Echo characterslocally (half-duplex mode).
z syst em, system syst em The system to call.
c phone- number , phone phone- number The phone number to call.
p port, port por t Name the port to use.
a por t Equivalent to port por t .
l l i ne, line l i ne Name the line to use by giving a device name. Thismay be used to dial out on
portsthat are not listed in the UUCP configuration files. Write accessto the device
isrequired.
cu
Part I: User Commands
90
s speed, speed speed The speed (baud rate) to use.
# Where # isa number, equivalent to speed #.
n, prompt Prompt for the phone number to use.
d Enter debugging mode. Equivalent to debug all.
x t ype, debug t ype Turn on particular debugging types. The following typesare recognized: abnormal,
chat, handshake, uucpproto, proto, port, config, spooldir, execute, incoming,
outgoing. Only abnormal, chat, handshake, port, config, incoming and outgoing are
meaningful for cu. Multiple typesmay be given, separated by commas, and the
debug option may appear multiple times. A number may also be given, which will
turn on that many typesfrom the foregoing list; for example, debug 2 is
equivalent to debug abnormal,chat. debug all may be used to turn on all
debugging options.
I f i l e, config f i l e Set configuration file to use. Thisoption may not be available, depending upon
how cu wascompiled.
v, version Report version information and exit.
help Print a help message and exit.
BUGS
Thisprogram doesnot work very well.
FILES
The filename may be changed at compilation time, so thisisonly an approximation. Configuration file:
/usr/lib/uucp/config
AUTHOR
Ian Lance Taylor (ian@airs.com)
Taylor UUCP 1.05
cut
cutRemove sectionsfrom each line of files
SYNOPSIS
cut {b byt e- l i st , bytes=byt e-l i st } [n] [help] [version] [f i l e...]
cut {c char act er - l i s t , characters=char act er - l i s t } [help] [version] [f i l e...]
cut {f f i el d- l i st , fields=f i el d- l i st } [d del i m] [s] [delimiter=del i m]
[only-delimited] [help] [version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of cut. cut printssectionsof each line of each input file, or the standard
input if no filesare given. A filename of - meansstandard input. The sectionsto be printed are selected by the options.
OPTIONS
The byt e- l i st , char act er - l i s t , and f i el d- l i st optionsare one or more numbersor ranges(two numbersseparated by a
dash) separated by commas. The first byte, character, and field are numbered 1. Incomplete rangesmay be given: m means1
m; n meansn through end of line or last field.
91
b, bytes byt e- l i st Print only the bytesin positionslisted in byt e- l i st . Tabsand backspacesare treated like
any other character; they take up one byte.
c, characters char act er - l i s t Print only charactersin positionslisted in char act er - l i s t . The same asb for now, but
internationalization will change that. Tabsand backspacesare treated like any other
character; they take up one character.
f, fields f i el d- l i st Print only the fieldslisted in f i el d- l i st . Fieldsare separated by TAB by default.
d, delimiter del i m For f, fieldsare separated by the first character in del i m instead of by TAB.
n Do not split multibyte characters(no-op for now).
s, only-delimited For f, do not print linesthat do not contain the field separator character.
help Print a usage message and exit with a nonzero status.
version Print version information on standard output then exit.
GNU Text Utilities
cvs
cvsConcurrent VersionsSystem
SYNOPSIS
cvs [ cvs_options ] cvs-command [ command_options ][command_args ]
DESCRIPTION
cvs isa front end to the rcs(1) revision control system, which extendsthe notion of revision control from a collection of files
in a single directory to a hierarchical collection of directoriesconsisting of revision controlled files. These directoriesand files
can be combined together to form a software release. cvs providesthe functionsnecessary to manage these software releases
and to control the concurrent editing of source filesamong multiple software developers.
cvs keepsa single copy of the master sources. Thiscopy iscalled the source repository; it containsall the information to
permit extracting previoussoftware releasesat any time based on either a symbolic revision tag, or a date in the past.
ESSENTIAL COMMANDS
cvs providesa rich variety of commands(cvs_command in the Synopsis), each of which often hasa wealth of options, to satisfy
the many needsof source management in distributed environments. However, you dont have to master every detail to do
useful work with cvs; in fact, five commandsare sufficient to use (and contribute to) the source repository.
cvs checkout modul es. . . A necessary preliminary for most cvs work: createsyour private copy of the source for
modules(named collectionsof source; you can also use a path relative to the source
repository here). You can work with thiscopy without interfering with others work. At
least one subdirectory level isalwayscreated.
cvs update Execute thiscommand from within your private source directory when you wish to
update your copiesof source filesfrom changesthat other developershave made to the
source in the repository.
cvs add f i l e. . . Use thiscommand to enroll new filesin cvs recordsof your working directory. The files
will be added to the repository the next time you run cvs commit. Note: You should use
the cvs import command to bootstrap new sourcesinto the source repository. cvs add is
only used for new filesto an already checked-out module.
cvs remove f i l e. . . Use thiscommand (after erasing any fileslisted) to declare that you wish to eliminate
filesfrom the repository. The removal doesnot affect othersuntil you run cvs commit.
cvs commit f i l e. . . Use thiscommand when you wish to publish your changesto other developers, by
incorporating them in the source repository.
cvs
Part I: User Commands
92
OPTIONS
The cvs command line can include cvs_options, which apply to the overall cvs program; a cvs_command, which specifiesa
particular action on the source repository; and command_options and command_arguments to fully specify what the cvs_command
will do.
WARNING
You must be careful of precisely where you place optionsrelative to the cvs_command. The same option can mean different
thingsdepending on whether it isin the cvs_options position (to the left of a cvs command) or in the command_options
position (to the right of a cvs command).
There are only two situationswhere you may omit cvs_command: cvs H or cvs help elicitsa list of available commands, and
cvs v or cvs version displaysversion information on cvs itself.
CVS OPTIONS
Asof release 1.6, cvs supportsGNU style long optionsaswell asshort options. Only a few long optionsare currently
supported; these are listed in bracketsafter the short optionswhose functionsthey duplicate.
Use these optionsto control the overall cvs program:
H [help] Display usage information about the specified cvs command (but do not actually execute the
command). If you dont specify a command name, cvs H displaysa summary of all the
commandsavailable.
Q Causesthe command to be really quiet; the command will generate output only for serious
problems.
q Causesthe command to be somewhat quiet; informational messages, such asreportsof
recursion through subdirectories, are suppressed.
b bi ndi r Use bi ndi r asthe directory where RCS programsare located. Overridesthe setting of the RCSBIN
environment variable. Thisvalue should be specified asan absolute pathname.
d CVS_r oot _di r ect or y Use CVS_r oot _di r ect or y asthe root directory pathname of the master RCS source repository.
Overridesthe setting of the CVS-ROOT environment variable. Thisvalue should be specified asan
absolute pathname.
e edi t or Use edi t or to enter revision log information. Overridesthe setting of the CVSEDITOR and the
EDITOR environment variables.
f Do not read the cvs startup file (/.cvsrc).
l Do not log the cvs_command in the command history (but execute it anyway). See the descrip-
tion of the history command for information on command history.
n Do not change any files. Attempt to execute the cvs_command, but only to issue reports; do
not remove, update, or merge any existing files, or create any new files.
t Trace program execution; display messagesshowing the stepsof cvs activity. Particularly useful
with n to explore the potential impact of an unfamiliar command.
-r Makesnew working filesread-only. Same effect asif the CVS-READ environment variable isset.
v [version] Displaysversion and copyright information for cvs.
w Makesnew working filesread-write (default). Overridesthe setting of the CVSREAD environment
variable.
z compr essi onl evel When transferring filesacrossthe network use gzip with compression level compr essi onl evel to
compressand decompressdata asit istransferred. Requiresthe presence of the GNU gzip
program in the current search path at both endsof the link.
93
USAGE
Except when requesting general help with cvs H, you must specify a cvs_command to cvs to select a specific release control
function to perform. Each cvs command acceptsitsown collection of optionsand arguments. However, many optionsare
available acrossseveral commands. You can display a usage summary for each command by specifying the H option with the
command.
CVS STARTUP FILE
Normally, when cvs startsup, it readsthe .cvsrc file from the home directory of the user reading it. Thisstartup procedure
can be turned off with the f flag.
The .cvsrc file listscvs commandswith a list of arguments, one command per line. For example, the following line in
.cvsrc:
diff c
will mean that the cvs diff command will alwaysbe passed the c option in addition to any other optionsthat are specified
in the command line (in thiscase, it will have the effect of producing context sensitive diffsfor all executionsof cvs diff ).
CVS COMMAND SUMMARY
Here are brief descriptionsof all the cvs commands:
add Add a new file or directory to the repository, pending a cvs commit on the same file. Can only be done
from within sourcescreated by a previouscvs checkout invocation. Use cvs import to place whole new
hierarchiesof sourcesunder cvs control. (Doesnot directly affect repository; changesworking
directory.)
admin Execute RCS control functionson the source repository. (Changesrepository directly; usesworking
directory without changing it.)
checkout Make a working directory of source filesfor editing. (Createsor changesworking directory.)
commit Apply to the source repository changes, additions, and deletionsfrom your working directory.
(Changesrepository.)
diff Show differencesbetween filesin working directory and source repository, or between two revisionsin
source repository. (Doesnot change either repository or working directory.)
export Prepare copiesof a set of source filesfor shipment off site. Differsfrom cvs checkout in that no cvs
administrative directoriesare created (and therefore cvs commit cannot be executed from a directory
prepared with cvs export), and a symbolic tag must be specified. (Doesnot change repository; creates
directory similar to working directories).
history Show reportson cvs commandsthat you or othershave executed on a particular file or directory in the
source repository. (Doesnot change repository or working directory.) History logsare kept only if
enabled by creation of the $CVSROOT/CVSROOT/history file; see cvs(5).
import Incorporate a set of updatesfrom off-site into the source repository, asa vendor branch. (Changes
repository.)
log Display RCS log information. (Doesnot change repository or working directory.)
rdiff Prepare a collection of diffs asa patch file between two releasesin the repository. (Doesnot change
repository or working directory.)
release Cancel a cvs checkout, abandoning any changes. (Can delete working directory; no effect on
repository.)
remove Remove filesfrom the source repository, pending a cvs commit on the same files. (Doesnot directly
affect repository; changesworking directory.)
rtag Explicitly specify a symbolic tag for particular revisionsof filesin the source repository. See also cvs
tag. (Changesrepository directly; doesnot require or affect working directory.)
status Show current statusof files: latest version, version in working directory, whether working version has
been edited and, optionally, symbolic tagsin the RCS file. (Doesnot change repository or working
directory.)
cvs
Part I: User Commands
94
tag Specify a symbolic tag for filesin the repository. By default, tagsthe revisionsthat were last synchro-
nized with your working directory. (Changesrepository directly; usesworking directory without
changing it.)
update Bring your working directory up to date with changesfrom the repository. Mergesare performed
automatically when possible; a warning isissued if manual resolution isrequired for conflicting
changes. (Changesworking directory; doesnot change repository.)
COMMON COMMAND OPTIONS
Thissection describesthe command_options that are available acrossseveral cvs commands. Not all commandssupport all of
these options; each option isonly supported for commandswhere it makessense. However, when a command hasone of
these optionsyou can count on the same meaning for the option asin other commands. (Other command options, which
are listed with the individual commands, may have different meaningsfrom one cvs command to another.)
WARNING
The history command isan exception; it supportsmany optionsthat conflict even with these standard options.
D dat e Use the most recent revision no later than date_spec (a single argument, date description specifying a
date in the past). A wide variety of date formatsare supported by the underlying RCS facilities, similar
to those described in co(1), but not exactly the same. The date_spec isinterpreted asbeing in the local
time zone, unlessa specific time zone isspecified. The specification issticky when you use it to make
a private copy of a source file; that is, when you get a working file using D, cvs recordsthe date you
specified, so that further updatesin the same directory will use the same date (unlessyou explicitly
override it; see the description of the update command). D isavailable with the checkout, diff, history,
export, rdiff, rtag, and update commands. Examplesof valid date specificationsinclude the following:
1 month ago
2 hoursago
400000 secondsago
last year
last Monday
yesterday
a fortnight ago
3/31/92 10:00:07 PST
January 23, 1987 10:05pm
22:00 GMT
f When you specify a particular date or tag to cvs commands, they normally ignore filesthat do not
contain the tag (or did not exist on the date) that you specified. Use the f option if you want files
retrieved even when there isno match for the tag or date. (The most recent version isused in this
situation.) f isavailable with these commands: checkout, export, rdiff, rtag, and update.
H Help; describe the optionsavailable for thiscommand. Thisisthe only option supported for all cvs
commands.
k kf l ag Alter the default RCS processing of keywords; all the k optionsdescribed in co(1) are available. The k
option isavailable with the add, checkout, diff, export, rdiff, and update commands. Your kf l ag
specification issticky when you use it to create a private copy of a source file; that is, when you use
thisoption with the checkout or update commands, cvs associatesyour selected kf l ag with the file, and
continuesto use it with future update commandson the same file until you specify otherwise.
Some of the more useful kf l agsare ko and kb (for binary files, only compatible with RCS version 5.7
or later), and kv, which isuseful for an export where you wish to retain keyword information after an
import at some other site.
95
l Local; run only in current working directory, rather than recurring through subdirectories. Available
with the following commands: checkout, commit, diff, export, remove, rdiff, rtag, status, tag, and
update.
WARNING
Thisisnot the same asthe overall cvs l option, which you can specify to the left of a cvs command.
n Do not run any checkout/commit/tag/update program. (A program can be specified to run on each of
these activities, in the modulesdatabase; thisoption bypassesit.) Available with the checkout, commit,
export, and rtag commands.
WARNING
Thisisnot the same asthe overall cvs n option, which you can specify to the left of a cvs command.
P Prune (remove) directoriesthat are empty after being updated, on checkout, or update. Normally, an
empty directory (one that isvoid of revision-controlled files) isleft alone. Specifying P will cause these
directoriesto be silently removed from your checked-out sources. Thisdoesnot remove the directory
from the repository, only from your checked out copy. Note that thisoption isimplied by the -r or D
optionsof checkout and export.
p Pipe the filesretrieved from the repository to standard output, rather than writing them in the current
directory. Available with the checkout and update commands.
-r tag Use the revision specified by the tag argument instead of the default head revision. Aswell asarbitrary
tagsdefined with the tag or rtag command, two special tagsare alwaysavailable: HEAD refersto the
most recent version available in the repository, and BASE refersto the revision you last checked out into
the current working directory. The tag specification issticky when you use thisoption with cvs
checkout or cvs update to make your own copy of a file: cvs remembersthe tag and continuesto use it
on future update commands, until you specify otherwise. tag can be either a symbolic or numeric tag,
in RCS fashion. Specifying the q global option along with the -r command option isoften useful, to
suppressthe warning messageswhen the RCS file doesnot contain the specified tag. -r isavailable
with the checkout, commit, diff, history, export, rdiff, rtag, and update commands.
WARNING
Thisisnot the same asthe overall cvs -r option, which you can specify to the left of a cvs command.
cvs COMMANDS
Here (finally) are detailson all the cvs commandsand the optionseach accepts. The summary linesat the top of each
commandsdescription highlight three kindsof things:
Command Optionsand Arguments Special optionsare described in detail; common command optionsmay appear only
in the summary line.
Working Directory, or Repository? Some cvs commandsrequire a working directory to operate; some require a
repository. Also, some commandschange the repository, some change the working
directory, and some change nothing.
Synonyms Many commandshave synonyms, which you may find easier to remember (or type)
than the principal name.
cvs
Part I: User Commands
96
I add [k kf l ag][m message] f i l es ...
Requires: Repository, working directory
Changes: Working directory
Synonym: new
Use the add command to create a new file or directory in the RCS source repository. The filesor directoriesspecified with
add must already exist in the current directory (which must have been created with the checkout command). To add a whole
new directory hierarchy to the source repository (for example, filesreceived from a third-party vendor), use the cvs import
command instead.
If the argument to cvs add refersto an immediate subdirectory, the directory iscreated at the correct place in the RCS source
repository, and the necessary cvs administration filesare created in your working directory. If the directory already existsin
the source repository, cvs add still createsthe administration filesin your version of the directory. Thisallowsyou to use cvs
add to add a particular directory to your private sourceseven if someone else created that directory after your checkout of the
sources. You can do the following:
example% mkdir new_directory
example% cvs add new_directory
example% cvs update new_directory
An alternate approach using cvs update might be:
example% cvs update -d new_directory
(To add any available new directoriesto your working directory, itsprobably simpler to use cvs checkout or cvs update -d.)
The added filesare not placed in the RCS source repository until you use cvs commit to make the change permanent. Doing
a cvs add on a file that wasremoved with the cvs remove command will resurrect the file, if no cvs commit command
intervened.
You will have the opportunity to specify a logging message, asusual, when you use cvs commit to make the new file
permanent. If youd like to have another logging message associated with just creation of the file (for example, to describe the
filespurpose), you can specify it with the m message option to the add command.
The -k kf l ag option specifiesthe default way that thisfile will be checked out. The kf l ag argument isstored in the RCS file
and can be changed with cvs admin. Specifying -ko isuseful for checking in binariesthat shouldnt have the RCS id strings
expanded.
I admin [r cs- opt i ons] f i l es...
Requires: Repository, working directory
Changes: Repository
Synonym: rcs
Thisisthe cvs interface to assorted administrative RCS facilities, documented in rcs(1). cvs admin simply passesall its
optionsand argumentsto the rcs command; it doesno filtering or other processing. Thiscommand doeswork recursively,
however, so extreme care should be used.
I checkout [options] modul es ...
Requires: Repository
Changes: Working directory
Synonyms: co, get
Make a working directory containing copiesof the source filesspecified by modules. You must execute cvs checkout before
using most of the other cvs commands, since most of them operate on your working directory.
modul es are either symbolic names[themselvesdefined asthe module modules in the source repository; see cvs(5)] for some
collection of source directoriesand files, or pathsto directoriesor filesin the repository.
Depending on the modulesyou specify, checkout may recursively create directoriesand populate them with the appropriate
source files. You can then edit these source filesat any time (regardlessof whether other software developersare editing their
97
own copiesof the sources); update them to include new changesapplied by othersto the source repository; or commit your
work asa permanent change to the RCS repository.
Note that checkout isused to create directories. The top-level directory created isalwaysadded to the directory where
checkout isinvoked, and usually hasthe same name asthe specified module. In the case of a module alias, the created
subdirectory may have a different name, but you can be sure that it will be a subdirectory, and that checkout will show the
relative path leading to each file asit isextracted into your private work area (unlessyou specify the Q global option).
Running cvs checkout on a directory that wasalready built by a prior checkout isalso permitted, and hasthe same effect as
specifying the d option to the update command described later.
The optionspermitted with cvs checkout include the standard command optionsP, f, k kflag, l, n, p, -r tag, and D
date. In addition to those, you can use several special command optionswith checkout, asdetailed in the following para-
graphs.
Use the A option to reset any sticky tags, dates, or k options. (If you get a working file using one of the -r, D, or k
options, cvs remembersthe corresponding tag, date, or kflag and continuesusing it on future updates; use the A option to
make cvs forget these specifications, and retrieve the head version of the file).
The j branch option mergesthe changesmade between the resulting revision and the revision that it isbased on (for
example, if the tag refersto a branch, cvs will merge all changesmade in that branch into your working file).
With two -j options, cvs will merge in the changesbetween the two respective revisions. Thiscan be used to remove a
certain delta from your working file.
In addition, each -j option can contain on optional date specification which, when used with branches, can limit the chosen
revision to one within a specific date. An optional date isspecified by adding a colon (:) to the tag. An example might be
what cvs import tellsyou to do when you have just imported sourcesthat have conflictswith local changes:
example% cvs checkout -jTAG:yesterday -jTAG module
Use the N option with d di r to avoid shortening module pathsin your working directory. (Normally, cvs shortenspathsas
much aspossible when you specify an explicit target directory.)
Use the c option to copy the module file, sorted, to the standard output, instead of creating or modifying any filesor
directoriesin your working directory.
Use the d di r option to create a directory called di r for the working files, instead of using the module name. Unlessyou
also use N, the pathscreated under dir will be asshort aspossible.
Use the s option to display per-module statusinformation stored with the s option within the modulesfile.
I commit [lnR][m log_message | f file][-r revision][f i l es...]
Requires: Working directory, repository
Changes: Repository
Synonym: ci
Use cvs commit when you want to incorporate changesfrom your working source filesinto the general source repository.
If you dont specify particular filesto commit, all of the filesin your working current directory are examined. commit is
careful to change in the repository only those filesthat you have really changed. By default (or if you explicitly specify the -r
option), filesin subdirectoriesare also examined and committed if they have changed; you can use the l option to limit
commit to the current directory only. Sometimesyou may want to force a file to be committed even though it isunchanged;
thisisachieved with the f flag, which also hasthe effect of disabling recursion (you can turn it back on with R, of course).
commit verifiesthat the selected filesare up-to-date with the current revisionsin the source repository; it will notify you, and
exit without committing, if any of the specified filesmust be made current first with cvs update. commit doesnot call the
update command for you, but rather leavesthat for you to do when the time isright.
When all iswell, an editor isinvoked to allow you to enter a log message that will be written to one or more logging
programsand placed in the RCS source repository file. You can instead specify the log message on the command line with
cvs
Part I: User Commands
98
the m option, thussuppressing the editor invocation, or use the F option to specify that the argument file containsthe log
message.
The -r option can be used to commit to a particular symbolic or numeric revision within the RCS file. For example, to bring
all your filesup to the RCS revision 3.0 (including those that havent changed), you might use
example% cvs commit -r3.0
cvs will only allow you to commit to a revision that ison the main trunk (a revision with a single dot). However, you can
also commit to a branch revision (one that hasan even number of dots) with the -r option. To create a branch revision, one
typically use the b option of the rtag or tag commands. Then, either checkout or update can be used to base your sourceson
the newly created branch. From that point on, all commit changesmade within these working sourceswill be automatically
added to a branch revision, thereby not perturbing mainline development in any way. For example, if you had to create a
patch to the 1.2 version of the product, even though the 2.0 version isalready under development, you might use this:
example% cvs rtag -b -rFCS1_2 FCS1_2 Patch product_module
example% cvs checkout -rFCS1_2_Patch product module
example% cd product module
[[ hack away ]]
example% cvs commit
Say you have been working on some extremely experimental software, based on whatever revision you happened to checkout
last week. If othersin your group would like to work on thissoftware with you, but without disturbing mainline develop-
ment, you could commit your change to a new branch. Otherscan then check out your experimental stuff and utilize the full
benefit of cvs conflict resolution. The scenario might look like this:
example% cvs tag -b EXPR1
example% cvs update -rEXPR1
[[ hack away ]]
example% cvs commit
Otherswould simply do cvs checkout -rEXPR1 what ever _modul e to work with you on the experimental change.
I diff [kl][r csdi f f _opt i ons][[-r r ev1 | D dat e1][-r r ev2 | D dat e2]] [f i l es...]
Requires: Working directory, repository
Changes: Nothing
You can compare your working fileswith revisionsin the source repository, with the cvs diff command. If you dont specify
a particular revision, your filesare compared with the revisionsthey were based on. You can also use the standard cvs
command option -r to specify a particular revision to compare your fileswith. Finally, if you use -r twice, you can see
differencesbetween two revisionsin the repository. You can also specify D optionsto diff against a revision in the past. The
-r and D optionscan be mixed together with at most two optionsever specified.
See rcsdiff(1) for a list of other accepted options.
If you dont specify any files, diff will display differencesfor all those filesin the current directory (and itssubdirectories,
unlessyou use the standard option l) that differ from the corresponding revision in the source repository (that is, filesthat
you have changed), or that differ from the revision specified.
I export [f lNnQq] -r r ev | D dat e [d di r ][k kf l ag] modul e...
Requires: Repository
Changes: Current directory
Thiscommand isa variant of cvs checkout; use it when you want a copy of the source for modul e without the cvs administra-
tive directories. For example, you might use cvs export to prepare source for shipment off-site. Thiscommand requiresthat
you specify a date or tag (with D or -r), so that you can count on reproducing the source you ship to others.
The only nonstandard optionsare d di r (write the source into directory di r ) and N (dont shorten module paths). These
have the same meaningsasthe same optionsin cvs checkout.
99
The kv option isuseful when export isused. Thiscausesany RCSkeywordsto be expanded such that an import done at
some other site will not lose the keyword revision information. Other kf l ag optionsmay be used with cvs export and are
described in co(1).
I history [- r epor t ][f l ags][opt i ons ar gs][f i l es ...]
Requires: The file $CVSROOT/CVSROOT/history
Changes: Nothing
cvs keepsa history file that trackseach use of the checkout, commit, rtag, update, and release commands. You can use cvs
history to display thisinformation in variousformats.
WARNING
cvs history usesf, l, n, and p in waysthat conflict with the descriptionsin Common Command Options, earlier
in thismanual page.
Several options(shown as[r epor t ] in the preceding bulleted code line) control what kind of report isgenerated:
c Report on each time commit wasused (that is, each time the repository wasmodified).
m modul e Report on a particular module. (You can meaningfully use m more than once on the command line.)
o Report on checked-out modules.
T Report on all tags.
x t ype Extract a particular set of record typesX from the cvs history. The typesare indicated by single letters,
which you may specify in combination. Certain commandshave a single record type: check-out (type
O), release (type F), and rtag (type T). One of four record typesmay result from an update: W, when the
working copy of a file isdeleted during update (because it wasgone from the repository); U, when a
working file wascopied from the repository; G, when a merge wasnecessary and it succeeded; and C,
when a merge wasnecessary but collisionswere detected (requiring manual merging). Finally, one of
three record typesresultsfrom commit: M, when a file wasmodified; A, when a file isfirst added; and R,
when a file isremoved.
e Everything (all record types); equivalent to specifying xMACFROGWUT.
z zone Use time zone zone when outputting history records. The zone name LT standsfor local time; numeric
offsetsstand for hoursand minutesahead of UTC. For example, +0530 standsfor 5 hoursand 30
minutesahead of (that is, east of) UTC.
The optionsshown asf l ags constrain the report without requiring option arguments:
a Show data for all users. (The default isto show data only for the user executing cvs history.)
l Show last modification only.
w Show only the recordsfor modificationsdone from the same working directory where cvs history is
executing.
The optionsshown asopt i ons ar gs constrain the report based on an argument:
b st r Show data back to a record containing the string str in either the module name, the filename, or the
repository path.
D dat e Show data since dat e.
p r eposi t or y Show data for a particular source repository (you can specify several p optionson the same command
line).
-r r ev Show recordsreferring to revisionssince the revision or tag named r ev appearsin individual RCS files.
Each RCS file issearched for the revision or tag.
t t ag Show recordssince tag t ag waslast added to the history file. Thisdiffersfrom the -r flag in that it
readsonly the history file, not the RCS files, and ismuch faster.
u name Show recordsfor username.
cvs
Part I: User Commands
100
I import [opt i ons] r eposi t or y vendor t ag r el easet ag ...
Requires: Repository, source distribution directory
Changes: Repository
Use cvs import to incorporate an entire source distribution from an outside source (for example, a source vendor) into your
source repository directory. You can use thiscommand both for initial creation of a repository, and for wholesale updatesto
the module form the outside source.
The repository argument givesa directory name (or a path to a directory) under the CVS root directory for repositories; if
the directory did not exist, import createsit.
When you use import for updatesto source that hasbeen modified in your source repository (since a prior import), it will
notify you of any filesthat conflict in the two branchesof development; use cvs checkout -j to reconcile the differences, as
import instructsyou to do.
By default, certain filenamesare ignored during cvs import: namesassociated with CVS administration, or with other
common source control systems; common namesfor patch files, object files, archive files, and editor backup files; and other
namesthat are usually artifactsof assorted utilities. Currently, the default list of ignored filesincludesfilesmatching these
names:
RCSLOG RCS SCCS
CVS* cvslog.*
tags TAGS
.make.state .nse_depinfo
#* .#* ,
.old *.bak *.BAK *.orig *.rej .del*
.a *.o *.so *.Z *.elc *.ln core
The outside source issaved in a first-level RCS branch, by default 1.1.1. Updatesare leavesof thisbranch; for example, files
from the first imported collection of source will be revision 1.1.1.1, then filesfrom the first imported update will be revision
1.1.1.2, and so on.
At least three argumentsare required. r eposi t or y isneeded to identify the collection of source. vendor t ag isa tag for the
entire branch (for example, for 1.1.1). You must also specify at least one r el easet ag to identify the filesat the leavescreated
each time you execute cvs import.
One of the standard cvs command optionsisavailable: m message. If you do not specify a logging message with m, your
editor isinvoked (aswith commit) to allow you to enter one.
There are three additional special options.
Use d to specify that each filestime of last modification should be used for the checkin date and time.
Use b br anch to specify a first-level branch other than 1.1.1.
Use I name to specify filenamesthat should be ignored during import. You can use thisoption repeatedly. To avoid
ignoring any filesat all (even those ignored by default), specify I !.
I log [l] r l og- opt i ons [f i l es...]
Requires: Repository, working directory
Changes: Nothing
Synonym: rlog
Display log information for f i l es. cvs log callsthe RCS utility rlog; all the optionsdescribed in rlog(1) are available.
Among the more useful rlog optionsare h to display only the header (including tag definitions, but omitting most of the
full log); -r to select logson particular revisionsor rangesof revisions; and d to select particular datesor date ranges. See
rlog(1) for full explanations. Thiscommand isrecursive by default, unlessthe l option isspecified.
101
I rdiff [f l ags][V vn][r t |D d [r t 2|D d2]] modul es...
Requires: Repository
Changes: Nothing
Synonym: patch
Buildsa Larry Wall format patch(1) file between two releasesthat can be fed directly into the patch program to bring an old
release up-to-date with the new release. (Thisisone of the few cvs commandsthat operatesdirectly from the repository and
doesnt require a prior checkout.) The diff output issent to the standard output device. You can specify (using the standard
-r and D options) any combination of one or two revisionsor dates. If only one revision or date isspecified, the patch file
reflectsdifferencesbetween that revision or date and the current head revisionsin the RCS file.
Note that if the software release affected iscontained in more than one directory, then it may be necessary to specify the p
option to the patch command when patching the old sources, so that patch isable to find the filesthat are located in other
directories.
If you use the option V vn, RCS keywordsare expanded according to the rulescurrent in RCS version vn (the expansion
format changed with RCS version 5).
The standard option f l ags f and l are available with thiscommand. There are also several special optionsf l ags.
If you use the s option, no patch output isproduced. Instead, a summary of the changed or added filesbetween the two
releasesissent to the standard output device. Thisisuseful for finding out, for example, which fileshave changed between
two datesor revisions.
If you use the t option, a diff of the top two revisionsissent to the standard output device. Thisismost useful for seeing
what the last change to a file was.
If you use the u option, the patch output usesthe newer unidiff format for context diffs.
You can use c to explicitly specify the diff c form of context diffs(which isthe default), if you like.
I release [dQq] modul es ...
Requires: Working directory
Changes: Working directory, history log
Thiscommand ismeant to safely cancel the effect of cvs checkout. Since cvs doesnt lock files, it isnt strictly necessary to use
thiscommand. You can alwayssimply delete your working directory, if you like; but you risk losing changesyou may have
forgotten, and you leave no trace in the cvs history file that youve abandoned your checkout.
Use cvs release to avoid these problems. Thiscommand checksthat no uncommitted changesare present; that you are
executing it from immediately above, or inside, a cvs working directory; and that the repository recorded for your filesisthe
same asthe repository defined in the module database.
If all these conditionsare true, cvs release leavesa record of itsexecution (attesting to your intentionally abandoning your
checkout) in the cvs history log.
You can use the d flag to request that your working copiesof the source filesbe deleted if the release succeeds.
I remove [lR][f i l es...]
Requires: Working directory
Changes: Working directory
Synonyms: rm, delete
Use thiscommand to declare that you wish to remove filesfrom the source repository. Like most cvs commands, cvs remove
workson filesin your working directory, not directly on the repository. Asa safeguard, it also requiresthat you first erase the
specified filesfrom your working directory.
The filesare not actually removed until you apply your changesto the repository with commit; at that point, the correspond-
ing RCS filesin the source repository are moved into the Attic directory (also within the source repository).
cvs
Part I: User Commands
102
Thiscommand isrecursive by default, scheduling all physically removed filesthat it findsfor removal by the next commit. Use
the l option to avoid thisrecursion, or just specify that actual filesthat you wish remove to consider.
I rtag [f alnRQq][b][d][r t ag | D dat e] symbol i c_t ag modul es...
Requires: Repository
Changes: Repository
Synonym: rfreeze
You can use thiscommand to assign symbolic tagsto particular, explicitly specified source versionsin the repository. cvs
rtag worksdirectly on the repository contents(and requiresno prior checkout). Use cvs tag instead, to base the selection of
versionsto tag on the contentsof your working directory.
In general, tags(often the symbolic namesof software distributions) should not be removed, but the d option isavailable as
a meansto remove completely obsolete symbolic namesif necessary (asmight be the case for an Alpha release, say).
cvs rtag will not move a tag that already exists. With the F option, however, cvs rtag will relocate any instance of
symbolic_tag that already existson that file to the new repository versions. Without the F option, attempting to use cvs
rtag to apply a tag that already existson that file will produce an error message.
The -b option makesthe tag a branch tag, allowing concurrent, isolated development. Thisismost useful for creating a patch
to a previously released software distribution.
You can use the standard -r and D optionsto tag only those filesthat already contain a certain tag. Thismethod would be
used to rename a tag: tag only the filesidentified by the old tag, then delete the old tag, leaving the new tag on exactly the
same filesasthe old tag.
rtag executesrecursively by default, tagging all subdirectoriesof modulesyou specify in the argument. You can restrict its
operation to top-level directorieswith the standard l option; or you can explicitly request recursion with R.
The modulesdatabase can specify a program to execute whenever a tag isspecified; a typical use isto send electronic mail to
a group of interested parties. If you want to bypassthat program, use the standard n option.
Use the a option to have rtag look in the Attic for removed filesthat contain the specified tag. The tag isremoved from
these files, which makesit convenient to reuse a symbolic tag asdevelopment continues(and filesget removed from the
upcoming distribution).
I status [lRqQ][v][f i l es ...]
Requires: Working directory, repository
Changes: Nothing
Display a brief report on the current statusof fileswith respect to the source repository, including any sticky tags, dates, or k
options. (Sticky optionswill restrict how cvs update operatesuntil you reset them; see the description of cvs update A....
You can also use thiscommand to anticipate the potential impact of a cvs update on your working source directory. If you
do not specify any filesexplicitly, reportsare shown for all filesthat cvs hasplaced in your working directory. You can limit
the scope of thissearch to the current directory itself (not itssubdirectories) with the standard l option flag; or you can
explicitly request recursive statusreportswith the R option.
The v option causesthe symbolic tagsfor the RCS file to be displayed aswell.
I tag [lQqR][F][b][d][r t ag | D dat e][f] symbolic_tag [files ...]
Requires: Working directory, repository
Changes: Repository
Synonym: freeze
Use thiscommand to assign symbolic tagsto the nearest repository versionsto your working sources. The tagsare applied
immediately to the repository, aswith rtag. One use for tagsisto record a snapshot of the current sourceswhen the
software freeze date of a project arrives. Asbugsare fixed after the freeze date, only those changed sourcesthat are to be part
of the release need be retagged.
103
The symbolic tagsare meant to permanently record which revisionsof which fileswere used in creating a software distribu-
tion. The checkout, export, and update commandsallow you to extract an exact copy of a tagged release at any time in the
future, regardlessof whether fileshave been changed, added, or removed since the release wastagged.
You can use the standard -r and D optionsto tag only those filesthat already contain a certain tag. Thismethod would be
used to rename a tag: tag only the filesidentified by the old tag, then delete the old tag, leaving the new tag on exactly the
same filesasthe old tag.
Specifying the f flag in addition to the -r or D flagswill tag those filesnamed on the command line even if they do not
contain the old tag or did not exist on the specified date.
By default (without a -r or D flag), the versionsto be tagged are supplied implicitly by the cvs recordsof your working files
history rather than applied explicitly.
If you use cvs tag d symbolic tag..., the symbolic tag you specify isdeleted instead of being added.
WARNING
Be very certain of your ground before you delete a tag; doing thiseffectively discardssome historical information, which
may later turn out to have been valuable.
cvs tag will not move a tag that already exists. With the F option, however, cvs tag will relocate any instance of symbolic
tag that already existson that file to the new repository versions. Without the F option, attempting to use cvs tag to apply a
tag that already existson that file will produce an error message.
The -b option makesthe tag a branch tag, allowing concurrent, isolated development. Thisismost useful for creating a patch
to a previously released software distribution.
Normally, tag executesrecursively through subdirectories; you can prevent thisby using the standard l option, or specify
the recursion explicitly by using R.
I update [Adf lPpQqR][d][r t ag|D dat e] f i l es ...
Requires: Repository, working directory
Changes: Working directory
After youve run checkout to create your private copy of source from the common repository, other developerswill continue
changing the central source. From time to time, when it isconvenient in your development process, you can use the update
command from within your working directory to reconcile your work with any revisionsapplied to the source repository
since your last checkout or update.
update keepsyou informed of itsprogressby printing a line for each file, prefaced with one of the charactersU, A, R, M, C, or ?
to indicate the statusof the file:
U f i l e The file wasbrought up-to-date with respect to the repository. Thisisdone for any file that existsin
the repository but not in your source, and for filesthat you havent changed but are not the most
recent versionsavailable in the repository.
A f i l e The file hasbeen added to your private copy of the sources, and will be added to the RCS source
repository when you run cvs commit on the file. Thisisa reminder to you that the file needsto be
committed.
R f i l e The file hasbeen removed from your private copy of the sources, and will be removed from the RCS
source repository when you run cvs commit on the file. Thisisa reminder to you that the file needsto
be committed.
M f i l e The file ismodified in your working directory. M can indicate one of two statesfor a file youre working
on: either there were no modificationsto the same file in the repository, so that your file remainsas
you last saw it; or there were modificationsin the repository aswell asin your copy, but they were
merged successfully, without conflict, in your working directory.
cvs
Part I: User Commands
104
C f i l e A conflict wasdetected while trying to merge your changesto f i l e with changesfrom the source
repository. f i l e (the copy in your working directory) isnow the output of the rcsmerge(1) command
on the two versions; an unmodified copy of your file isalso in your working directory, with the name
.#file.version, where version isthe RCSrevision that your modified file started from. (Note that
some systemsautomatically purge filesthat begin with .# if they have not been accessed for a few days.
If you intend to keep a copy of your original file, it isa very good idea to rename it.)
? f i l e f i l e isin your working directory, but doesnot correspond to anything in the source repository, and is
not in the list of filesfor cvs to ignore; see the description of the I option.
Use the A option to reset any sticky tags, dates, or k options. (If you get a working copy of a file by using one of the -r, D,
or k options, cvs remembersthe corresponding tag, date, or kflag and continuesusing it on future updates; use the A
option to make cvs forget these specifications, and retrieve the head version of the file).
The jbranch option mergesthe changesmade between the resulting revision and the revision that it isbased on. (For
example, if the tag refersto a branch, cvs will merge all changesmade in that branch into your working file.)
With two -j options, cvs will merge in the changesbetween the two respective revisions. Thiscan be used to remove a
certain delta from your working file. For example, if the file foo.c isbased on revision 1.6 and I want to remove the changes
made between 1.3 and 1.5, I might do this:
example% cvs update -j1.5 -j1.3 foo.c # note the order...
In addition, each -j option can contain on optional date specification which, when used with branches, can limit the chosen
revision to one within a specific date. An optional date isspecified by adding a colon (:) to the tag:
-jSymbolic Tag:Date Specifier
Use the d option to create any directoriesthat exist in the repository if theyre missing from the working directory.
(Normally, update actsonly on directoriesand filesthat were already enrolled in your working directory.) Thisisuseful for
updating directoriesthat were created in the repository since the initial checkout; but it hasan unfortunate side effect. If you
deliberately avoided certain directoriesin the repository when you created your working directory (either through use of a
module name or by listing explicitly the filesand directoriesyou wanted on the command line), then updating with d will
create those directories, which may not be what you want.
Use I name to ignore fileswhose namesmatch name (in your working directory) during the update. You can specify I more
than once on the command line to specify several filesto ignore. By default, update ignoresfileswhose namesmatch any of
the following:
RCSLOG RCS SCCS
CVS* cvslog.*
tags TAGS
.make.state .nse_depinfo
#* .#* ,
.old *.bak *.BAK *.orig *.rej .del*
.a *.o *.so *.Z *.elc *.ln core
Use I! to avoid ignoring any filesat all.
The standard cvs command optionsf, k, l, P, p, and r are also available with update.
FILES
For more detailed information on cvs supporting files, see cvs(5).
Filesin home directories:
.cvsrc The cvs initialization file. Linesin thisfile can be used to specify default optionsfor each cvs
command. For example, the line diff c will ensure that cvs diff isalwayspassed the c option in
addition to any other optionspassed on the command line.
.cvswrappers Specifieswrappersto be used in addition to those specified in the CVSROOT/cvswrappers file in the
repository.
105
Filesin working directories:
CVS A directory of cvs administrative files. Do not delete.
CVS/Entries List and statusof filesin your working directory.
CVS/Entries.Backup A backup of CVS/Entries.
CVS/Entries.Static Flag: do not add more entrieson cvs update.
CVS/Root Pathname to the repository (CVSROOT) location at the time of checkout. Thisfile isused instead
of the CVSROOT environment variable if the environment variable isnot set. A warning message
will be issued when the contentsof thisfile and the CVSROOT environment variable differ. The
file may be overridden by the presence of the CVS_IGNORE_REMOTE_ROOT environment variable.
CVS/Repository Pathname to the corresponding directory in the source repository.
CVS/Tag Containsthe per-directory sticky tag or date information. Thisfile iscreated/updated when you
specify -r or D to the checkout or update commands, and no filesare specified.
CVS/Checkin.prog Name of program to run on cvs commit.
CVS/Update.prog Name of program to run on cvs update.
Filesin source repositories:
$CVSROOT/CVSROOT Directory of global administrative filesfor repository.
CVSROOT/commitinfo,v Recordsprogramsfor filtering cvs commit requests.
CVSROOT/cvswrappers,v Recordscvs wrapper commandsto be used when checking filesinto and out of the repository.
Wrappersallow the file or directory to be processed on the way in and out of CVS. The intended
usesare many; one possible use would be to reformat a C file before the file ischecked in, so all
of the code in the repository looksthe same.
CVSROOT/editinfo,v Recordsprogramsfor editing/validating cvs commit log entries.
CVSROOT/history Log file of cvs transactions.
CVSROOT/loginfo,v Recordsprogramsfor piping cvs commit log entries.
CVSROOT/modules,v Definitionsfor modulesin thisrepository.
CVSROOT/rcsinfo,v Recordspathnamesto templatesused during a cvs commit operation.
CVSROOT/taginfo,v Recordsprogramsfor validating/logging cvs tag and cvs rtag operations.
MODULE/Attic Directory for removed source files.
#cvs.lock A lock directory created by cvs when doing sensitive changesto the RCS source repository.
#cvs.tfl.pid Temporary lock file for repository.
#cvs.rfl.pid A read lock.
#cvs.wfl.pid A write lock.
ENVIRONMENT VARIABLES
CVSROOT Should contain the full pathname to the root of the cvs source repository (where the RCSfiles
are kept). Thisinformation must be available to cvs for most commandsto execute; if CVSROOT
isnot set, or if you wish to override it for one invocation, you can supply it on the command
line: cvs d cvsroot cvs command.... You may not need to set CVSROOT if your cvs binary hasthe
right path compiled in; use cvs v to display all compiled-in paths.
CVSREAD If thisisset, checkout and update will try hard to make the filesin your working directory read-
only. When thisisnot set, the default behavior isto permit modification of your working files.
RCSBIN Specifiesthe full pathname where to find RCS programs, such asco(1)and ci(1). If not set, a
compiled-in value isused; see the display from cvs v.
CVSEDITOR Specifiesthe program to use for recording log messagesduring commit. If not set, the EDITOR
environment variable isused instead. If EDITOR isnot set either, the default is/usr/ucb/vi.
CVS_IGNORE_REMOTE_ROOT If thisvariable isset, then cvs will ignore all referencesto remote repositoriesin the CVS/Root
file.
cvs
Part I: User Commands
106
CVS_RSH cvs usesthe contentsof thisvariable to determine the name of the remote shell command to use
when starting a cvs server. If thisvariable isnot set then rsh isused.
CVS_SERVER cvs usesthe contentsof thisvariable to determine the name of the cvs server command. If this
variable isnot set then cvs isused.
CVSWRAPPERS Thisvariable isused by the cvswrappers script to determine the name of the wrapper file, in
addition to the wrappersdefaultscontained in the repository (CVSROOT/cvswrappers) and the
usershome directory (/.cvswrappers).
AUTHORS
Dick Grune Original author of the cvsshell script version posted to comp.sources.unix in the volume 6
release of December, 1986. Credited with much of the cvs conflict resolution algorithms.
Brian Berliner Coder and designer of the cvs program itself in April, 1989, based on the original work done by
Dick.
Jeff Polk Helped Brian with the design of the cvs module and vendor branch support and author of the
checkin(1) shell script (the ancestor of cvs import).
SEE ALSO
ci(1), co(1), cvs(5), cvsbug(8), diff(1), grep(1), patch(1), rcs(1), rcsdiff(1), rcsmerge(1), rlogbug(8)
13 March 1996
date
dateShow and set date and time
SYNOPSIS
date [ u ][c ][n ][d dst t ype ] [ t mi nut es- west ] [ a [+|-]sss. f f f ][+f or mat ][
[yyyy]mmddhhmm[yy][. ss ]]
DESCRIPTION
Date without argumentswritesthe date and time to the standard output in the form:
Wed Mar 8 14:54:40 EST 1989
with EST replaced by the local time zonesabbreviation (or by the abbreviation for the time zone specified in the TZ environ-
ment variable if set). The exact output format dependson the locale.
If a command-line argument startswith a plussign (+), the rest of the argument isused asa format that controlswhat
appearsin the output. In the format, when a percent sign (%) appears, it and the character after it are not output, but rather
identify part of the date or time to be output in a particular way (or identify a special character to output):
Argument Sampleoutput Explanation
%a Wed Abbreviated weekday name*
%A Wednesday Full weekday name*
%b Mar Abbreviated month name*
%B March Full month name*
%c Wed Mar 08 14:54:40 1989 Date and time*
%C 19 Century
%d 08 Day of month (alwaystwo digits)
%D 03/08/89 Month/day/year (eight characters)
107
%e 8 Day of month (leading zero blanked)
%h Mar Abbreviated month name*
%H 14 24-hour-clock hour (two digits)
%I 02 12-hour-clock hour (two digits)
%j 067 Julian day number (three digits)
%k 2 12-hour-clock hour (leading zero blanked)
%l 14 24-hour-clock hour (leading zero blanked)
%m 03 Month number (two digits)
%M 54 Minute (two digits)
%n nn Newline character
%p PM AM/PM designation
%r 02:54:40 PM Hour:minute:second AM/PM designation
%R 14:54 Hour:minute
%S 40 Second (two digits)
%t nt Tab character
%T 14:54:40 Hour:minute:second
%U 10 Sunday-based week number (two digits)
%w 3 Day number (one digit, Sunday is0)
%W 10 Monday-based week number (two digits)
%x 03/08/89 Date*
%X 14:54:40 Time*
%y 89 Last two digitsof year
%Y 1989 Year in full
%Z EST Time zone abbreviation
%+ Wed Mar 8 14:54:40 EST 1989 Default output format*
* The exact output dependson thelocale.
If a character other than one of those shown in the preceding table appearsafter a percent sign in the format, that following
character isoutput. All other charactersin the format are copied unchanged to the output; a newline character isalways
added at the end of the output.
In Sunday-based week numbering, the first Sunday of the year beginsweek 1; dayspreceding it are part of week 0. In
Monday-based week numbering, the first Monday of the year beginsweek 1.
To set the date, use a command-line argument with one of the following forms:
1454 24-hour-clock hours(first two digits) and minutes
081454 Month day (first two digits), hours, and minutes
03081454 Month (two digits, January is01), month day, hours, minutes
8903081454 Year, month, month day, hours, minutes
0308145489 Month, month day, hours, minutes, year (on System V-compatible systems)
030814541989 Month, month day, hours, minutes, four-digit year
198903081454 Four-digit year, month, month day, hours, minutes
Argument Sampleoutput Explanation
date
Part I: User Commands
108
If the century, year, month, or month day isnot given, the current value isused. Any of the preceding formsmay be
followed by a period and two digitsthat give the secondspart of the new time; if no secondsare given, zero isassumed.
These optionsare available:
u or c Use GMT when setting and showing the date and time.
n Do not notify other networked systemsof the time change.
d dst t ype Set the kernel-stored Daylight Saving Time type to the given value. (The kernel-stored DST type is
used mostly by old binaries.)
t mi nut es- west Set the kernel-stored minuteswest of GMT value to the one given on the command line. (The
kernel-stored DST type isused mostly by old binaries.)
a adj ust ment Change the time forward (or backward) by the number of seconds(and fractionsthereof) specified
in the adjustment argument. Either the secondspart or the fractionspart of the argument (but not
both) may be omitted. On BSD-based systems, the adjustment ismade by changing the rate at
which time advances; on System-Vbased systems, the adjustment ismade by changing the time.
FILES
/usr/lib/locale/L/LC TIME Description of time locale L
/usr/local/etc/zoneinfo Time zone information directory
/usr/local/etc/zoneinfo/localtime Local time zone file
/usr/local/etc/zoneinfo/posixrules Used with POSIX-style TZs
/usr/local/etc/zoneinfo/GMT For UTC leap seconds
If /usr/local/etc/zoneinfo/GMT isabsent, UTC leap secondsare loaded from /usr/local/etc/zoneinfo/posixrules.
dd
ddConvert a file while copying it (data dumper)
SYNOPSIS
dd [help] [version] [if=f i l e] [of=f i l e] [ibs=byt es] [obs=byt es] [bs=byt es]
[cbs=byt es ] [skip=bl ocks ] [seek=bl ocks ] [count=bl ocks] [conv={ascii,
ebcdic, ibm, block, unblock, lcase, ucase, swab, noerror, notrunc, sync}]
DESCRIPTION
Thismanual page documentsthe GNU version of dd. dd copiesa file (from the standard input to the standard output, by
default) with a user-selectable blocksize, while optionally performing conversionson it.
OPTIONS
Numberscan be followed by a multiplier:
b=512, c=1, k=1024, w=2, xm=number m
These optionsare available:
help Print a usage message on standard output and exit successfully.
version Print version information on standard output then exit successfully.
if=f i l e Read from file instead of the standard input.
of=f i l e Write to file instead of the standard output. Unlessconv=notrunc isgiven, truncate
file to the size specified by seek= (0 bytesif seek= isnot given).
ibs=byt es Read byt es bytesat a time.
obs=byt es Write byt es bytesat a time.
bs=byt es Read and write byt es bytesat a time. Override ibs and obs.
109
cbs=byt es Convert byt es bytesat a time.
skip=bl ocks Skip bl ocks ibs-sized blocksat start of input.
seek=bl ocks Skip bl ocks obs-sized blocksat start of output.
count=bl ocks Copy only bl ocks ibs-sized input blocks.
conv=conver si on[,conver si on...] Convert the file asspecified by the conversion arguments.
Conversions:
ascii Convert EBCDIC to ASCII.
ebcdic Convert ASCII to EBCDIC.
ibm Convert ASCII to alternate EBCDIC.
block Pad newline-terminated recordsto size of cbs, replacing newline with trailing spaces.
unblock Replace trailing spacesin cbs-sized block with newline.
lcase Change uppercase charactersto lowercase.
ucase Change lowercase charactersto uppercase.
swab Swap every pair of input bytes. Unlike the UNIX dd, thisworkswhen an odd
number of bytesare read. If the input file containsan odd number of bytes, the last
byte issimply copied (since there isnothing to swap it with).
noerror Continue after read errors.
notrunc Do not truncate the output file.
sync Pad every input block to size of ibs with trailing NULLs.
GNU FileUtilities
depmod, modprobe
depmod, modprobeHandle loadable modulesautomatically
SYNOPSIS
depmod [a]
depmod modul e1. o modul e2.o ...
modprobe module.o [symbol=val ue ...]
modprobe t t ag pat t er n
modprobe a t tag pattern modprobe l [ t t ag ] pat t er n
modprobe r modul e
modprobe c
DESCRIPTION
These utilitiesare intended to make a Linux modular kernel manageable for all users, administrators, and distribution
maintainers.
depmod createsa makefile-like dependency file, based on the symbolsit findsin the set of modulesmentioned on the
command line (or in a default place). Thisdependency file can later be used by modprobe to automatically load the relevant
module(s).
modprobe isused to load a set of moduleseither a single module, a stack of dependent modules, or all modulesthat are
marked with a specified tag.
modprobe will automatically load all base modulesneeded in a module stack, asdescribed by the dependency file modules.dep.
If the loading of one of these modulesfails, the whole current stack of moduleswill be unloaded (by rmmod) automatically.
modprobe hastwo waysof loading modules. One way (the probe mode) will try to load a module out of a list (defined by
pattern). It stopsloading assoon asone module load successfully. Thiscan be used to autoload one Ethernet driver out of a
list, for example. The other way isto load all modulesfrom a list. Thiscan be used to load some modulesat boot time.
depmod, modprobe
Part I: User Commands
110
With the option -r, modprobe will automatically unload a stack of modules, similar to the way rmmod -r does.
Option -l combined with option -t listsall available modulesof a certain type. An enhanced mount command could use the
command:
modprobe -l -t fs
to get the list of all file system driversavailable and on request load the proper one. So, the mount command could become
more generic aswell. (The kerneld solvesthiswithout changing the mount utility.)
Option -c will print all configuration (default + configuration file).
The normal use of depmod isto include the line /sbin/depmod -a in one of the rc-files in /etc/rc.d, so that the correct
module dependencieswill be available immediately after booting the system.
Option -d putsdepmod in debug mode. It outputsall commandsit isissuing.
Option -e outputsthe list of unresolved symbol for each module, Normally, depmod only outputsthe list of unloadable
modules.
Option -v outputsthe list of all processed modules.
Modulesmay be located at different place in the filesystem, but there will alwaysbe some need to override this, especially for
module developers. We expect some official standard will emerge, defined by the FSSTND. Until that time, you might as
well use thissuggested directory structure.
CONFIGURATION
The behavior of depmod and modprobe can be adjusted by the (optional) configuration file /etc/conf.modules.
The configuration file consistsof a set of lines. All empty lines, and all text on a line after a #, will be ignored. Linesmay be
continued by ending the line with a \. The remaining linesshould all conform to one of the following formats:
keep
parameter=value
options module symbol=value ...
alias module real_name
pre-install module command ...
install module command ...
post-install module command ...
pre-remove module command ...
remove module command ...
post-remove module command ...
parameter=value options module symbol=value ... alias module real_name
All valuesin the parameter lineswill be processed by a shell, which meansthat shell trickslike wildcardsand commands
enclosed in backquotescan be used:
path[misc]=/lib/modules/1.1.5?/misc
path[net]=/lib/modules/uname -r/net
Parametersmay be repeated multiple times.
These are the legal parameters:
depfile=DEPFILE_PATH Thisisthe path to the dependency file that will be created by depmod and used by modprobe.
path=SOME_PATH The path parameter specifiesa directory to search for the modules.
path[tag]=SOME_PATH The path parameter can carry an optional tag. Thistellsusa little more about the purpose of the
modulesin thisdirectory and allowssome automated operationsby modprobe. The tag isappended
to the path keyword enclosed in square brackets. If the tag ismissing, the tag misc isassumed. One
very useful tag isboot, which can be used to mark all modulesthat should be loaded at boot time.
If the configuration file /etc/conf.modules ismissing, or if any parameter isnot overridden, the following defaultsare
assumed:
111
depfile=/lib/modules/uname -r/modules.dep
path[boot]=/lib/modules/boot
path[fs]=/lib/modules/uname -r/fs
path[misc]=/lib/modules/uname -r/misc
path[net]=/lib/modules/uname -r/net
path[scsi]=/lib/modules/uname -r/scsi
path[fs]=/lib/modules/default/fs
path[misc]=/lib/modules/default/misc
path[net]=/lib/modules/default/net
path[scsi]=/lib/modules/default/scsi
path[fs]=/lib/modules/fs
path[misc]=/lib/modules/misc
path[net]=/lib/modules/net
path[scsi]=/lib/modules/scsi
All option linesspecify the default optionsthat are needed for a module, asin
modprobe de620 bnc=1
These optionswill be overridden by any optionsgiven on the modprobe command line.
The aliaslinescan be used to give aliasnamesto modules. A line in /etc/conf.modules that lookslike this:
alias iso9660 isofs
makesit possible to write modprobe iso9660, although there isno such module available.
STRATEGY
The idea isthat modprobe will look first at the directory containing modulescompiled for the current release of the kernel. If
the module isnot found there, modprobe will look in the directory containing modulesfor a default release.
When you install a new Linux, the modulesshould be moved to a directory related to the release (and version) of the kernel
you are installing. Then you should do a symlink from thisdirectory to the default directory.
Each time you compile a new kernel, the command make modules_install will create a new directory, but wont change the
default.
When you get a module unrelated to the kernel distribution, you should place it in one of the version-independent
directoriesunder /lib/modules.
Thisisthe default strategy, which can be overridden in /etc/conf.modules.
EXAMPLES
modprobe -t net Load one of the modulesthat are stored in the directory tagged net. Each module istried until one
succeeds. (Default: /lib/modules/net).
modprobe -a -t boot All modulesthat are stored in the directory tagged boot will be loaded. (Default: /lib/modules/
boot).
modprobe slip.o Thiswill attempt to load the module slhc.o if it wasnot previously loaded, since the slip module
needsthe functionality in the slhc module. Thisdependency will be described in the file
modules.dep that wascreated automatically by depmod.
modprobe -r slip.o Will unload slip.o. It will also unload slhc.o automatically, unlessit isused by some other module
aswell (such asppp.o).
FILES
/etc/conf.modules
/lib/modules/*/modules.dep
/lib/modules/*
depmod, modprobe
Part I: User Commands
112
SEE ALSO
lsmod(1), kerneld(8), ksyms(1), modules(2)
REQUIRED UTILITIES
insmod(1), nm(1) rmmod(1)
NOTES
The pattern supplied to modprobe will often be escaped to ensure that it isevaluated in the proper context.
AUTHOR
JacquesGelinas(jack@solucorp.qc.ca), Bjorn Ekwall (bj0rn@blox.se)
BUGS
Naah
Linux, 14 May1995
df
dfSummarize free disk space
SYNOPSIS
df [aikPv] [t f st ype] [x f st ype] [all] [inodes] [type=f st ype]
[excludetype=f st ype] [kilobytes] [portability] [printtype]
[help] [version] [filename...]
DESCRIPTION
Thismanual page documentsthe GNU version of df. df displaysthe amount of disk space available on the filesystem
containing each filename argument. If no filename isgiven, the space available on all currently mounted filesystemsisshown.
Disk space isshown in 1K blocksby default, unlessthe environment variable POSIXLY_CORRECT isset, in which case 512-byte
blocksare used.
If an argument isthe absolute filename of a disk device node containing a mounted filesystem, df showsthe space available
on that filesystem rather than on the filesystem containing the device node (which isalwaysthe root filesystem). Thisversion
of df cannot show the space available on unmounted filesystems, because on most kindsof systemsdoing so requiresvery
nonportable, intimate knowledge of filesystem structures.
OPTIONS
a, all Include in the listing filesystemsthat have 0 blocks, which are omitted by default. Such
filesystemsare typically special-purpose pseudo-filesystems, such asautomounter entries. On
some systems, filesystemsof type ignore or auto are also omitted by default and included in the
listing by thisoption.
-i, inodes List inode usage information instead of block usage. An inode (short for index node) isa
special kind of disk block that containsinformation about a file, such asitsowner, permissions,
timestamps, and location on the disk.
k, kilobytes Print sizesin 1K blocksinstead of 512-byte blocks. Thisoverridesthe environment variable
POSIXLY_CORRECT.
P, portability Use the POSIX output format. Thisislike the default format except that the information about
each filesystem isalwaysprinted on exactly one line; a mount device isnever put on a line by
itself. Thismeansthat if the mount device name ismore than 20 characterslong (asfor some
network mounts), the columnsare misaligned.
113
T, printtype Print a type string for each filesystem. Any such printed filesystem type name may be used asan
argument to either of the type= or excludetype= options.
t, type=f st ype Limit the listing to filesystemsof type f st ype. Multiple filesystem typescan be shown by giving
multiple t options. By default, all filesystem typesare listed.
x, excludetype=f st ype Limit the listing to filesystemsnot of type fstype. Multiple filesystem typescan be eliminated by
giving multiple x options. By default, all filesystem typesare listed.
v Ignored; for compatibility with System V versionsof df.
help Print a usage message on standard output and exit successfully.
version Print version information on standard output then exit successfully.
GNU FileUtilities
dig
digSend domain name query packetsto name servers
SYNOPSIS
dig [@ser ver ] domai n [<quer y- t ype>][<quer y- cl ass>][+<quer y- opt i on>][<di g- opt i on>]
[%comment ]
DESCRIPTION
dig (domain information groper) isa flexible command-line tool that can be used to gather information from the Domain
Name System servers. dig hastwo modes: simple interactive mode that makesa single query, and batch that executesa query
for each in a list of several query lines. All query optionsare accessible from the command line.
The usual simple use of dig takesthe form:
dig @ser ver domai n quer y- t ype quer y- cl ass
where
ser ver May be either a domain name or a dot-notation Internet address. If thisoptional field isomitted,
dig will attempt to use the default name server for your machine.
NOTE
If a domain name isspecified, thiswill be resolved using the domain name system resolver (BIND). If your system doesnot
support DNS, you may have to specify a dot-notation address. Alternatively, if there isa server at your disposal some-
where, all that isrequired isthat /etc/resolv.conf be present and indicate where the default name serversreside, so that
server itself can be resolved. See resolver(5) for information on /etc/resolv.conf.
WARNING
Changing /etc/resolv.conf will affect the standard resolver library and potentially several programsthat use it.) Asan
option, the user may set the environment variable LOCALRES to name a file which isto be used instead of /etc/resolv.conf
(LOCALRES isspecific to the dig resolver and not referenced by the standard resolver). If the LOCALRES variable isnot set or
the file isnot readable, then /etc/resolv.conf will be used.
domai n The domain name for which you are requesting information. See Options [-x] for a convenient
way to specify inverse addressquery.
dig
Part I: User Commands
114
quer y- t ype The type of information (DNSquery type) that you are requesting. If omitted, the default isa (T_A
= address). The following typesare recognized:
Type Example Description
a T_A Network address
any T_ANY All/any information about specified domain
mx T_MX Mail exchanger for the domain
ns T_NS Name servers
soa T_SOA Zone of authority record
hinfo T_HINFO Host information
axfr T_AXFR Zone transfer (must ask an authoritative server)
txt T_TXT Arbitrary number of strings
(See RFC 1035 for the complete list.)
quer y- cl ass The network classrequested in the query. If omitted, the default isin (C_IN = Internet). The
following classesare recognized:
in C_IN Internet classdomain
any C_ANY All/any classinformation
(See RFC 1035 for the complete list.)
NOTE
any can be used to specify a classand/or a type of query. dig will parse the first occurrence of any to mean query-type =
T_ANY.
To specify query-class = C_ANY you must either specify any twice, or set query-class using c option. (See Other Op-
tions, next.)
OTHER OPTIONS
%ignored-comment % isused to include an argument that issimply not parsed. Thismay be useful if running dig in
batch mode. Instead of resolving every @ser ver - domai n- name in a list of queries, you can avoid the
overhead of doing so, and still have the domain name on the command line asa reference.
Example:
dig @128.9.0.32 %venera.isi.edu mx isi.edu
<dig opt i on> isused to specify an option that affectsthe operation of dig. The following optionsare currently
available (although not guaranteed to be useful):
x dot - not at i on- addr ess Convenient form to specify inverse addressmapping. Instead of
dig 32.0.9.128.in-addr.arpa
one can simply use
dig -x 128.9.0.32
f f i l e File for dig batch mode. The file containsa list of query
specifications(dig command lines) which are to be executed
successively. Linesbeginning with ;, #, or \n are ignored. Other
optionsmay still appear on the command line, and will be in
effect for each batch query.
T t i me Time in secondsbetween start of successive querieswhen running
in batch mode. Can be used to keep two or more batch dig
commandsrunning roughly in sync. Default iszero.
115
p por t Port number. Query a name server listening to a nonstandard port
number. Default is53.
P[pi ng- st r i ng] After query returns, execute a ping(8) command for response time
comparison. Thisrather unelegantly makesa call to the shell. The
last three linesof statisticsisprinted for the command:
ping sserver_name 56 3
If the optional ping string ispresent, it replacesping s in the
shell command.
t quer y- t ype Specify type of query. May specify either an integer value to be
included in the type field or use the abbreviated mnemonic as
discussed earlier (mx = T_MX).
c quer y- cl ass Specify classof query. May specify either an integer value to be
included in the classfield or use the abbreviated mnemonic as
discussed earlier (in = C_IN).
envsav Thisflag specifiesthat the dig environment (defaults, print options, and so on), after all of the
argumentsare parsed, should be saved to a file to become the default environment. Useful if you do
not like the standard set of defaultsand do not desire to include a large number of optionseach
time dig isused. The environment consistsof resolver state variable flags, timeout, and retriesas
well asthe flagsdetailing dig output (see below). If the shell environment variable LOCALDEF isset to
the name of a file, thisiswhere the default dig environment issaved. If not, the file DiG.env is
created in the current working directory.
NOTE
LOCALDEF isspecific to the dig resolver, and will not affect operation of the standard resolver library.
Each time dig isexecuted, it looksfor ./DiG.env or the file specified by the shell environment
variable LOCALDEF. If such file existsand isreadable, then the environment isrestored from thisfile
before any argumentsare parsed.
envset Thisflag only affectsbatch query runs. When envset isspecified on a line in a dig batch file, the
dig environment after the argumentsare parsed, becomesthe default environment for the duration
of the batch file, or until the next line which specifiesenvset.
[no]stick Thisflag only affectsbatch query runs. It specifiesthat the dig environment (asread initially or set
by envset switch) isto be restored before each query (line) in a dig batch file. The default nostick
meansthat the dig environment doesnot stick, hence optionsspecified on a single line in a dig
batch file will remain in effect for subsequent lines(that is, they are not restored to the sticky
default).
+<quer y opt i on> + isused to specify an option to be changed in the query packet or to change dig output specifics.
Many of these are the same parametersaccepted by nslookup(8). If an option requiresa parameter,
the form isasfollows:
+keyword[=value]
Most keywordscan be abbreviated. Parsing of the + optionsisvery simplistica value must not be
separated from itskeyword by whitespace. The following keywordsare currently available:
Keyword Abbreviation Meaning(Default)
[no]debug (deb) Turn on/off debugging mode [deb]
[no]d2 Turn on/off extra debugging mode [nod2]
[no]recurse (rec) Use/dont use recursive lookup [rec]
retry=# (ret) Set number of retriesto # [4]
continues
dig
Part I: User Commands
116
time=# (ti) Set timeout length to # seconds[4]
[no]ko Keep open option (impliesvc) [noko]
[no]vc Use/dont use virtual circuit [novc]
[no]defname (def) Use/dont use default domain name [def]
[no]search (sea) Use/dont use domain search list [sea]
domain=NAME (do) Set default domain name to NAME
[no]ignore (i) Ignore/dont ignore trunc. errors[noi]
[no]primary (pr) Use/dont use primary server [nopr]
[no]aaonly (aa) Authoritative query only flag [noaa]
[no]sort (sor) Sort resource records[nosor]
[no]cmd Echo parsed arguments[cmd]
[no]stats (st) Print query statistics[st]
[no]Header (H) Print basic header [H]
[no]header (he) Print header flags[he]
[no]ttlid (tt) Print TTLs[tt]
[no]cl Print classinfo [nocl]
[no]qr Print outgoing query [noqr]
[no]reply (rep) Print reply [rep]
[no]ques (qu) Print question section [qu]
[no]answer (an) Print answer section [an]
[no]author (au) Print authoritative section [au]
[no]addit (ad) Print additional section [ad]
pfdef Set to default print flags
pfmin Set to minimal default print flags
pfset=# Set print flagsto # (# can be hex/octal/decimal)
pfand=# Bitwise and print flagswith #
pfor=# Bitwise or print flagswith #
The retry and time optionsaffect the retransmission strategy used by resolver library when sending datagram queries. The
algorithm isasfollows:
August 30, 1990
for i = 0 to retry 1
for j = 1 to num_servers
send_query
wait((time * (2**i)) / num_servers)
end
end
Note that dig alwaysusesa value of 1 for num_servers.
DETAILS
dig once required a slightly modified version of the BIND resolver (3) library. BINDsresolver has(asof BIND 4.9) been
augmented to work properly with dig. Essentially, dig isa straightforward (albeit not pretty) effort of parsing argumentsand
setting appropriate parameters. dig usesresolver routinesres_init(), res_mkquery(), res_send() aswell asaccessing _res
structure.
Keyword Abbreviation Meaning(Default)
117
FILES
/etc/resolv.conf Initial domain name and name server addresses
ENVIRONMENT
LOCALRES file to use in place of /etc/resolv.conf
LOCALDEF default environment file
AUTHOR
Steve Hotz (hotz@isi.edu)
ACKNOWLEDGMENTS
dig usesfunctionsfrom nslookup(8) authored by Andrew Cherenson.
BUGS
dig hasa seriouscase of creeping featurism, the result of considering several potential usesduring itsdevelopment. It would
probably benefit from a rigorousdiet. Similarly, the print flagsand granularity of the itemsthey specify make evident their
rather ad hoc genesis.
dig doesnot consistently exit nicely (with appropriate status) when a problem occurssomewhere in the resolver (Most of the
common exit casesare handled.) Thisisparticularly annoying when running in batch mode. If it exitsabnormally (and isnot
caught), the entire batch aborts; when such an event istrapped, dig simply continueswith the next query.
SEE ALSO
named(8), resolver(3), resolver(5), nslookup(8)
30 August 1990
dnsquery
dnsqueryQuery domain name serversusing resolver
SYNOPSIS
dnsquery [-n nameser ver ] [-t t ype] [-c cl ass] [-r r et r y] [-p r et r y period]
[-d] [-s] [-v] host
DESCRIPTION
The dnsquery program isa general interface to nameserversvia BIND resolver library calls. The program supportsqueriesto the
nameserver with an opcode of QUERY. Thisprogram isintended to be a replacement or supplement to programslike nstest,
nsquery, and nslookup. All argumentsexcept for host and ns are treated without case-sensitivity.
OPTIONS
n The nameserver to be used in the query. Nameserverscan appear aseither Internet addressesof the form
w. x. y. z or can appear asdomain names. (default: asspecified in /etc/resolv.conf)
t The type of resource record of interest. Typesinclude:
A Address
NS Nameserver
CNAME Canonical name
PTR Domain name pointer
SOA Start of authority
dnsquery
Part I: User Commands
118
WKS Well-known service
HINFO Host information
MINFO Mailbox information
MX Mail exchange
RP Responsible person
MG Mail group member
AFSDB DCE or AFS server
ANY Wildcard
NOTE
Any case may be used (the default isANY)
c The classof resource recordsof interest. Classesinclude the following:
IN Internet
HS Hesiod
CHAOS Chaos
ANY Wildcard
NOTE
Any case may be used (the default isIN).
-r The number of timesto retry if the nameserver isnot responding. (default: 4)
p Period to wait before timing out. (default: RES_TIMEOUT) options field. (default: any answer)
d Turn on debugging. Thissetsthe RES_DEBUG bit of the resolversoptions field. (default: no debugging)
s Use a stream rather than a packet. Thisusesa TCP stream connection with the nameserver rather than a
UDP datagram. Thissetsthe RES_USEVC bit of the resolversoptionsfield. (default: UDP)
v Synonym for the s flag.
host The name of the host (or domain) of interest.
FILES
/etc/resolv.conf To get the default ns and search lists.
<arpa/nameser.h> List of usable RR typesand classes
<resolv.h> List of resolver flags
SEE ALSO
nslookup(8), nstest(1), nsquery(1), named(8), resolver(5)
DIAGNOSTICS
If the resolver failsto answer the query and debugging hasnot been turned on, dnsquery will simply print a message like this:
Query failed (rc = 1) : Unknown host
The value of the return code issupplied by h_errno.
119
BUGS
Queriesof a classother than IN can have interesting resultssince ordinarily a nameserver only hasa list of root nameservers
for classIN resource records.
Query usesa call to inet_addr() to determine if the argument for the -n option isa valid Internet address. Unfortunately,
inet_addr() seemsto cause a segmentation fault with some (bad) addresses(for example, 1.2.3.4.5).
AUTHOR
Bryan Beecher
10 March 1990
domainname
domainnameSet or print domain of current host
SYNOPSIS
domainname [ name ]
DESCRIPTION
domainname printsthe domain name of the current host, from the getdomainname(3) library call. If an argument ispresent and
the effective UID is0, domainname changesthe name of the host, with the setdomainname(2) system call. Thisisusually done at
boot time in the /etc/rc.local script.
FILES
/etc/rc.local
SEE ALSO
getdomainname(3), setdomainname(2), uname(1), uname(2)
AUTHOR
LarsWirzeniusby substituting in hostname.c
Linux 0.98, 26 December 1992
dsplit
dsplitSplit a large file into pieces
SYNOPSIS
dsplit [ size nnn ][i nput _f i l e [ out put _base ]]
DESCRIPTION
dsplit splitsbinary filesinto smaller chunksso that they may be placed on floppy disks.
OPTIONS
size nnn Specifiesthe size of each output file, in bytes. The default is1457000, which isenough to will a
1.44MB floppy disk.
i nput _f i l e Specifiesthe name of the file to split up. A indicatesstandard input. The default isstandard
input.
dsplit
Part I: User Commands
120
out put _base Specifiesthe name of the output filesto be written. dsplit will append 000, 001, ..., to the
out put _base. The default isdsplit.
AUTHORS NOTES
Submitted by: David Arnstein (arnstein@netcom.com)
Posting number: Volume 40, Issue 51
Archive name: dsplit/part01
Environment: MS-DOS, UNIX
Here isa portable binary file splitting program. It readsa binary file and splitsit into pieces. I use thisprogram to put large
binary fileson floppy disks. For thisreason, the default size of the output filesis1,457,000 bytes, which just about fillsup a
1.44MB floppy disk.
Unlike other binary split programsI have seen, dsplit doesnot malloc a huge block of memory. dsplit issuitable for use
under MS-DOS and other primitive operating systems.
(The program came from gatekeeper.dec.com:/pub/usenet/comp.sources.misc/volume40/dsplit).
Linux 1.1, 5 July1994
du
duSummarize disk usage
SYNOPSIS
du [abcklsxDLS] [all] [total] [count-links] [summarize] [bytes]
[kilobytes] [one-file-system] [separate-dirs] [dereference]
[dereference-args] [help] [-version] [f i l ename...]
DESCRIPTION
Thismanual page documentsthe GNU version of du. du displaysthe amount of disk space used by each argument and for
each subdirectory of directory arguments. The space ismeasured in 1K blocksby default, unlessthe environment variable
POSIXLY_CORRECT isset, in which case 512-byte blocksare used.
OPTIONS
a, all Display countsfor all files, not just directories.
b, bytes Print sizesin bytes.
c, total Write a grand total of all of the argumentsafter all argumentshave been processed. Thiscan
be used to find out the disk usage of a directory, with some filesexcluded.
k, kilobytes Print sizesin kilobytes. Thisoverridesthe environment variable POSIXLY_CORRECT.
l, count-links Count the size of all files, even if they have appeared already in another hard link.
s, summarize Display only a total for each argument.
x, one-file-system Skip directoriesthat are on different filesystemsfrom the one that the argument being
processed ison.
D, dereference-args Dereference symbolic linksthat are command-line arguments. Doesnot affect other
symbolic links. Thisishelpful for finding out the disk usage of directorieslike /usr/tmp
where they are symbolic links.
L, dereference Dereference symbolic links(show the disk space used by the file or directory that the link
pointsto instead of the space used by the link).
S, separate-dirs Count the size of each directory separately, not including the sizesof subdirectories.
help Print a usage message on standard output and exit successfully.
version Print version information on standard output, then exit successfully.
121
BUGS
On BSD systems, du reportssizesthat are half the correct valuesfor filesthat are NFS-mounted from HP-UX systems. On
HP-UX systems, it reportssizesthat are twice the correct valuesfor filesthat are NFS-mounted from BSD systems. Thisis
due to a flaw in HP-UX; it also affectsthe HP-UX du program.
GNU FileUtilities
editres
editresA dynamic resource editor for X Toolkit applications
SYNTAX
editres [ t ool ki t opt i on ... ]
OPTIONS
editres acceptsall of the standard X Toolkit command-line options(see X(1)). The order of the command-line optionsisnot
important.
DESCRIPTION
editres isa tool that allowsusersand application developersto view the full widget hierarchy of any X Toolkit application
that speaksthe editres protocol. In addition, editres will help the user construct resource specifications, allow the user to
apply the resource to the application and view the resultsdynamically. Once the user ishappy with a resource specification,
editres will append the resource string to the usersX Resourcesfile.
USING editres
editres providesa window consisting of the following four areas:
Menu Bar A set of pop-up menusthat allow you full accessto editressfeatures.
Panner The panner providesa more intuitive way to scroll the application tree display.
Message Area Displaysinformation to the user about the action that editres expects.
Application Widget Tree Thisarea isused to display the selected applicationswidget tree.
To begin an editres session, select the Get Widget Tree menu item from the Command menu. Thiswill change the pointer
cursor to crosshair. You should now select the application you wish look at by clicking on any of itswindows. If this
application understandsthe editres protocol, editres will display the applicationswidget tree in itstree window. If the
application doesnot understand the editres protocol, editres will inform you of thisfact in the message area after a few
secondsdelay.
After you have a widget tree, you may select any of the other menu options. The effect of each of these isdescribed in
Commands, next.
COMMANDS
Get Widget Tree Allowsthe user to click on any application that speaksthe editres protocol and receive its
widget tree.
Refresh Current Widget Tree editres only knowsabout the widgetsthat exist at the present time. Many applications
create and destroy widgetson the fly. Selecting thismenu item will cause editres to ask the
application to resend itswidget tree, thusupdating itsinformation to the new state of the
application.
For example, xman only createsthe widgetsfor itstopbox when it startsup. None of the
widgetsfor the manual page window are created until the user actually clickson the Manual
Page button. If you retrieved xmanswidget tree before the manual page isactive, you may
wish to refresh the widget tree after the manual page hasbeen displayed. Thiswill allow you
to also edit the manual pagesresources.
editres
Part I: User Commands
122
Dump Widget Tree to a File When documenting applicationsit isoften useful to be able to dump the entire application
widget tree to an ASCII file. Thisfile can then be included in the manual page. When this
menu item isselected, a pop-up dialog isactivated. Type the name of the file in thisdialog,
and either select Okay, or type a carriage-return. editres will dump the widget tree to this
file. To cancel the file dialog, select the Cancel button.
Show Resource Box Thiscommand will pop up a resource box for the current application. Thisresource box
(described in detail later in thissection) will allow the user to see exactly which resources
can be set for the widget that iscurrently selected in the widget tree display. Only one
widget may be currently selected; if greater or fewer are selected, editres will refuse to pop
up the resource box and put an error message in the Message Area.
Set Resource Thiscommand will pop up a simple dialog box for setting an arbitrary resource on all
selected widgets. You must type in the resource name, aswell asthe value. You can use the
Tab key to switch between the resource name field and the resource value field.
Quit Exitseditres.
TREE COMMANDS
The Tree menu containsseveral commandsthat enable operationsto be performed on the widget tree.
Select Widget in Client Thismenu item allowsyou to select any widget in the application; editres will then
highlight the corresponding element the widget tree display. After thismenu item is
selected, the pointer cursor will again turn to a crosshair, and you must click any pointer
button in the widget you wish to have displayed. Since some widgetsare fully obscured by
their children, it isnot possible to get to every widget thisway, but thismechanism does
give very useful feedback between the elementsin the widget tree and those in the actual
application.
Select All, Unselect All, These functionsallow the user to select, unselect, or invert all widgetsin the widget tree.
Invert All
Select Children, These functionsselect the immediate parent or children of each of the currently selected
Select Parents widgets.
Select Descendants, These functionsselect all parentsor children of each of the currently selected widgets. This
Select Ancestors isa recursive search.
Show Widget Names, When the tree widget isinitially displayed, the labelsof each widget in the tree correspond
Show ClassNames, to the widget names. These functionswill cause the label of all widgetsin the tree to be
Show Widget Windows changed to show the classname, IDs, or window associated with each widget in the
application. The widget IDs, and windowsare shown ashex numbers.
In addition, there are keyboard acceleratorsfor each of the Tree operations. If the input
focusisover an individual widget in the tree, then that operation will only affect that
widget. If the input focusisin the Tree background, it will have exactly the same effect as
the corresponding menu item.
The translation entriesshown may be applied to any widget in the application. If that
widget isa child of the Tree widget, then it will only affect that widget; otherwise, it will
have the same effect asthe commandsin the Tree menu.
Flash Active Widgets Thiscommand isthe inverse of the Select Widget in Client command; it will show the user
each widget that iscurrently selected in the widget tree by flashing the corresponding widget
in the application numFlashes (three by default) timesin the flash-Color.
Key Option Translation Entry
space Unselect Select(nothing)
w Select Select(widget)
s Select Select(all)
i Invert Select(invert)
123
c Select Children Select(children)
d Select Descendants Select(descendants)
p Select Parent Select(parent)
a Select Ancestors Select(ancestors)
N Show Widget Names Relabel(name)
C Show ClassNames Relabel(class)
I Show Widget IDs Relabel(id)
W Show Widget Windows Relabel(window)
T Toggle Widget/ClassName Relabel(toggle)
Clicking button 1 on a widget addsit to the set of selected widgets. Clicking button 2 on a widget deselectsall other widgets
and then selectsjust that widget. Clicking button 3 on a widget togglesitslabel between the widgetsinstance name the
widgetsclassname.
USING THE RESOURCE BOX
The resource box containsfive different areas. Each of the areas, asthey appear on the screen from top to bottom, are
discussed in the following list:
The Resource Line Thisarea at the top of the resource box showsthe current resource name exactly asit
would appear if you were to save it to a file or apply it.
The Widget Namesand Classes Thisarea enablesyou to select exactly which widgetsthisresource will apply to. The
area containsfour lines; the first containsthe name of the selected widget and all its
ancestors, and the more restrictive dot (.) separator. The second line containsless
specific classnamesof each widget, aswell asthe lessrestrictive star (*) separator.
The third line containsa set of special buttonscalled Any Widget that will generalize
thislevel to match any widget. The last line containsa set of special buttonscalled
Any Widget Chain that will turn the single level into something that matcheszero or
more levels.
The initial state of thisarea isthe most restrictive, using the resource namesand the
dot separator. By selecting the other buttonsin thisarea, you can ease the restrictions
to allow more and more widgetsto match the specification. The extreme case isto
select all the Any Widget Chain buttons, which will match every widget in the
application. Asyou select different buttons, the tree display will update to show you
exactly which widgetswill be affected by the current resource specification.
Normal and Constraint Resources The next area allowsyou to select the name of the normal or constraint resources
you wish to set. Some widgetsmay not have constraint resources, so that area will
not appear.
Resource Value Thisnext area allowsyou to enter the resource value. Thisvalue should be entered
exactly asyou would type a line into your resource file. Thus, it should contain no
unescaped newlines. There are a few special character sequencesfor thisfile:
\n- Thiswill be replaced with a newline.
\###- Where # isany octal digit. Thiswill be replaced with a single
byte that containsthissequence interpreted asan octal
number. For example, a value containing a NULL byte can be
stored by specifying \000.
\<new-line>- Thiswill compressto nothing.
\\- Thiswill compressto a single backslash.
Key Option Translation Entry
editres
Part I: User Commands
124
Command Area Thisarea containsseveral command buttons, described in the following list:
The Set Save File button allowsthe user to modify file that the resourceswill be
saved to. Thisbutton will bring up a dialog box that will ask you for a filename;
after the filename hasbeen entered, either hit carriage-return or click on the
Okay button. To pop down the dialog box without changing the save file, click
the Cancel button.
The Save button will append the resource line already described to the end of the
current save file. If no save file hasbeen set, the Set Save File dialog box will be
popped up to prompt the user for a filename.
The Apply button attemptsto perform a XtSetValues call on all widgetsthat
match the resource line described earlier. The value specified isapplied directly
to all matching widgets. Thisbehavior isan attempt to give a dynamic feel to the
resource editor. Since thisfeature allowsusersto put an application in statesit
may not be willing to handle, a hook hasbeen provided to allow specific
applicationsto block these SetValues requests. (See Blocking editres Requests,
following).
Unfortunately, due to design constraintsimposed on the widgetsby the X
Toolkit and the Resource Manager, trying to coerce an inherently static system
into dynamic behavior can cause strange results. There isno guarantee that the
resultsof an apply will be the same aswhat will happen when you save the value
and restart the application. Thisfunctionality isprovided to try to give you a
rough feel for what your changeswill accomplish, and the resultsobtained
should be considered suspect at best. Having said that, thisisone of the neatest
featuresof editres, and I strongly suggest that you play with it, and see what it
can do.
The Save and Apply button combinesthe Save and Apply actionsdescribed
earlier into one button.
The Popdown Resource Box button will remove the resource box from the
display.
BLOCKING editres REQUESTS
The editres protocol hasbeen built into the Athena Widget set. Thisallowsall applicationsthat are linked against Xaw to be
able to speak to the resource editor. Although thisprovidesgreat flexibility, and isa useful tool, it can quite easily be abused.
It istherefore possible for any Xaw application to specify a value for the editresBlock resource to keep editres from divulging
information about itsinternals, or to disable the SetValues part of the protocol.
editresBlock (ClassEditresblock) specifieswhich type of blocking thisapplication wishesto impose on the editres protocol.
The accepted valuesare asfollows:
all Block all requests.
setValues Block all SetValues requests. Asthisisthe only editres request that actually modifiesthe application, this
isin effect stating that the application isread-only.
none Allow all editres requests.
Remember that these resourcesare set on any Xaw application, not editres. They allow individual applicationsto keep all or
some of the requestseditres makesfrom ever succeeding. Of course, editres isalso an Xaw application, so it may also be
viewed and modified by editres (rather recursive, I know); these commandscan be blocked by setting the editresBlock
resource on editres itself.
RESOURCES
For editres, the available application resourcesare asfollows:
numFlashes (ClassNumFlashes) specifiesthe number of timesthe widgetsin the application will be flashed when the Show
Active Widgetscommand in invoked.
125
flashTime (ClassFlashTime) specifiesthe mount of time between the flashesdescribed in the preceding entry.
flashColor (ClassflashColor) specifiesthe color used to flash application widgets. A bright color should be used that will
immediately draw your attention to the area being flashed, such asred or yellow.
saveResourcesFile (ClassSaveResourcesFile) isthe file the resource line will be append to when the Save button activated in
the resource box.
WIDGETS
In order to specify resources, it isuseful to know the hierarchy of the widgetsthat compose editres. In the following
notation, indentation indicateshierarchical structure. The widget classname isgiven first, followed by the widget instance
name.
Editres editres
Paned paned
Box box
MenuButton commands
SimpleMenu menu
SmeBSB sendTree
SmeBSB refreshTree
SmeBSB dumpTreeToFile
SmeLine line SmeBSB getResourceList
SmeLine line
SmeBSB quit
MenuButton treeCommands
SimpleMenuumenu
SmeBSB showClientWidget
SmeBSB selectAll
SmeBSB unselectAll
SmeBSB invertAll
SmeLine line
SmeBSB selectChildren
SmeBSB selectParent
SmeBSB selectDescendants
SmeBSB selectAncestors
SmeLine line
SmeBSB showWidgetNames
SmeBSB showClassNames
SmeBSB showWidgetIDs
SmeBSB showWidgetWindows
SmeLine line
SmeBSB flashActiveWidgets
Paned hPane
Panner panner
Label userMessage
Grip grip
Porthole porthole
Tree tree
Toggle <name of widget in application>
.
.
.
TransientShell resourceBox
Paned pane
Label resourceLabel
Form namesAndClasses
Toggle dot
Toggle star
Toggle any
Toggle name
editres
Part I: User Commands
126
Toggle class
.
.
.
Label namesLabel
List namesList
Label constraintLabel
List constraintList
Form valueForm
Label valueLabel
Text valueText
Box commandBox
Command setFile
Command save
Command apply
Command saveAndApply
Command cancel
Grip grip
Grip grip
ENVIRONMENT
DISPLAY To get the default host and display number
XENVIRONMENT To get the name of a resource file that overridesthe global resourcesstored in the RESOURCE_MANAGER
property.
FILES
<XRoot>/lib/X11/app-defaults/Editres specifiesrequired resources.
SEE ALSO
X(1), xrdb(1), Athena Widget Set
RESTRICTIONS
Thisisa prototype. There are lotsof nifty featuresI would love to add, but I hope thiswill give you some ideasabout what a
resource editor can do.
AUTHOR
ChrisD. Peterson (formerly MIT X Consortium)
X Version 11 Release 6
elvis, ex, vi, view, input
elvis, ex, vi, view, inputThe editor
SYNOPSIS
elvis [f l ags][+cmd][f i l es...]
DESCRIPTION
elvis isa text editor that emulatesvi/ex.
On systemswhich passthe program name asan argument, such asUNIX and Minix, you may also install elvis under the
namesex, vi, view, and input. These extra nameswould normally be linksto elvis; see the ln shell command.
127
When elvis isinvoked asvi, it behavesexactly asthough it wasinvoked aselvis. However, if you invoke elvis asview, then
the readonly option isset asthough you had given it the -R flag. If you invoke elvis asex, then elvis will start up in the
colon command mode instead of the visual command mode, asthough you had given it the -e flag. If you invoke elvis as
input or edit, then elvis will start up in input mode, asthough the -i flag wasgiven.
OPTIONS
-r To the real vi, thisflag meansthat a previousedit should be recovered. elvis, though, hasa
separate program, called elvrec(1), for recovering files. When you invoke elvis with -r, elvis will
tell you to run elvrec.
-R Thissetsthe readonly option, so you wont accidentally overwrite a file.
-s Thissetsthe safer option, which disablesmany potentially harmful commands. It hasnot been
rigorously proven to be absolutely secure, however.
-t t ag Thiscauseselvis to start editing at the given tag.
-m [f i l e] elvis will search through f i l e for something that lookslike an error message from a compiler. It
will then begin editing the source file that caused the error, with the cursor sitting on the line where
the error wasdetected. If you dont explicitly name a file, then errlist isassumed.
-e elvis will start up in colon command mode.
-v elvis will start up in visual command mode.
-i elvis will start up in input mode.
-w winsize Setsthe window optionsvalue to winsize.
+command or -c command If you use the +command parameter, then after the first file isloaded, command isexecuted asan EX
command. A typical example would be elvis +237 foo, which would cause elvis to start editing
foo and then move directly to line 237. The -c command variant wasadded for UNIX SysV
compatibility.
FILES
/tmp/elv* During editing, elvis storestext in a temporary file. For UNIX, thisfile will usually be stored in
the /tmp directory, and the first three characterswill be elv. For other systems, the temporary files
may be stored someplace else; see the version-specific section of the documentation.
tags Thisisthe database used by the :tags command and the -t option. It isusually created by the
ctags(1) program.
.exrc or elvis.rc On UNIX-like systems, a file called .exrc in your home directory isexecuted asa seriesof ex
commands. A file by the same name may be executed in the current directory, too. On non-UNIX
systems, .exrc isusually an invalid filename; there, the initialization file iscalled elvis.rc instead.
ENVIRONMENT
TERM Thisisthe name of your terminalsentry in the termcap or terminfo database. The list of legal
valuesvariesfrom one system to another.
TERMCAP Optional. If your system usestermcap, and the TERMCAP variable isunset, then elvis will read your
terminalsdefinition from /etc/termcap. If TERMCAP isset to the full pathname of a file (starting with
a /) then elvis will look in the named file instead of /etc/termcap. If TERMCAP isset to a value which
doesnt start with a /, then itsvalue isassumed to be the full termcap entry for your terminal.
TERMINFO Optional. If your system usesterminfo, and the TERMINFO variable isunset, then elvis will read your
terminalsdefinition from the database in the /usr/lib/terminfo database. If TERMINFO isset, then its
value isused asthe database name to use instead of /usr/lib/terminfo.
LINES, COLUMNS Optional. These variables, if set, will override the screen size valuesgiven in the termcap/terminfo
for your terminal. On windowing systemssuch asX, elvis hasother waysof determining the
screen size, so you should probably leave these variablesunset.
EXINIT Optional. Thisvariable can hold EX commandswhich will be executed instead of the .exrc file in
your home directory.
eluis, ex, vi, niew, input
Part I: User Commands
128
SHELL Optional. The SHELL variable setsthe default value for the shell option, which determineswhich
shell program isused to perform wildcard expansion in filenames, and also which isused to execute
filtersor external programs. The default value on UNIX systemsis/bin/sh.
Note: Under MS-DOS, thisvariable iscalled COMSPEC instead of SHELL.
HOME Thisvariable should be set to the name of your home directory. elvis looksfor itsinitialization file
there; if HOME isunset, then the initialization file will not be executed.
TAGPATH Optional. Thisvariable isused by the ref program, which isinvoked by the shift-K, control-],
and :tag commands. See ref for more information.
TMP, TEMP These optional environment variablesare only used in non-UNIX versionsof elvis. They allow
you to supply a directory name to be used for storing temporary files.
SEE ALSO
ctags(1), ref(1), elvprsv(1), elvrec(1)
ElvisA Cloneof Vi/Ex, the complete elvis documentation.
BUGS
There isno Lisp support. Certain other featuresare missing, too.
Auto-indent mode isnot quite compatible with the real vi. Among other things, 0D and D dont do what you might
expect.
Long linesare displayed differently. The real vi wrapslong linesonto multiple rowsof the screen, but elvis scrollssideways.
AUTHOR
Steve Kirkendall (kirkenda@cs.pdx.edu)
Many other people have worked to port elvis to variousoperating systems. To see who deservescredit, run the :version
command from within elvis, or look in the system-specific section of the complete documentation.
elvprsv
elvprsvPreserve the modified version of a file after a crash
SYNOPSIS
elvprsv [why elvis died] /tmp/f i l ename...
elvprsv -R /tmp/f i l ename...
DESCRIPTION
elvprsv preservesyour edited text after elvis dies. The text can be recovered later, via the elvprsv program.
For UNIX-like systems, you should never need to run thisprogram from the command line. It isrun automatically when
elvis isabout to die, and it should be run (via /etc/rc) when the computer isbooted. THATS ALL!
For non-UNIX systemssuch asMS-DOS or VMS, you can either use elvprsv the same way asunder UNIX systems(by
running it from your AUTOEXEC.BAT file), or you can run it separately with the -R flag to recover the filesin one step.
If youre editing a file when elvis dies(due to a bug, system crash, power failure, and so on), then elvprsv will preserve the
most recent version of your text. The preserved text isstored in a special directory; it doesnot overwrite your text file
automatically. (If the preservation directory hasnt been set up correctly, then elvprsv will simply send you a mail message
describing how to manually run elvprsv.)
elvprsv will send mail to any user whose work it preserves, if your operating system normally supportsmail.
129
FILES
/tmp/elv* The temporary file that elvis wasusing when it died.
/usr/preserve/p* The text that ispreserved by elvprsv.
/usr/preserve/Index A text file which liststhe namesof all preserved files, and the namesof the /usr/preserve/p* files
that contain their preserved text.
BUGS
Due to the permissionson the /usr/preserve directory, on UNIX systemselvprsv must be run assuperuser. Thisis
accomplished by making the elvprsv executable be owned by root and turning on itsset user id bit.
If youre editing a namelessbuffer when elvis dies, then elvprsv will pretend that the file wasnamed foo.
AUTHOR
Steve Kirkendall (kirkenda@cs.pdx.edu)
elvrec
elvrec Recover the modified version of a file after a crash
SYNOPSIS
elvrec [pr eser vedf i l e [newf i l e]]
DESCRIPTION
If youre editing a file when elvis dies, the system crashes, or power fails, the most recent version of your text will be
preserved. The preserved text isstored in a special directory; it doesnot overwrite your text file automatically.
The elvrec program locatesthe preserved version of a given file, and writesit over the top of your text fileor to a new file,
if you prefer. The recovered file will have nearly all of your changes.
To see a list of all recoverable files, run elvrec with no arguments.
NOTE
If you havent set up a directory for file preservation, youll have to manually run the elvprsv program instead of elvrec.
FILES
/usr/preserve/p* The text that waspreserved when elvis died.
/usr/preserve/Index A text file that liststhe namesof all preserved files, and the namesof the /usr/preserve/p* filesthat
contain their preserved text.
BUGS
elvrec isvery picky about filenames. You must tell it to recover the file using exactly the same pathname aswhen you were
editing it. The simplest way to do thisisto go into the same directory that you were editing, and invoke elvrec with the
same filename aselvis. If that doesnt work, then try running elvrec with no arguments, to see exactly which pathname it is
using for the desired file.
Due to the permissionson the /usr/preserve directory, on UNIX systemselvrec must be run assuperuser. Thisis
accomplished by making the elvrec executable be owned by root and setting itsset user id bit.
If youre editing a namelessbuffer when elvis dies, then elvrec will pretend that the file wasnamed foo.
elvrec
Part I: User Commands
130
AUTHOR
Steve Kirkendall (kirkenda@cs.pdx.edu)
emacs
emacsGNU project emacs
SYNOPSIS
emacs [ command-line switches ] [ f i l es ... ]
DESCRIPTION
GNU emacs isa version of emacs, written by the author of the original (PDP-10) emacs, Richard Stallman.
The primary documentation of GNU emacs isin the GNU EmacsManual, which you can read online using info, a
subsystem of emacs. Please look there for complete and up-to-date documentation. Thisman page isupdated only when
someone volunteersto do so; the emacs maintainers priority goal isto minimize the amount of time thisman page takes
away from other more useful projects.
The user functionality of GNU emacs encompasseseverything other emacs editorsdo, and it iseasily extensible since its
editing commandsare written in Lisp.
emacs hasan extensive interactive help facility, but the facility assumesthat you know how to manipulate emacs windowsand
buffers. Ctrl+h (backspace or Ctrl+h) entersthe Help facility. Help Tutorial (Ctrl+h t) requestsan interactive tutorial that
can teach beginnersthe fundamentalsof emacs in a few minutes. Help Apropos(Ctrl+h a) helpsyou find a command given
itsfunctionality, Help Character (Ctrl+h c) describesa given characterseffect, and Help Function (Ctrl+h f) describesa
given Lisp function specified by name.
emacssUndo can undo several stepsof modification to your buffers, so it iseasy to recover from editing mistakes.
GNU emacssmany special packageshandle mail reading (RMail) and sending (Mail), outline editing (Outline), compiling
(Compile), running subshellswithin emacs windows(Shell), running a Lisp read-eval-print loop (Lisp-Interaction-Mode), and
automated psychotherapy (Doctor).
There isan extensive reference manual, but usersof other emacsesshould have little trouble adapting even without a copy.
Usersnew to emacs will be able to use basic featuresfairly rapidly by studying the tutorial and using the self-documentation
features.
OPTIONS
The following optionsare of general interest:
f i l e Edit f i l e.
+number Go to the line specified by number (do not insert a space between the + sign and the number).
q Do not load an init file.
u user Load usersinit file.
t f i l e Use specified file asthe terminal instead of using stdin/stdout. Thismust be the first argument specified
in the command line.
The following optionsare Lisp-oriented (these optionsare processed in the order encountered):
f f unct i on Execute the Lisp function f unct i on.
l f i l e Load the Lisp code in the file f i l e.
The following optionsare useful when running emacs asa batch editor:
batch Edit in batch mode. The editor will send messagesto stdout. Thisoption must be the first in the
argument list. You must use -l and -f optionsto specify filesto execute and functionsto call.
kill Exit emacs while in batch mode.
131
USING emacs WITH X
emacs hasbeen tailored to work well with the X Window System. If you run emacs from under X windows, it will create its
own X window to display in. You will probably want to start the editor asa background processso that you can continue
using your original window.
emacs can be started with the following X switches:
rn name Specifiesthe program name which should be used when looking up defaultsin the
usersX resources. Thismust be the first option specified in the command line.
name name Specifiesthe name that should be assigned to the emacs window.
-r Display the emacs window in reverse video.
-i Use the kitchen sink bitmap icon when iconifying the emacs window.
font f ont , fn f ont Set the emacs windowsfont to that specified by font. You will find the variousX
fontsin the /usr/lib/X11/fonts directory. Note that emacs will only accept fixed
width fonts. Under the X11 Release 4 font-naming conventions, any font with the
value m or c in the eleventh field of the font name isa fixed width font. Furthermore,
fontswhose name are of the form widthheight are generally fixed width, asisthe
font fixed. See xlsfonts(1) for more information.
When you specify a font, be sure to put a space between the switch and the font
name.
b pi xel s Set the emacs windowsborder width to the number of pixelsspecified by pixels.
Defaultsto one pixel on each side of the window.
ib pi xel s Set the windowsinternal border width to the number of pixelsspecified by pi xel s.
Defaultsto one pixel of padding on each side of the window.
geometry geomet r y Set the emacs windowswidth, height, and position asspecified. The geomet r y
specification isin the standard uformat; see X(1) for more information. The width
and height are specified in characters; the default is80 by 24.
fg col or On color displays, setsthe color of the text. See the file /usr/lib/X11/rgb.txt for a
list of valid color names.
bg col or On color displays, setsthe color of the windowsbackground.
bd col or On color displays, setsthe color of the windowsborder.
cr col or On color displays, setsthe color of the windowstext cursor.
ms col or On color displays, setsthe color of the windowsmouse cursor.
d di spl ayname, display di spl ayname Create the emacs window on the display specified by di spl ayname. Must be the first
option specified in the command line.
nw Tellsemacs not to use itsspecial interface to X. If you use thisswitch when invoking
emacs from an xterm(1) window, display isdone in that window. Thismust be the
first option specified in the command line.
You can set X default valuesfor your emacs windowsin your Xresources file; see xrdb(1). Use the following format:
emacs.keywor d:val ue
where val ue specifiesthe default value of keywor d. emacs letsyou set default valuesfor the following keywords:
font (classFont) Setsthe windowstext font.
reverseVideo (classReverseVideo) If reverseVideosvalue isset to on, the window will be displayed in reverse video.
bitmapIcon (classBitmapIcon) If bitmapIconsvalue isset to on, the window will iconify into the kitchen sink.
borderWidth (classBorderWidth) Setsthe windowsborder width in pixels.
internalBorder (classBorderWidth) Setsthe windowsinternal border width in pixels.
foreground (classForeground) For color displays, setsthe windowstext color.
background (classBackground) For color displays, setsthe windowsbackground color.
borderColor (classBorderColor) For color displays, setsthe color of the windowsborder.
emacs
Part I: User Commands
132
cursorColor (classForeground) For color displays, setsthe color of the windowstext cursor.
pointerColor (classForeground) For color displays, setsthe color of the windowsmouse cursor.
geometry (classGeometry) Setsthe geometry of the emacs window.
title (classTitle) Setsthe title of the emacs window.
iconName (classTitle) Setsthe icon name for the emacs window icon.
If you try to set color valueswhile using a black-and-white display, the windowscharacteristicswill default asfollows: The
foreground color will be set to black, the background color will be set to white, the border color will be set to gray, and the
text and mouse cursorswill be set to black.
USING THE MOUSE
The following liststhe mouse button bindingsfor the emacs window under X11.
MouseButton Function
left Set point.
middle Paste text.
right Cut text into X cut buffer.
Shift+middle Cut text into X cut buffer.
Shift+right Paste text.
Ctrl+middle Cut text into X cut buffer and kill it.
Ctrl+right Select thiswindow, then split it into two windows. Same astyping Ctrl+x 2.
Ctrl+Shift+left X buffer menu; hold the buttonsand keysdown, wait for menu to appear, select buffer, and
release. Move mouse out of menu and release to cancel.
Ctrl+Shift+middle X help menu; pop up index card menu for emacs help.
Ctrl+Shift+right Select window with mouse, and delete all other windows. Same astyping Ctrl+x 1.
MANUALS
You can order printed copiesof the GNU EmacsManual from the Free Software Foundation, which developsGNU
software. See the file ORDERS for ordering information.
Your local emacs maintainer might also have copiesavailable. Aswith all software and publicationsfrom FSF, everyone is
permitted to make and distribute copiesof the emacs manual. The TeX source to the manual isalso included in the emacs
source distribution.
FILES
/usr/local/info Filesfor the info documentation browser (a subsystem of emacs) to
refer to. Currently not much of UNIX isdocumented here, but the
complete text of the emacs reference manual isincluded in a
convenient tree structured form.
/usr/local/lib/emacs/$VERSION/src C source filesand object files.
/usr/local/lib/emacs/$VERSION/lisp Lisp source filesand compiled filesthat define most editing com-
mands. Some are preloaded; othersare autoloaded from thisdirectory
when used.
/usr/local/lib/emacs/$VERSION/etc Variousprogramsthat are used with GNU emacs, and some filesof
information.
/usr/local/lib/emacs/$VERSION/etc/DOC.* Containsthe documentation stringsfor the Lisp primitivesand
preloaded Lisp functionsof GNU emacs. They are stored here to
reduce the size of emacs proper.
133
/usr/local/lib/emacs/$VERSION/etc/DIFF DiscussesGNU emacs versusTwenex emacs.
/usr/local/lib/emacs/$VERSION/etc/CCADIFF DiscussesGNU emacs versusCCA emacs.
/usr/local/lib/emacs/$VERSION/etc/GOSDIFF DiscussesGNU emacs versusGosling emacs.
/usr/local/lib/emacs/$VERSION/etc/SERVICE Listspeople offering variousservicesto assist usersof GNU emacs,
including education, troubleshooting, porting, and customization.
These filesalso have information useful to anyone wanting to write
programsin the emacsLisp extension language, which hasnot yet
been fully documented.
/usr/local/lib/emacs/lock Holdslock filesthat are made for all filesbeing modified in emacs, to
prevent simultaneousmodification of one file by two users.
/usr/local/lib/emacs/$VERSION/$ARCHITECTURE/cpp The GNU cpp, needed for building emacs on certain versionsof
UNIX where the standard cpp cannot handle long namesfor macros.
/usr/lib/X11/rgb.txt List of valid X color names.
BUGS
There isa mailing list, bug-gnu-emacs@prep.ai.mit.edu on the Internet (ucbvax!prep.ai.mit.edu!bug-gnu-emacs on
UUCPnet), for reporting emacs bugsand fixes. But before reporting something asa bug, please try to be sure that it really isa
bug, not a misunderstanding or a deliberate feature. We ask you to read the section Reporting emacs Bugs near the end of
the reference manual (or info system) for hintson how and when to report bugs. Also, include the version number of the
emacs you are running in every bug report that you send in.
Do not expect a personal answer to a bug report. The purpose of reporting bugsisto get them fixed for everyone in the next
release, if possible. For personal assistance, look in the SERVICE file for a list of people who offer it.
Please do not send anything but bug reportsto thismailing list. Send requeststo be added to mailing liststo the special list
info-gnu-emacs-request@prep.ai.mit.edu (or the corresponding UUCP address). For more information about emacs mailing
lists, see the file /usr/local/emacs/etc/MAILINGLISTS. Bugstend actually to be fixed if they can be isolated, so it isin your
interest to report them in such a way that they can be easily reproduced.
One bug that I know about: Shell will not work with programsrunning in Raw mode on some UNIX versions.
UNRESTRICTIONS
emacs isfree; anyone may redistribute copiesof emacs to anyone under the termsstated in the emacs General Public License, a
copy of which accompanieseach copy of emacs and which also appearsin the reference manual.
Copiesof emacs may sometimesbe received packaged with distributionsof UNIX systems, but it isnever included in the
scope of any license covering those systems. Such inclusion violatesthe termson which distribution ispermitted. In fact, the
primary purpose of the General Public License isto prohibit anyone from attaching any other restrictionsto redistribution
of emacs.
Richard Stallman encouragesyou to improve and extend emacs, and urgesthat you contribute your extensionsto the GNU
library. Eventually GNU (GNUsNot UNIX) will be a complete replacement for Berkeley UNIX. Everyone will be free to
use, copy, study, and change the GNU system.
SEE ALSO
X(1), xlsfonts(1), xterm(1), xrdb(1)
AUTHORS
emacs waswritten by Richard Stallman and the Free Software Foundation. Joachim Martillo and Robert Krawitz added the X
features.
19 April 1994
emacs
Part I: User Commands
134
emacstool
emacstoolRun emacs under Sun windowswith function key and mouse support.
SYNOPSIS
emacstool [{window_args} {-rc run_command_path} args ... ]
TYPICAL USAGE
In /.suntools or /.rootmenu, include a line like this:
Emacstool emacstool -WI emacs.icon -f emacstool-init
DESCRIPTION
emacstool createsa SunView frame and a tty subwindow within which mouse eventsand function keysare translated to
ASCII sequencesthat emacs can parse. The translated input eventsare sent to the processrunning in the tty subwindow,
which istypically GNU emacs. emacstool thereby allowsGNU emacs usersto make full use of the mouse and function keys.
GNU emacs can be loaded with functionsto interpret the mouse and function-key eventsto make a truly fine screen-oriented
editor for the Sun Workstation.
NOTE
GNU emacs hasa special interface to the X Window System aswell. The X Window System hasmany technical advan-
tages, it isan industry standard, and it isalso free software. The Free Software Foundation urgesyou to try X Windows,
and distributesa free copy of X on emacs distribution tapes.
Function keysare translated to a sequence of the form ^X*[a-o][lrt]. The last character isl, r, or t, corresponding to
whether the key isamong the Left, Right, or Top function keys. The third character indicateswhich button of the group was
pressed. Thus, the function key in the lower-right corner will transmit the sequence ^X*or. In addition, the [lrt] isaffected
by the Control, Meta, and Shift keys. Unshifted Ctrl keyswill be nonalphabetic: C-l is [,], C-r is[2], C-t is[4].
Mouse buttonsare encoded asX@([124] x y)\n. X@ isthe standard GNU emacs mouse event prefix; it isfollowed by a list
indicating the button pressed and the character row and column of the point in the window where the mouse cursor is, and
followed by a newline character. In GNU emacs, the X@ dispatchesto a mouse event handler which then readsthe following
list.
OPTIONS
emacstool supportsall the standard window arguments, including font and icon specifiers.
By default, emacstool runsthe program emacs in the created subwindow. The value of the environment variable EMACSTOOL
can be used to override thisif your version of emacs isnot accessible on your search path by the name emacs. In addition, the
run command can be set by the pathname following the last occurrence of the rc flag. Thisisconvenient for using emacstool
to run on remote machines.
All other command-line argumentsnot used by the window system are passed asargumentsto the program that runsin the
emacstool window.
For example,
local% (emacstool -rc rlogin remote -8 &)&
will create an emacstool window logged in to a machine named remote. If emacs isrun from thiswindow, emacstool will
encode mouse and function keys, and send them to rlogin. If emacs isrun from thisshell on the remote machine, it will see
the mouse and function keysproperly. However, since the remote host doesnot have accessto the screen, the cursor cannot
be changed, menuswill not appear, and the selection buffer (STUFF) islimited.
135
USING WITH GNU emacs
The GNU emacs fileslisp/term/sun.el, lisp/sun-mouse.el, lisp/sun-fns.el, and src/sunfns.c provide emacs support
for the emacstool and function keys. emacstool will automatically set the TERM environment variable to be sun and unset
the environment variable TERMCAP. That is, these variableswill not be inherited from the shell that startsemacstool. Since the
terminal type isSUN (that is, the environment variable TERM isset to SUN), emacs will automatically load the file lisp/term/sun.
This, in turn, will ensure that sun-mouse.el isautoloaded when any mouse eventsare detected. It issuggested that sun-mouse
and sun-fns be loaded in your site-init.el file, so that they will alwaysbe loaded when running on a Sun workstation.
In addition, emacstool setsthe environment variable IN_EMACSTOOL = t. Lisp code in your /.emacs can use (getenv
IN_EMACSTOOL) to determine whether to do emacstool-specific initialization. Sun.el usesthisto automatically call emacstool-
init if (getenv IN_EMACSTOOL) isdefined.
The file src/sunfns.c definesseveral useful functionsfor emacs on the Sun. Among these are proceduresto pop up SunView
menus, put and get from the SunView STUFF buffer, and a procedure for changing the cursor icon. If you want to define or
edit cursor icons, there isa rudimentary mouse-driven icon editor in the file lisp/sun-cursors.el. Try invoking (sc:edit-
cursor).
BUGS
It takesa few millisecondsto create a menu before it popsup.
ENVIRONMENT VARIABLES
EMACSTOOL, IN_EMACSTOOL, TERM, TERMCAP
FILES
emacs
SEE ALSO
emacs(1), .../etc/SUN-SUPPORT, .../lisp/term/sun.el
etags
etagsGenerate tag file for emacs
ctagsGenerate tag file for vi
SYNOPSIS
etags [ aCDSVH] [ i f i l e ][o t agf i l e ]
[ --c++ ] [ --nodefines] [ --ignoreindentation ] [ --help ] [ --version ]
[ --include=f i l e ] [ --output=t agf i l e ] [ --append ] f i l e ...
ctags [ aCdSVH] [ BtTuvwx ] [ o t agf i l e ]
[ --c++ ] [ --defines ] [ --ignoreindentation ]
[ --backwardsearch] [ --forwardsearch ] [ --typedefs ] [ --typedefsandc++]
[ --nowarn ] [ --cxref ] [ --help ] [ --version ]
[ --output=t agf i l e ] [ --append ] [ --update ] f i l e ...
DESCRIPTION
The etags program isused to create a tag table file, in a format understood by emacs(1); the ctags program isused to create a
similar table in a format understood by vi(1) . Both formsof the program understand the syntax of C, FORTRAN, Pascal,
LaTeX, Scheme, emacs Lisp/Common Lisp, and most assemblerlike syntaxes. Both formsread the filesspecified on the
command line, and write a tag table (defaults: TAGS for etags, tags for ctags) in the current working directory. The programs
recognize the language used in an input file based on itsfilename and contents; there are no switchesfor specifying the
language.
etags
Part I: User Commands
136
OPTIONS
Some optionsmake sense only for the vi-style tag filesproduced by ctags; etags doesnot recognize them. The programs
accept unambiguousabbreviationsfor long option names.
a, --append Append to existing tag file. (For vi-format tag files, see also --update.)
B, --backwardsearch Tag fileswritten in the format expected by vi contain regular expression search instructions;
the B option writesthem using the delimiter ?, to search backwardsthrough files. The
default isto use the delimiter / to search forwardsthrough files. Only ctags acceptsthis
option.
C, --c++ Treat fileswith .c and .h extensionsasC++ code, not C code. Fileswith .C, .H, .cxx, .hxx,
or .cc extensionsare alwaysassumed to be C++ code.
d, --defines Create tag entriesfor C preprocessor definitions, too. Thisisthe default behavior for etags,
so thisoption isonly accepted by ctags.
D, --nodefines Do not create tag entriesfor C preprocessor definitions. Thismay make the tagsfile much
smaller if many header filesare tagged. Thisisthe default behavior for ctags, so thisoption
isonly accepted by etags.
-i file, --include=f i l e Include a note in tag file indicating that, when searching for a tag, one should also consult
the tagsfile f i l e after checking the current file. Only etags acceptsthisoption.
o tagfile, --output=t agf i l e Explicit name of file for tag table; overridesdefault TAGS or tags. (But ignored with v or
x.)
S, --ignoreindentation Dont rely on indentation asmuch aswe normally do. Currently, thismeansnot to assume
that a closing brace in the first column isthe final brace of a function or structure definition
in C and C++.
t, --typedefs Record typedefs in C code astags. Since thisisthe default behavior of etags, only ctags
acceptsthisoption.
T, --typedefsandc++ Generate tag entriesfor typedefs, struct, enum, and union tags, and C++ member functions.
Since thisisthe default behavior of etags, only ctags acceptsthisoption.
u, --update Update tag entriesfor filesspecified on command line, leaving tag entriesfor other filesin
place. Currently, thisisimplemented by deleting the existing entriesfor the given filesand
then rewriting the new entriesat the end of the tagsfile. It isoften faster to simply rebuild
the entire tag file than to use this. Only ctags acceptsthisoption.
v, --vgrind Instead of generating a tag file, write index (in vgrind format) to standard output. Only
ctags acceptsthisoption.
w, --nowarn Suppresswarning messagesabout duplicate entries. The etags program doesnot check for
duplicate entries, so thisoption isnot allowed with it.
x, --cxref Instead of generating a tag file, write a cross-reference (in cxref format) to standard output.
Only ctags acceptsthisoption.
H, --help Print usage information.
V, --version Print the current version of the program (same asthe version of the emacs etags isshipped
with).
SEE ALSO
emacs entry in info; GNU EmacsManual, Richard Stallman.
cxref(1), emacs(1), vgrind(1), vi(1).
COPYING
Copyright 1992 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim copiesof this
manual provided the copyright notice and thispermission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
137
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
GNU Tools, 19 April 1994
expand
expandConvert tabsto spaces
SYNOPSIS
expand [t ab1[,t ab2[,...]]] [t t ab1[,t ab2[,...]]] [i] [tabs=t ab1[,t ab2[,...]]]
[--initial] [--help] [--version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of expand. expand writesthe contentsof each given file, or the standard input
if none are given or when a file named isgiven, to the standard output, with tab charactersconverted to the appropriate
number of spaces. By default, expand convertsall tabsto spaces. It preservesbackspace charactersin the output; they
decrement the column count for tab calculations. The default action isequivalent to 8 (set tabsevery 8 columns).
OPTIONS
, t, --tabs t ab1[,t ab2[,...]] If only one tab stop isgiven, set the tabst ab1 spacesapart instead of the default 8.
Otherwise, set the tabsat columns t ab1, t ab2, and so forth (numbered from 0) and
replace any tabsbeyond the tab stopsgiven with single spaces. If the tab-stopsare
specified with the t or --tabs option, they can be separated by blanksaswell asby
commas.
-i, --initial Only convert initial tabs(those that precede all nonspace or tab characters) on each
line to spaces.
--help Print a usage message and exit with a nonzero status.
--version Print version information on standard output then exit.
GNU Text Utilities
find
findSearch for filesin a directory hierarchy
SYNOPSIS
find [path...] [expr essi on]
DESCRIPTION
Thismanual page documentsthe GNU version of find. find searchesthe directory tree rooted at each given filename by
evaluating the given expression from left to right, according to the rulesof precedence (see Operators, later in thismanual
page), until the outcome isknown (the left side isFalse for AND operations, True for OR), at which point find moveson to the
next filename.
The first argument that beginswith , (, ), ,, or ! istaken to be the beginning of the expression; any argumentsbefore it are
pathsto search, and any argumentsafter it are the rest of the expression. If no pathsare given, the current directory isused. If
no expression isgiven, the expression print isused.
find exitswith status0 if all filesare processed successfully, greater than 0 if errorsoccur.
find
Part I: User Commands
138
EXPRESSIONS
The expression ismade up of options(which affect overall operation rather than the processing of a specific file, and always
return True), tests(which return a True or False value), and actions(which have side effectsand return a True or False value),
all separated by operators. and isassumed where the operator isomitted. If the expression containsno actionsother than
prune, print isperformed on all filesfor which the expression istrue.
OPTIONS
All optionsalwaysreturn True. They alwaystake effect, rather than being processed only when their place in the expression is
reached. Therefore, for clarity, it isbest to place them at the beginning of the expression.
daystart Measure times(for amin, atime, cmin, ctime, mmin, and mtime) from the beginning of today
rather than from 24 hoursago.
depth Processeach directoryscontentsbefore the directory itself.
follow Dereference symbolic links. Impliesnoleaf.
help, help Print a summary of the command-line usage of find and exit.
maxdepth l evel s Descend at most l evel s (a nonnegative integer) levelsof directoriesbelow the command-line
arguments. maxdepth 0 meansonly apply the testsand actionsto the command-line arguments.
mindepth l evel s Do not apply any testsor actionsat levelslessthan l evel s (a nonnegative integer). mindepth 1
meansprocessall filesexcept the command-line arguments.
mount Dont descend directorieson other filesystems. An alternate name for xdev, for compatibility with
some other versionsof find.
noleaf Do not optimize by assuming that directoriescontain two fewer subdirectoriesthan their hard link
count. Thisoption isneeded when searching filesystemsthat do not follow the UNIX directory-
link convention, such asCD-ROM or MS-DOSfilesystemsor AFS volume mount points. Each
directory on a normal UNIX filesystem hasat least 2 hard links: itsname and its. entry. Addition-
ally, itssubdirectories(if any) each have a .. entry linked to that directory. When find isexamining
a directory, after it hasstatted two fewer subdirectoriesthan the directoryslink count, it knows
that the rest of the entriesin the directory are nondirectories(leaf filesin the directory tree). If
only the files namesneed to be examined, there isno need to stat them; thisgivesa significant
increase in search speed.
version, version Print the find version number and exit.
xdev Dont descend directorieson other filesystems.
TESTS
Numeric argumentscan be specified as
+n Greater than n.
n Lessthan n.
n Exactly n.
amin n File waslast accessed n minutesago.
anewer f i l e File waslast accessed more recently than f i l e wasmodified. anewer isaffected by follow only if
follow comesbefore anewer on the command line.
atime n File waslast accessed n*24 hoursago.
cmin n Filesstatuswaslast changed n minutesago.
cnewer f i l e Filesstatuswaslast changed more recently than file wasmodified. cnewer isaffected by follow
only if follow comesbefore cnewer on the command line.
ctime n Filesstatuswaslast changed n*24 hoursago.
empty File isempty and iseither a regular file or a directory.
false Alwaysfalse.
139
fstype t ype File ison a filesystem of type t ype. The valid filesystem typesvary among different versionsof
UNIX; an incomplete list of filesystem typesthat are accepted on some version of UNIX or another
is: ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K. You can use printf with the %F directive to see the types
of your filesystems.
gid n Filesnumeric group ID isn.
group gname File belongsto group gname (numeric group ID allowed).
ilname pat t er n Like lname, but the match iscase-insensitive.
iname pat t er n Like name, but the match iscase-insensitive. For example, the patternsfo* and F?? match the
filenamesFoo, FOO, foo, fOo, and so on.
inum n File hasinode number n.
ipath pat t er n Like path, but the match iscase-insensitive.
iregex pat t er n Like regex, but the match iscase-insensitive.
links n File hasn links.
lname pat t er n File isa symbolic link whose contentsmatch shell pattern pat t er n. The meta charactersdo not treat
/ or . specially.
mmin n Filesdata waslast modified n minutesago.
mtime n Filesdata waslast modified n*24 hoursago.
name pat t er n Base of filename (the path with the leading directoriesremoved) matchesshell pattern pattern. The
meta characters(*, ?, and []) do not match a . at the start of the base name. To ignore a directory
and the filesunder it, use prune; see an example in the description of path.
newer f i l e File wasmodified more recently than file. newer isaffected by follow only if follow comesbefore
newer on the command line.
nouser No user correspondsto filesnumeric user ID.
nogroup No group correspondsto filesnumeric group ID.
path pat t er n Filename matchesshell pattern pattern. The meta charactersdo not treat / or . specially; so, for
example,
find . path ./sr*sc
will print an entry for a directory called ./src/misc (if one exists). To ignore a whole directory tree,
use prune rather than checking every file in the tree. For example, to skip the directory src/emacs
and all filesand directoriesunder it, and print the namesof the other filesfound, do something like
this:
find . path ./src/emacs -prune -o -print
perm mode Filespermission bitsare exactly mode (octal or symbolic). Symbolic modesuse mode 0 asa point
of departure.
perm mode All of the permission bitsmode are set for the file.
perm +mode Any of the permission bitsmode are set for the file.
regex pat t er n Filename matchesregular expression pattern. Thisisa match on the whole path, not a search. For
example, to match a file named ./fubar3, you can use the regular expression .*bar. or .*b.*3, but
not b.*r3.
size n[bckw] File usesn unitsof space. The unitsare 512-byte blocksby default or if b followsn, bytesif c
followsn, kilobytesif k followsn, or 2-byte wordsif w followsn. The size doesnot count indirect
blocks, but it doescount blocksin sparse filesthat are not actually allocated.
true Alwaystrue.
type c File isof type c. Possible types:
b Block (buffered) special
c Character (unbuffered) special
d Directory
p Named pipe (FIFO)
find
Part I: User Commands
140
f Regular file l symbolic link
s Socket
uid n Filesnumeric user ID isn.
used n File waslast accessed n daysafter itsstatuswaslast changed.
user uname File isowned by user uname (numeric user ID allowed).
xtype c The same astype unlessthe file isa symbolic link. For symbolic links: if follow hasnot been
given, True if the file isa link to a file of type c; if follow hasbeen given, True if c isl. In other
words, for symbolic links, xtype checksthe type of the file that type doesnot check.
ACTIONS
exec command; Execute command; True if 0 statusisreturned. All following argumentsto find are taken to be
argumentsto the command until an argument consisting of ; isencountered. The string {} is
replaced by the current filename being processed everywhere it occursin the argumentsto the
command, not just in argumentswhere it isalone, asin some versionsof find. Both of these
constructionsmight need to be escaped (with a \) nor quoted to protect them from expansion by
the shell. The command isexecuted in the starting directory.
fls f i l e True; like ls but write to f i l e like fprint.
fprint f i l e True; print the full filename into file f i l e. If f i l e doesnot exist when find isrun, it iscreated; if it
doesexist, it istruncated. The filenames/dev/stdout and /dev/stderr are handled specially; they
refer to the standard output and standard error output, respectively.
fprint0 f i l e True; like print0 but write to file like fprint.
fprintf f i l e f or mat True; like printf but write to file like fprint.
ok command; Like exec but ask the user first (on the standard input); if the response doesnot start with y or Y,
do not run the command, and return False.
print True; print the full filename on the standard output, followed by a newline.
print0 True; print the full filename on the standard output, followed by a null character. Thisallows
filenamesthat contain newlinesto be correctly interpreted by programsthat processthe find
output.
printf f or mat True; print format on the standard output, interpreting n escapesand % directives. Field widthsand
precisionscan be specified aswith the printf C function. Unlike print, printf doesnot add a
newline at the end of the string. The escapesand directivesare asfollows:
\a Alarm bell
\b Backspace
\c Stop printing from thisformat immediately and flush the output
\f Form feed
\n Newline
\r Carriage return
\t Horizontal tab
\v Vertical tab
\\ A literal backslash (\)
A \ character followed by any other character istreated asan ordinary character, so they both are
printed:
%% A literal percent sign.
%a Fileslast accesstime in the format returned by the C ctime function.
%Ak Fileslast accesstime in the format specified by k, which iseither @ or a directive for the C
strftime function. The possible valuesfor k are listed below; some of them might not be
available on all systems, due to differencesin strftime between systems.
@secondssince Jan. 1, 1970, 00:00 GMT.
141
Timefields:
H Hour (00..23)
I Hour (01..12)
k Hour (0..23)
l Hour (1..12)
M Minute (00..59)
p Localesa.m. or p.m.
r Time, 12-hour (hh:mm:ss [AP]M)
u Second (00..61)
T Time, 24-hour (hh:mm:ss)
X Localestime representation (H:M:S)
Z Time zone (for example, EDT), or nothing if no time zone is
determinable
Datefields:
a Localesabbreviated weekday name (Sun..Sat)
A Localesfull weekday name, variable length (Sunday..Saturday)
b Localesabbreviated month name (Jan..Dec)
B Localesfull month name, variable length (January.. December)
c Localesdate and time (Sat Nov 04 12:02:33 EST 1989)
d Day of month (01..31)
D Date (mm/dd/yy)
h Same asb
j Day of year (001..366)
m Month (01..12)
U Week number of year with Sunday asfirst day of week (00..53)
w Day of week (0..6)
W Week number of year with Monday asfirst day of week (00..53)
x Localesdate representation (mm/dd/yy)
y Last two digitsof year (00..99)
Y Year (1970...)
%b Filessize in 512-byte blocks(rounded up).
%c Fileslast statuschange time in the format returned by the C ctime function.
%Ck Fileslast statuschange time in the format specified by k, which isthe same asfor %A.
%d Filesdepth in the directory tree; 0 meansthe file isa command-line argument.
%f Filesname with any leading directoriesremoved (only the last element).
%F Type of the filesystem the file ison; thisvalue can be used for fstype.
%g Filesgroup name, or numeric group ID if the group hasno name.
%G Filesnumeric group ID.
%h Leading directoriesof filesname (all but the last element).
%H Command-line argument under which file wasfound.
%i Filesinode number (in decimal).
%k Filessize in 1K blocks(rounded up).
%l Object of symbolic link (empty string if file isnot a symbolic link).
find
Part I: User Commands
142
%m Filespermission bits(in octal).
%n Number of hard linksto file.
%p Filesname.
%P Filesname with the name of the command-line argument under which it wasfound
removed.
%s Filessize in bytes.
%t Fileslast modification time in the format returned by the C ctime function.
%Tk Fileslast modification time in the format specified by k, which isthe same asfor %A.
%u Filesusername, or numeric user ID if the user hasno name.
%U Filesnumeric user ID.
A % character followed by any other character isdiscarded (but the other character is
printed).
prune If depth isnot given, True; do not descend the current directory.
If depth isgiven, False; no effect.
ls True; list current file in ls dils format on standard output. The block countsare of 1K blocks,
unlessthe environment variable POSIXLY_CORRECT isset, in which case 512- byte blocksare used.
OPERATORS
Listed in order of decreasing precedence:
( expr ) Force precedence.
! expr True if expr isfalse.
not expr Same as! expr .
expr 1 expr 2 And (implied); expr 2 isnot evaluated if expr 1 isfalse.
expr 1 a expr 2 Same as expr 1 expr 2.
expr 1 and expr 2 Same as expr 1 expr 2.
expr 1 o expr 2 Or; expr 2 isnot evaluated if expr 1 istrue.
expr 1 or expr 2 Same asexpr 1 o expr 2.
expr 1, expr 2 List; both expr 1 and expr 2 are alwaysevaluated. The value of expr 1 isdiscarded; the value of the list
isthe value of expr 2.
SEE ALSO
locate(1L), locatedb(5L), updatedb(1L), xargs(1L) Finding Files(online in info, or printed)
GNU File Utilities
fitstopnm
fitstopnmConvert a FITS file into a portable anymap
SYNOPSIS
fitstopnm [-image N][-noraw][-scanmax][-printmax][-min f][-max f][FI TSf i l e]
DESCRIPTION
Readsa FITS file asinput. Producesa portable pixmap if the FITS file consistsof 3 image planes(NAXIS = 3 and NAXIS3 = 3),
a portable graymap if the FITS file consistsof 2 image planes(NAXIS = 2), or whenever the image flag isspecified. The
resultsmay need to be flipped top for bottom; if so, just pipe the output through pnmflip -tb.
143
OPTIONS
The -image option isfor FITS fileswith three axes. The assumption isthat the third axisisfor multiple images, and this
option letsyou select which one you want.
Flags-min and -max can be used to override the min and max valuesasread from the FITS header or the image data if no
DATAMIN and DATAMAX keywordsare found. Flag -scanmax can be used to force the program to scan the data even when DATAMIN
and DATAMAX are found in the header. If -printmax isspecified, the program will just print the min and max valuesand quit.
Flag -noraw can be used to force the program to produce an ASCII portable anymap.
The program will tell what kind of anymap iswriting. All flagscan be abbreviated to their shortest unique prefix.
REFERENCES
FITS standsfor Flexible Image Transport System. A full description can be found in Astronomy& AstrophysicsSupplement
Series44 (1981), page 363.
SEE ALSO
pnmtofits(1), pgm(5), pnmflip(1)
AUTHOR
Copyright 1989 by Jef Poskanzer, with modificationsby Daniel Briggs(dbriggs@nrao.edu) and Alberto Accomazzi
(alberto@cfa.harvard.edu)
20 September 1989
fmt
fmtAdjust line-length for paragraphsof text
SYNOPSIS
fmt [wi dt h][f i l es]...
DESCRIPTION
fmt isa simple text formatter. It insertsor deletesnewlines, asnecessary, to make all linesin a paragraph be approximately the
same width. It preservesindentation and word spacing.
The default line width is72 characters. You can override thiswith the width flag. If you dont name any fileson the
command line, then fmt will read from stdin.
It istypically used from within vi to adjust the line breaksin a single paragraph. To do this, move the cursor to the top of
the paragraph, type !gfmt, and pressReturn.
AUTHOR
Steve Kirkendall (kirkenda@cs.pdx.edu)
fold
foldWrap each input line to fit in specified width
SYNOPSIS
fold [bs] [w wi dt h] [bytes] [spaces] [width=wi dt h] [help]
[version] [f i l e...]
fold
Part I: User Commands
144
DESCRIPTION
Thismanual page documentsthe GNU version of fold. fold printsthe specified files, or the standard input when no filesare
given or the filename isencountered, on the standard output. It breakslong linesinto multiple shorter linesby inserting a
newline at column 80. It countsscreen columns, so tab charactersusually take more than one column, backspace characters
decrease the column count, and carriage return charactersset the column count back to zero.
OPTIONS
b, bytes Count bytesrather than columns, so that tabs, backspaces, and carriage returnsare each counted as
taking up one column, just like other characters.
s, spaces Break at word boundaries. If the line containsany blanks, the line isbroken after the last blank that
fallswithin the maximum line length. If there are no blanks, the line isbroken at the maximum
line length, asusual.
w, width wi dt h Use a maximum line length of width columnsinstead of 80.
help Print a usage message and exit with a nonzero status.
version Print version information on standard output then exit.
GNU Text Utilities
free
freeDisplay amount of free and used memory in the system
SYNOPSIS
free [-b | -k | -m] [-o] [-s del ay ] [-t]
DESCRIPTION
free displaysthe total amount of free and used physical and swap memory in the system, aswell asthe shared memory and
buffersused by the kernel.
OPTIONS
The -b switch displaysthe amount of memory in bytes; the -k switch (set by default) displaysit in kilobytes; the -m switch
displaysit in megabytes.
The -t switch displaysa line containing the totals.
The -o switch disablesthe display of a buffer adjusted line. Unlessspecified free subtracts/addsbuffer memory from/to the
used/free memory reports(respectively!).
The -s switch activatescontinuouspolling delay secondsapart. You may actually specify any floating point number for
delay, usleep(3) isused for microsecond resolution delay times.
FILES
/proc/meminfo Memory information
SEE ALSO
ps(1), top(1)
AUTHORS
Brian Edmonds
Cohesive Systems, 20 March 1993
145
fsinfo
fsinfoX font server information utility
SYNOPSIS
fsinfo [server ser ver name]
DESCRIPTION
fsinfo isa utility for displaying information about an X font server. It isused to examine the capabilitiesof a server, the
predefined valuesfor variousparametersused in communicating between clientsand the server, and the font cataloguesand
alternate serversthat are available.
EXAMPLE
The following isa sample produced by fsinfo.
name of server: hansen:7100
version number: 1
vendor string: Font Server Prototype
vendor release number: 17
maximum request size: 16384 longwords (65536 bytes)
number of catalogues: 1
all
Number of alternate servers: 2
#0 hansen:7101
#1 hansen:7102
number of extensions: 0
ENVIRONMENT
FONTSERVER To get the default fontserver
SEE ALSO
xfs(1), fslsfonts(1)
AUTHOR
Dave Lemke (Network Computing Devices, Inc.)
X Version 11 Release 6
fslsfonts
fslsfontsList fontsserved by X font server
SYNOPSIS
fslsfonts [options ...] [fn pat t er n]
DESCRIPTION
fslsfonts liststhe fontsthat match the given pattern. The wildcard character * may be used to match any sequence of
characters(including none), and ? to match any single character. If no pattern isgiven, * isassumed.
The * and ? charactersmust be quoted to prevent them from being expanded by the shell.
OPTIONS
server host : por t Thisoption specifiesthe X font server to contact.
l Listssome attributesof the font on one line in addition to itsname.
fslsfonts
Part I: User Commands
146
ll Listsfont propertiesin addition to l output.
lll Supported for compatibility with xlsfonts, but output isthe same asfor ll.
m Thisoption indicatesthat long listingsshould also print the minimum and maximum boundsof
each font.
C Thisoption indicatesthat listingsshould use multiple columns. Thisisthe same asn 0.
1 Thisoption indicatesthat listingsshould use a single column. Thisisthe same asn 1.
w wi dt h Thisoption specifiesthe width in charactersthat should be used in figuring out how many
columnsto print. The default is79.
n col umns Thisoption specifiesthe number of columnsto use in displaying the output. The default is0,
which will attempt to fit asmany columnsof font namesinto the number of character specified by
w width.
u Thisoption indicatesthat the output should be left unsorted.
SEE ALSO
xfs(1), showfont(1), xlsfonts(1)
ENVIRONMENT
FONTSERVER To get the default host and port to use
BUGS
Doing fslsfonts l can tie up your server for a very long time. Thisisreally a bug with single-threaded nonpreemptable
servers, not with thisprogram.
AUTHOR
Dave Lemke (Network Computing Devices, Inc.)
X Version 11 Release 6 1
fstobdf
fstobdfGenerate BDF font from X font server
SYNOPSIS
fstobdf [ server ser ver ] fn f ont name
DESCRIPTION
The fstobdf program readsa font from a font server and printsa BDF file on the standard output that may be used to
recreate the font. Thisisuseful in testing servers, debugging font metrics, and reproducing lost BDF files.
OPTIONS
server ser ver name Thisoption specifiesthe server from which the font should be read.
fn f ont name Thisoption specifiesthe font for which a BDF file should be generated.
ENVIRONMENT
FONTSERVER Default server to use
SEE ALSO
xfs(1), bdftopcf(1), fslsfonts(1)
147
AUTHOR
Olaf Brandt (Network Computing Devices), Dave Lemke (Network Computing Devices), Jim Fulton (MIT X Consortium)
X Version 11 Release 6
fstopgm
fstopgmConvert a Usenix FaceSaver file into a portable graymap
SYNOPSIS
fstopgm [f sf i l e]
DESCRIPTION
Readsa Usenix FaceSaver file asinput. Producesa portable graymap asoutput.
FaceSaver filessometimeshave rectangular pixels. Although fstopgm wont rescale them into square pixelsfor you, it will give
you the precise pnmscale command that will do the job. Because of this, reading a FaceSaver image isa two-step process.
First you do
fstopgm > /dev/null
Thiswill tell you whether you need to use pnmscale. Then use one of the following pipelines:
fstopgm | pgmnorm
fstopgm | pnmscale -whatever | pgmnorm
To go to PBM, you want something more like one of these:
fstopgm | pnmenlarge 3 | pgmnorm | pgmtopbm
fstopgm | pnmenlarge 3 | pnmscale <whatever> | pgmnorm | pgmtopbm
You want to enlarge when going to a bitmap because otherwise you lose information; but enlarging by more than 3 doesnot
look good.
FaceSaver isa registered trademark of Metron Computerware Ltd. of Oakland, CA.
SEE ALSO
pgmtofs(1), pgm(5), pgmnorm(1), pnmenlarge(1), pnmscale(1), pgmtopbm(1)
AUTHOR
Copyright 1989 by Jef Poskanzer
6 April 1989
ftp
ftpARPAnet file transfer program
SYNOPSIS
ftp [-v] [-d] [-i] [-n] [-g] [host ]
DESCRIPTION
ftp isthe user interface to the ARPAnet standard File Transfer Protocol. The program allowsa user to transfer filesto and
from a remote network site.
Optionsmay be specified at the command line, or to the command interpreter.
ftp
Part I: User Commands
148
-v Verbose option forcesftp to show all responsesfrom the remote server, aswell as
report on data transfer statistics.
-n Restrainsftp from attempting auto-login upon initial connection. If auto-login is
enabled, ftp will check the (see below) file in the usershome directory for an entry
describing an account on the remote machine. If no entry exists, ftp will prompt for
the remote machine login name (default isthe user identity on the local machine),
and, if necessary, prompt for a password and an account with which to login.
-i Turnsoff interactive prompting during multiple file transfers.
-d Enablesdebugging.
-g Disablesfilename globbing.
The client host with which ftp isto communicate may be specified on the command line. If thisisdone, ftp will immedi-
ately attempt to establish a connection to an FTP server on that host; otherwise, ftp will enter itscommand interpreter and
await instructionsfrom the user. When ftp isawaiting commandsfrom the user, the prompt
ftp>
isprovided to the user. The following commandsare recognized by ftp :
! [command] [ar gs] Invoke an interactive shell on the local machine. If there are arguments, the first is
taken to be a command to execute directly, with the rest of the argumentsasits
arguments.
$ macr o- name [ar gs ] Execute the macro macr o- name that wasdefined with the macdef command.
Argumentsare passed to the macro unglobbed.
account [passwd] Supply a supplemental password required by a remote system for accessto resources
once a login hasbeen successfully completed. If no argument isincluded, the user
will be prompted for an account password in a nonechoing input mode.
append l ocal - f i l e [r emot e- f i l e] Append a local file to a file on the remote machine. If r emot e- f i l e isleft unspecified,
the local filename isused in naming the remote file after being altered by any ntrans
or nmap setting. File transfer usesthe current settingsfor type, format, mode, and
structure.
ascii Set the file transfer type to network ASCII. Thisisthe default type.
bell Arrange that a bell be sounded after each file transfer command iscompleted.
binary Set the file transfer type to support binary image transfer.
bye Terminate the FTP session with the remote server and exit ftp. An end of file will
also terminate the session and exit.
case Toggle remote computer filename case mapping during mget commands. When case
ison (default isoff), remote computer filenameswith all lettersin upper case are
written in the local directory with the lettersmapped to lowercase.
cd r emot e- di r ect or y Change the working directory on the remote machine to r emot e- di r ect or y.
cdup Change the remote machine working directory to the parent of the current remote
machine working directory.
chmod mode f i l e- name Change the permission modesof the file f i l e- name on the remote system to mode.
close Terminate the FTP session with the remote server, and return to the command
interpreter. Any defined macrosare erased.
cr Toggle carriage return stripping during ASCII type file retrieval. Recordsare
denoted by a carriage return/linefeed sequence during ASCII type file transfer.
When cr ison (the default), carriage returnsare stripped from thissequence to
conform with the UNIX single linefeed record delimiter. Recordson non-UNIX
remote systemsmay contain single linefeeds; when an ASCII type transfer ismade,
these linefeedsmay be distinguished from a record delimiter only when cr isoff.
delete r emot e- f i l e Delete the file r emot e- f i l e on the remote machine.
149
debug [debug- val ue] Toggle debugging mode. If an optional debug- val ue isspecified, it isused to set the
debugging level. When debugging ison, ftp printseach command sent to the
remote machine, preceded by the string >.
dir [r emot e- di r ect or y] [l ocal - f i l e] Print a listing of the directory contentsin the directory, r emot e- di r ect or y, and,
optionally, placing the output in l ocal - f i l e. If interactive prompting ison, ftp will
prompt the user to verify that the last argument isindeed the target local file for
receiving dir output. If no directory isspecified, the current working directory on
the remote machine isused. If no local file isspecified, or l ocal - f i l e is-, output
comesto the terminal.
disconnect A synonym for close.
form f or mat Set the file transfer form to f or mat . The default f or mat isfile.
get r emot e- f i l e [l ocal - f i l e] Retrieve the r emot e- f i l e and store it on the local machine. If the local filename is
not specified, it isgiven the same name it hason the remote machine, subject to
alteration by the current case, ntrans, and nmap settings. The current settingsfor
type, form, mode, and structure are used while transferring the file.
glob Toggle filename expansion for mdelete, mget, and mput. If globbing isturned off with
glob, the filename argumentsare taken literally and not expanded. Globbing for mput
isdone asin csh 1. For mdelete and mget, each remote filename isexpanded
separately on the remote machine and the listsare not merged. Expansion of a
directory name islikely to be different from expansion of the name of an ordinary
file: the exact result dependson the foreign operating system and FTP server, and
can be previewed by doing mls remote-filesNote: mget and mput are not meant to
transfer entire directory subtreesof files. That can be done by transferring a tar 1
archive of the subtree (in binary mode).
hash Toggle hash-sign (#) printing for each data block transferred. The size of a data block
is1024 bytes.
help [command] Print an informative message about the meaning of command. If no argument isgiven,
ftp printsa list of the known commands.
idle [seconds ] Set the inactivity timer on the remote server to seconds seconds. If seconds is
omitted, the current inactivity timer isprinted.
lcd [di r ect or y] Change the working directory on the local machine. If no directory isspecified, the
usershome directory isused.
ls [r emot e- di r ect or y] [l ocal - f i l e] Print a listing of the contentsof a directory on the remote machine. The listing
includesany system-dependent information that the server choosesto include; for
example, most systemswill produce output from the command ls l. (See also
nlist.) If r emot e- di r ect or y isleft unspecified, the current working directory isused.
If interactive prompting ison, ftp will prompt the user to verify that the last
argument isindeed the target local file for receiving ls output. If no local file is
specified, or if l ocal - f i l e is-, the output issent to the terminal.
macdef macr o- name Define a macro. Subsequent linesare stored asthe macro macr o- name; a null line
(consecutive newline charactersin a file or carriage returnsfrom the terminal)
terminatesmacro input mode. There isa limit of 16 macrosand 4096 total
charactersin all defined macros. Macrosremain defined until a close command is
executed. The macro processor interprets$ and \ asspecial characters. A $ followed
by a number (or numbers) isreplaced by the corresponding argument on the macro
invocation command line. A $ followed by an i signalsthat macro processor that the
executing macro isto be looped. On the first pass$i isreplaced by the first argument
on the macro invocation command line, on the second passit isreplaced by the
second argument, and so on. A \ followed by any character isreplaced by that
character. Use the \ to prevent special treatment of the $.
mdelete [r emot e- f i l es] Delete the r emot e- f i l es on the remote machine.
ftp
Part I: User Commands
150
mdir r emot e- f i l es l ocal - f i l e Like dir, except multiple remote filesmay be specified. If interactive prompting is
on, ftp will prompt the user to verify that the last argument isindeed the target local
file for receiving mdir output.
mget r emot e- f i l es Expand the r emot e- f i l es on the remote machine and do a get for each filename thus
produced. See glob for detailson the filename expansion. Resulting filenameswill
then be processed according to case, ntrans, and nmap settings. Filesare transferred
into the local working directory, which can be changed with lcd directory ; new local
directoriescan be created with !mkdir directory.
mkdir di r ect or y- name Make a directory on the remote machine.
mls r emot e- f i l es l ocal - f i l e Like nlist, except multiple remote filesmay be specified, and the local-file must
be specified. If interactive prompting ison, ftp will prompt the user to verify that
the last argument isindeed the target local file for receiving mls output.
mode [mode- name] Set the file transfer mode to mode- name. The default mode isstream mode.
modtime f i l e- name Show the last modification time of the file on the remote machine.
mput l ocal - f i l es Expand wildcardsin the list of local filesgiven asargumentsand do a put for each
file in the resulting list. See glob for detailsof filename expansion. Resulting
filenameswill then be processed according to ntrans and nmap settings.
newer f i l e- name Get the file only if the modification time of the remote file ismore recent that the
file on the current system. If the file doesnot exist on the current system, the remote
file isconsidered newer. Otherwise, thiscommand isidentical to get.
nlist [r emot e- di r ect or y] Print a list of the filesin a directory on the remote machine. If r emot e- di r ect or y is
[l ocal - f i l e] left unspecified, the current working directory isused. If interactive prompting ison,
ftp will prompt the user to verify that the last argument isindeed the target local file
for receiving nlist output. If no local file isspecified, or if l ocal - f i l e is-, the
output issent to the terminal.
nmap [i npat t er n] out pat t er n Set or unset the filename mapping mechanism. If no argumentsare specified, the
filename mapping mechanism isunset. If argumentsare specified, remote filenames
are mapped during mput commandsand put commandsissued without a specified
remote target filename. If argumentsare specified, local filenamesare mapped during
mget commandsand get commandsissued without a specified local target filename.
Thiscommand isuseful when connecting to a non-UNIX remote computer with
different file naming conventionsor practices. The mapping followsthe pattern set
by inpattern and outpattern. Inpattern isa template for incoming filenames(which
may have already been processed according to the ntrans and case settings). Variable
templating isaccomplished by including the sequences$1, $2,..., $9 in inpattern.
Use \ to prevent thisspecial treatment of the $ character. All other charactersare
treated literally, and are used to determine the nmap inpattern variable values. For
example, given inpattern $1.$2 and the remote filename mydata.data, $1 would have
the value mydata, and $2 would have the value data. The outpattern determinesthe
resulting mapped filename. The sequences$1, $2,...., $9 are replaced by any value
resulting from the inpattern template. The sequence $0 isreplaced by the original
filename. Additionally, the sequence seq1, seq2 isreplaced by seq1 if seq1 isnot a
null string; otherwise, it isreplaced by seq2. For example, the command nmap
$1.$2.$3 [$1,$2].[$2,file] would yield the output filename myfile.data for
input filenamesmy-file. data and myfile.data.old, myfile.file for the input
filename my-file, and myfile.myfile for the input filename .myfile. Spacesmay be
included in outpattern, asin the example: nmap $1 sed s/ *$// > $1. Use the \
character to prevent special treatment of the $, [, [, and , characters.
ntrans [i nchar s] [out char s ] Set or unset the filename character translation mechanism. If no argumentsare
specified, the filename character translation mechanism isunset. If argumentsare
specified, charactersin remote filenamesare translated during mput commandsand
151
put commandsissued without a specified remote target filename. If argumentsare
specified, charactersin local filenamesare translated during mget commandsand get
commandsissued without a specified local target filename. Thiscommand isuseful
when connecting to a non-UNIX remote computer with different file naming
conventionsor practices. Charactersin a filename matching a character in i nchar s
are replaced with the corresponding character in out char s. If the charactersposition
in i nchar s islonger than the length of out char s, the character isdeleted from the
filename.
open host [por t ] Establish a connection to the specified host FTP server. An optional port number
may be supplied, in which case, ftp will attempt to contact an FTP server at that
port. If the auto-login option ison (default), ftp will also attempt to automatically
log the user in to the FTP server (see below).
prompt Toggle interactive prompting. Interactive prompting occursduring multiple file
transfersto allow the user to selectively retrieve or store files. If prompting isturned
off (default ison), any mget or mput will transfer all files, and any mdelete will delete
all files.
proxy ftp-command Execute an ftp command on a secondary control connection. Thiscommand allows
simultaneousconnection to two remote FTP serversfor transferring filesbetween
the two servers. The first proxy command should be an open, to establish the
secondary control connection. Enter the command proxy ? to see other ftp
commandsexecutable on the secondary connection. The following commands
behave differently when prefaced by proxy :, open will not define new macrosduring
the auto-login process, close will not erase existing macro definitions, get and mget
transfer filesfrom the host on the primary control connection to the host on the
secondary control connection, and put, mput, and append transfer filesfrom the host
on the secondary control connection to the host on the primary control connection.
Third-party file transfersdepend upon support of the FTP protocol PASV command
by the server on the secondary control connection.
put l ocal - f i l e [r emot e- f i l e] Store a local file on the remote machine. If r emot e- f i l e isleft unspecified, the local
filename isused after processing according to any ntrans or nmap settingsin naming
the remote file. File transfer usesthe current settingsfor type, format, mode, and
structure.
pwd Print the name of the current working directory on the remote machine.
quit A synonym for bye.
quote ar g1 ar g2... The argumentsspecified are sent, verbatim, to the remote FTP server.
recv r emot e- f i l e [l ocal - f i l e] A synonym for get.
reget r emot e- f i l e [l ocal - f i l e] Reget actslike get, except that if l ocal - f i l e existsand issmaller than r emot e- f i l e,
l ocal - f i l e ispresumed to be a partially transferred copy of r emot e- f i l e and the
transfer iscontinued from the apparent point of failure. Thiscommand isuseful
when transferring very large filesover networksthat are prone to dropping
connections.
remotehelp [command- name] Request help from the remote FTP server. If a command- name isspecified, it issupplied
to the server aswell.
remotestatus [f i l e- name] With no arguments, show statusof remote machine. If f i l e- name isspecified, show
statusof f i l e- name on remote machine.
rename [f r om] [t o] Rename the file from on the remote machine, to the file t o.
reset Clear reply queue. Thiscommand resynchronizescommand/reply sequencing with
the remote FTP server. Resynchronization may be necessary following a violation of
the FTP protocol by the remote server.
restart mar ker Restart the immediately following get or put at the indicated marker. On UNIX
systems, mar ker isusually a byte offset into the file.
ftp
Part I: User Commands
152
rmdir di r ect or y- name Delete a directory on the remote machine.
runique Toggle storing of fileson the local system with unique filenames. If a file already
existswith a name equal to the target local filename for a get or mget command, a .1
isappended to the name. If the resulting name matchesanother existing file, a .2 is
appended to the original name. If thisprocesscontinuesup to .99, an error message
isprinted, and the transfer doesnot take place. The generated unique filename will
be reported. Note that runique will not affect local filesgenerated from a shell
command. The default value isoff.
send l ocal - f i l e [r emot e- f i l e] A synonym for put.
sendport Toggle the use of PORT commands. By default, ftp will attempt to use a PORT
command when establishing a connection for each data transfer. The use of PORT
commandscan prevent delayswhen performing multiple file transfers. If the PORT
command fails, ftp will use the default data port. When the use of PORT commandsis
disabled, no attempt will be made to use PORT commandsfor each data transfer. This
isuseful for certain FTP implementationswhich do ignore PORT commandsbut,
incorrectly, indicate theyve been accepted.
site ar g1 ar g2... The argumentsspecified are sent, verbatim, to the remote FTP server asa SITE
command.
size f i l e- name Return size of file-name on remote machine.
status Show the current statusof ftp.
struct [st r uct - name] Set the file transfer structure to st r uct - name. By default stream structure isused.
sunique Toggle storing of fileson remote machine under unique filenames. Remote FTP
server must support ftp protocol STOU command for successful completion. The
remote server will report unique name. Default value isoff.
system Show the type of operating system running on the remote machine.
tenex Set the file transfer type to that needed to talk to TENEX machines.
trace Toggle packet tracing.
type [t ype- name] Set the file transfer type to t ype- name. If no type isspecified, the current type is
printed. The default type isnetwork ASCII.
umask [newmask] Set the default umask on the remote server to newmask. If newmask isomitted, the
current umask isprinted.
user user - name [passwor d] [account ] Identify yourself to the remote FTP server. If the password isnot specified and the
server requiresit, ftp will prompt the user for it (after disabling local echo). If an
account field isnot specified, and the FTP server requiresit, the user will be
prompted for it. If an account field isspecified, an account command will be relayed
to the remote server after the login sequence iscompleted if the remote server did
not require it for logging in. Unlessftp isinvoked with auto-login disabled, this
processisdone automatically on initial connection to the FTP server.
verbose Toggle verbose mode. In verbose mode, all responsesfrom the FTP server are
displayed to the user. In addition, if verbose ison, when a file transfer completes,
statisticsregarding the efficiency of the transfer are reported. By default, verbose is
on.
? [command] A synonym for help.
Command argumentswhich have embedded spacesmay be quoted with quotation marks().
ABORTING A FILE TRANSFER
To abort a file transfer, use the terminal interrupt key (usually Ctrl-C). Sending transferswill be immediately halted.
Receiving transferswill be halted by sending an FTP protocol ABOR command to the remote server, and discarding any
further data received. The speed at which thisisaccomplished dependsupon the remote serverssupport for ABOR processing.
153
If the remote server doesnot support the ABOR command, an ftp> prompt will not appear until the remote server has
completed sending the requested file.
The terminal interrupt key sequence will be ignored when ftp hascompleted any local processing and isawaiting a reply
from the remote server. A long delay in thismode may result from the ABOR processing described earlier in thissection, or
from unexpected behavior by the remote server, including violationsof the FTP protocol. If the delay resultsfrom unex-
pected remote server behavior, the local ftp program must be killed by hand.
FILE NAMING CONVENTIONS
Filesspecified asargumentsto ftp commandsare processed according to the following rules:
If the filename - isspecified, the stdin (for reading) or stdout (for writing) isused.
If the first character of the filename isj, the remainder of the argument isinterpreted asa shell command. ftp then forksa
shell, using popen 3 with the argument supplied, and reads(writes) from the stdout (stdin). If the shell command includes
spaces, the argument must be quoted; for example, ls -lt. A particularly useful example of thismechanism is: dir more.
Failing the preceding checks, if globbing isenabled, local filenamesare expanded according to the rulesused in the csh 1;
c.f. the glob command. If the ftp command expectsa single local file (for example, put), only the first filename generated by
the globbing operation isused.
For mget commandsand get commandswith unspecified local filenames, the local filename isthe remote filename, which
may be altered by a case, ntrans, or nmap setting. The resulting filename may then be altered if runique ison.
For mput commandsand put commandswith unspecified remote filenames, the remote filename isthe local filename, which
may be altered by an ntrans or nmap setting. The resulting filename may then be altered by the remote server if sunique ison.
FILE TRANSFER PARAMETERS
The FTP specification specifiesmany parametersthat may affect a file transfer. The type may be one of ASCII, image
(binary), ebcdic, and local byte size (for PDP Ns-10sand PDP Ns-20smostly). ftp supportsthe ASCII and image typesof
file transfer, pluslocal byte size 8 for tenex mode transfers.
ftp supportsonly the default valuesfor the remaining file transfer parameters: mode, form, and struct.
THE .netrc FILE
The file containslogin and initialization information used by the auto-login process. It residesin the usershome directory.
The following tokensare recognized; they may be separated by spaces, tabs, or newlines:
machine name Identify a remote machine name. The auto-login processsearchesthe file for a machine token that
matchesthe remote machine specified on the ftp command line or asan open command argument.
When a match ismade, the subsequent tokensare processed, stopping when the end of file is
reached or another machine or a default token isencountered.
default Thisisthe same asmachine name except that default matchesany name. There can be only one
default token, and it must be after all machine tokens. Thisisnormally used asdef aul t l ogi n
anonymous pas swor d user @si t e, thereby giving the user automatic anonymousftp login to machines
not specified. Thiscan be overridden by using the -n flag to disable auto-login.
login name Identify a user on the remote machine. If thistoken ispresent, the auto-login processwill initiate a
login using the specified name.
password st r i ng Supply a password. If thistoken ispresent, the auto-login processwill supply the specified string if
the remote server requiresa password aspart of the login process. Note that if thistoken ispresent
in the file for any user other than anonymous, ftp will abort the auto-login processif the isreadable
by anyone besidesthe user.
account st r i ng Supply an additional account password. If thistoken ispresent, the auto-login processwill supply
the specified string if the remote server requiresan additional account password, or the auto-login
processwill initiate an ACCT command if it doesnot.
ftp
Part I: User Commands
154
macdef name Define a macro. Thistoken functionslike the ftp macdef command functions. A macro isdefined
with the specified name; itscontentsbegin with the next line and continue until a null line
(consecutive newline characters) isencountered. If a macro named init isdefined, it isautomati-
cally executed asthe last step in the auto-login process.
ENVIRONMENT
ftp utilizesthe following environment variables:
HOME For default location of a file, if one exists
SHELL For default shell
SEE ALSO
ftpd(8)
HISTORY
The ftp command appeared in BSD 4.2.
BUGS
Correct execution of many commandsdependsupon proper behavior by the remote server.
An error in the treatment of carriage returnsin the BSD 4.2 ASCII-mode transfer code hasbeen corrected. Thiscorrection
may result in incorrect transfersof binary filesto and from BSD 4.2 serversusing the ASCII type. Avoid thisproblem by
using the binary image type.
BSD 4.2, 30 July 1991
fuser
fuserIdentify processesusing files
SYNOPSIS
fuser [a|s][si gnal ][kmuv] f i l ename ... [][si gnal ][kmuv] f i l ename ...
fuser [l]
DESCRIPTION
fuser displaysthe PIDsof processesusing the specified filesor file systems. In the default display mode, each filename is
followed by a letter denoting the type of access:
c Current directory.
e Executable being run.
f Open file. f isomitted in default display mode.
r Root directory.
m mmaped file or shared library.
fuser returnsa nonzero return code if none of the specified filesisaccessed or in case of a fatal error. If at least one accesshas
been found, fuser returnszero.
OPTIONS
a Show all filesspecified on the command line. By default, only filesthat are accessed by at least one process
are shown.
k Kill processesaccessing the file. Unlesschanged with -signal, SIGKILL issent. A fuser processnever kills
itself, but may kill other fuser processes.
155
u List all known signal names.
m f i l ename specifiesa file on a mounted file system or a block device that ismounted. All processesaccessing
fileson that file system are listed. If a directory file isspecified, it isautomatically changed to filename/. to
use any file system that might be mounted on that directory.
s Silent operation. a, u, and v are ignored in thismode.
si gnal Use the specified signal instead of SIGKILL when killing processes. Signalscan be specified either by name
(for example, HUP) or by number (for example, 1).
u Append the username of the processowner to each PID.
v Verbose mode. Processesare shown in a ps-like style. The fieldsPID, USER, and COMMAND are similar to ps.
ACCESS showshow the processaccessesthe file.
Reset all optionsand set the signal back to SIGKILL.
FILES
/proc Location of the proc file system
EXAMPLES
fuser -km /home killsall processesaccessing the file system /home in any way.
In thisexample:
if fuser -s /dev/ttyS1; then :; else something
fi invokessomething if no other processisusing /dev/ttyS1.
RESTRICTIONS
Processesaccessing the same file or filesystem several timesin the same way are only shown once.
AUTHOR
Werner Almesberger (<almesber@di.epfl.ch>U)
SEE ALSO
kill(1), killall(1), ps(1), kill(2)
Linux, 11 October 1994
g++
g++GNU project C++ Compiler
SYNOPSIS
g++ [ opt i on | f i l ename ]. ..
DESCRIPTION
The C and C++ compilersare integrated; g++ isa script to call gcc with optionsto recognize C++. gcc processesinput files
through one or more of four stages: preprocessing, compilation, assembly, and linking. Thisman page containsfull
descriptionsfor only C++ specific aspectsof the compiler, though it also containssummariesof some general-purpose
options. For a fuller explanation of the compiler, see gcc(1).
C++ source filesuse one of the suffixes.C, .cc, .cxx, .cpp, or .c++; preprocessed C++ filesuse the suffix .ii.
OPTIONS
There are many command-line options, including optionsto control detailsof optimization, warnings, and code generation,
which are common to both gcc and g++. For full information on all options, see gcc(1).
g++
Part I: User Commands
156
Optionsmust be separate: dr isquite different from d -r.
Most f and W optionshave two contrary forms: fname and fnoname (or Wname and Wnoname). Only the nondefault
formsare shown here.
c Compile or assemble the source files, but do not link. The compiler output isan
object file corresponding to each source file.
Dmacr o Define macro macrowith the string 1 asitsdefinition.
Dmacr o=def n Define macro macr o asdef n.
E Stop after the preprocessing stage; do not run the compiler proper. The output is
preprocessed source code, which issent to the standard output.
fallvirtual Treat all possible member functionsasvirtual, implicitly. All member functions
(except for constructor functionsand new or delete member operators) are treated as
virtual functionsof the classwhere they appear.
Thisdoesnot mean that all callsto these member functionswill be made through
the internal table of virtual functions. Under some circumstances, the compiler can
determine that a call to a given virtual function can be made directly; in these cases
the callsare direct in any case.
fdollarsinidentifiers Permit the use of $ in identifiers. Traditional C allowed the character $ to form part
of identifiers; by default, GNU C also allowsthis. However, ANSI C forbids$ in
identifiers, and GNU C++ also forbidsit by default on most platforms(though on
some platformsitsenabled by default for GNU C++ aswell).
felideconstructors Use thisoption to instruct the compiler to be smarter about when it can elide
constructors. Without thisflag, GNU C++ and cfront both generate effectively the
same code for
A foo ();
A x (foo ()); // x initialized by foo (), no ctor called
A y = foo (); // call to foo () heads to temporary, // y is initial-
ized from the temporary.
Note the difference. With thisflag, GNU C++ initializesy directly from the call to
foo() without going through a temporary.
fenumintequiv Normally GNU C++ allowsconversion of enum to int, but not the other way
around. Use thisoption if you want GNU C++ to allow conversion of int to enum as
well.
fexternaltemplates Produce smaller code for template declarations, by generating only a single copy of
each template function where it isdefined. To use thisoption successfully, you must
also mark all filesthat use templateswith either #pragma implementation (the
definition) or #pragma interface (declarations).
When your code iscompiled with fexternaltemplates, all template instantiations
are external. You must arrange for all necessary instantiationsto appear in the
implementation file; you can do thiswith a typedef that referenceseach instantiation
needed. Conversely, when you compile using the default option fno external
templates, all template instantiationsare explicitly internal.
fnognulinker Do not output global initializations(such asC++ constructorsand destructors) in
the form used by the GNU linker (on systemswhere the GNU linker isthe standard
method of handling them). Use thisoption when you want to use a non-GNU
linker, which also requiresusing the collect2 program to make sure the system
linker includesconstructorsand destructors. (collect2 isincluded in the GNU CC
distribution.) For systemswhich must use collect2, the compiler driver gcc is
configured to do thisautomatically.
fmemoizelookupsfsavememorized These flagsare used to get the compiler to compile programsfaster using heuristics.
They are not on by default since they are only effective about half the time. The
other half of the time programscompile more slowly (and take more memory).
157
The first time the compiler must build a call to a member function (or reference to a
data member), it must (1) determine whether the classimplementsmember
functionsof that name; (2) resolve which member function to call (which involves
figuring out what sortsof type conversionsneed to be made); and (3) check the
visibility of the member function to the caller. All of thisaddsup to slower
compilation. Normally, the second time a call ismade to that member function (or
reference to that data member), it must go through the same lengthy processagain.
Thismeansthat code like this:
cout << This << p << has<< n << legs.\n;
makessix passesthrough all three steps. By using a software cache, a hit signifi-
cantly reducesthiscost. Unfortunately, using the cache introducesanother layer of
mechanismswhich must be implemented, and so incursitsown overhead.
fmemorize lookups enablesthe software cache.
Because accessprivileges(visibility) to membersand member functionsmay differ
from one function context to the next, g++ may need to flush the cache. With the
fmemoizelookups flag, the cache isflushed after every function that iscompiled. The
fsavememorized flag enablesthe same software cache, but when the compiler
determinesthat the context of the last function compiled would yield the same
accessprivilegesof the next function to compile, it preservesthe cache. Thisismost
helpful when defining many member functionsfor the same class: with the
exception of member functionswhich are friendsof other classes, each member
function hasexactly the same accessprivilegesasevery other, and the cache need not
be flushed.
fnodefaultinline Do not make member functionsinline by default merely because they are defined
inside the classscope. Otherwise, when you specify O, member functionsdefined
inside classscope are compiled inline by default; that is, you dont need to add
inline in front of the member function name.
fnostrictprototype Consider the declaration int foo;(). In C++, thismeansthat the function foo takes
no arguments. In ANSI C, thisisdeclared int foo(void);. With the flag fno
strictprototype, declaring functionswith no argumentsisequivalent to declaring
itsargument list to be untyped, that is, int foo(); isequivalent to saying int foo
(...);.fnonnullobjects. Normally, GNU C++ makesconservative assumptions
about objectsreached through references. For example, the compiler must check that
a isnot null in code like the following:
obj &a = g ();
a.f (2);
Checking that referencesof thissort have non-null valuesrequiresextra code,
however, and it isunnecessary for many programs. You can use fnonnullobjects to
omit the checksfor null, if your program doesnt require the default checking.
fhandlesignatures These optionscontrol the recognition of the signature and sigof constructsfor
fnohandlesignatures specifying abstract types. By default, these constructsare not recognized.
fthisisvariable The incorporation of user-defined free store management into C++ hasmade
assignment to thisan anachronism. Therefore, by default GNU C++ treatsthe type
of thisin a member function of classX to be X *const. In other words, it isillegal to
assign to thiswithin a classmember function. However, for backwardscompatibil-
ity, you can invoke the old behavior by using fthisisvariable.
g Produce debugging information in the operating systemsnative format (for DBX or
SDB or DWARF). GDB also can work with thisdebugging information. On most
systemsthat use DBX format, g enablesuse of extra debugging information that
only GDB can use.
Unlike most other C compilers, GNU CC allowsyou to use g with 0. The
shortcutstaken by optimized code may occasionally produce surprising results: some
g++
Part I: User Commands
158
variablesyou declared may not exist at all; flow of control may briefly move where
you did not expect it; some statementsmay not be executed because they compute
constant resultsor their valueswere already at hand; some statementsmay execute in
different placesbecause they were moved out of loops.
Nevertheless, it provespossible to debug optimized output. Thismakesit reasonable
to use the optimizer for programsthat might have bugs.
Idi r Append directory di r to the list of directoriessearched for include files.
Ldi r Add directory di r to the list of directoriesto be searched for l.
ll i br ar y Use the library named l i br ar y when linking. (C++ programsoften require lg++ for
successful linking.)
nostdinc Do not search the standard system directoriesfor header files. Only the directories
you have specified with I options(and the current directory, if appropriate) are
searched.
nostdinc++ Do not search for header filesin the standard directoriesspecific to C++, but do still
search the other standard directories. (Thisoption isused when building libg++.)
O Optimize. Optimizing compilation takessomewhat more time, and a lot more
memory for a large function.
o f i l e Place output in file f i l e.
S Stop after the stage of compilation proper; do not assemble. The output isan
assembler code file for each nonassembler input file specified.
traditional Attempt to support some aspectsof traditional C compilers. Specifically, for both C
and C++ programs:
In the preprocessor, commentsconvert to nothing at all, rather than to a space. This
allowstraditional token concatenation.
In the preprocessor, macro argumentsare recognized within string constantsin a
macro definition (and their valuesare stringified, though without additional quote
marks, when they appear in such a context). The preprocessor alwaysconsidersa
string constant to end at a newline.
The preprocessor doesnot predefine the macro STDC when you use traditional, but
still predefinesGNUC (since the GNU extensionsindicated by GNUC are not affected by
traditional). If you need to write header filesthat work differently depending on
whether traditional isin use, by testing both of these predefined macrosyou can
distinguish four situations: GNU C, traditional GNU C, other ANSI C compilers,
and other old C compilers.
In the preprocessor, commentsconvert to nothing at all, rather than to a space. This
allowstraditional token concatenation.
String constants are not necessarily constant; they are stored in writable space, and
identical looking constantsare allocated separately. For C++ programsonly (not C),
traditional hasone additional effect: assignment to thisispermitted. Thisisthe
same asthe effect of fthisisvariable.
Umacr o Undefine macro macro.
Wall Issue warningsfor conditionsthat pertain to usage that we recommend avoiding and
that we believe iseasy to avoid, even in conjunction with macros.
Wenumclash Warn when converting between different enumeration types.
Woverloadedvirtual In a derived class, the definitionsof virtual functionsmust match the type signature
of a virtual function declared in the base class. Use thisoption to request warnings
when a derived classdeclaresa function that may be an erroneousattempt to define
a virtual function; that is, warn when a function with the same name asa virtual
function in the base class, but with a type signature that doesnt match any virtual
functionsfrom the base class.
159
Wtemplatedebugging When using templatesin a C++ program, warn if debugging isnot yet fully
available.
w Inhibit all warning messages.
+eN Control how virtual function definitionsare used, in a fashion compatible with
cfront 1.x.
PRAGMAS
Two #pragma directivesare supported for GNU C++, to permit using the same header file for two purposes: asa definition of
interfacesto a given object class, and asthe full definition of the contentsof that object class.
#pragma interface Use thisdirective in header filesthat define object classes, to save space in most of
the object filesthat use those classes. Normally, local copiesof certain information
(backup copiesof inline member functions, debugging information, and the internal
tablesthat implement virtual functions) must be kept in each object file that
includesclassdefinitions. You can use thispragma to avoid such duplication. When
a header file containing #pragma interface isincluded in a compilation, thisauxiliary
information will not be generated (unlessthe main input source file itself uses
#pragma implementation). Instead, the object fileswill contain referencesto be
resolved at link time.
#pragma implementation Use thispragma in a main input file, when you want full output from included
#pragma implementation !objects.h! header filesto be generated (and made globally visible). The included header file, in
turn, should use #pragma interface. Backup copiesof inline member functions,
debugging information, and the internal tablesused to implement virtual functions
are all generated in implementation files.
If you use #pragma implementation with no argument, it appliesto an include file
with the same basename asyour source file; for example, in allclass.cc, #pragma
implementation by itself isequivalent to #pragma implementation allclass.h. Use
the string argument if you want a single implementation file to include code from
multiple header files.
There isno way to split up the contentsof a single header file into multiple
implementation files.
FILES
file.h C header (preprocessor) file
file.i Preprocessed C source
file file.C C++ source file
file.cc C++ source file
file.cxx C++ source file
file.s Assembly language file
file.o Object file
a.out Link edited output
TMPDIR/cc Temporary files
LIBDIR/cpp Preprocessor
LIBDIR/cc1plus Compiler
LIBDIR/collect Linker front end needed on some machines
LIBDIR/libgcc.a GCC subroutine library
/lib/crt[01n].o Start-up routine
LIBDIR/ccrt0 Additional start-up routine for C++
/lib/libc.a Standard C library; see intro(3)
g++
Part I: User Commands
160
/usr/include Standard directory for #include files
LIBDIR/include Standard gcc directory for #include files
LIBDIR/g++include Additional g++ directory for #include
LIBDIR isusually /usr/local/lib/machine/version.
TMPDIR comesfrom the environment variable TMPDIR (default /usr/tmp if available, else /tmp).
SEE ALSO
gcc(1), cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1), gcc, cpp, as, ld, and gdb entriesin info.
Usingand PortingGNU CC (for version 2.0), Richard M. Stallman; TheC Preprocessor, Richard M. Stallman; Debugging
with GDB: theGNU Source-Level Debugger, Richard M. Stallman and Roland H. Pesch; Usingas: theGNU Assembler, Dean
Elsner, Jay Fenlason and friends; gld: theGNU linker, Steve Chamberlain and Roland Pesch.
BUGS
For instructionson how to report bugs, see the GCC manual.
COPYING
Copyright 1991, 1992, 1993 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim
copiesof thismanual provided the copyright notice and thispermission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
AUTHORS
See the GNU CC Manual for the contributorsto GNU CC.
GNU Tools, 30 April 1993
g3topbm
g3topbmConvert a Group 3 fax file into a portable bitmap
SYNOPSIS
g3topbm [-kludge][-reversebits][-stretch][g3f i l e]
DESCRIPTION
Readsa Group 3 fax file asinput. Producesa portable bitmap asoutput.
OPTIONS
-kludge Tellsg3topbm to ignore the first few linesof the file; sometimesfax fileshave some junk at the beginning.
-reversebits Tellsg3topbm to interpret bitsleast-significant first, instead of the default most-significant first.
Apparently, some fax modemsdo it one way and othersdo it the other way. If you get a whole bunch of
bad code word messages, try using thisflag.
-stretch Tellsg3topbm to stretch the image vertically by duplicating each row. Thisisfor the low-quality transmis-
sion mode.
All flagscan be abbreviated to their shortest unique prefix.
161
REFERENCES
The standard for Group 3 fax isdefined in CCITT Recommendation T.4.
BUGS
Probably.
SEE ALSO
pbmtog3(1), pbm(5)
AUTHOR
Copyright 1989 by Paul Haeberli (paul@manray.sgi.com)
2 October 1989
gawk
gawkPattern scanning and processing language
SYNOPSIS
gawk [ POSIX or GNU style options ] f pr ogr am- f i l e [ ] file ...
gawk [ POSIX or GNU style options ] [ ] pr ogr am- t ext file ...
DESCRIPTION
gawk isthe GNU Projectsimplementation of the awk programming language. It conformsto the definition of the language
in the 1003.2 Command Language and UtilitiesStandard. Thisversion in turn isbased on the description in TheAWK
ProgrammingLanguage, by Aho, Kernighan, and Weinberger, with the additional featuresdefined in the System V Release 4
version of awk. gawk also providessome GNU-specific extensions.
The command line consistsof optionsto gawk itself, the awk program text (if not supplied via the f or file options), and
valuesto be made available in the ARGC and ARGV predefined awk variables.
OPTIONS
gawk optionsmay be either the traditional one-letter options, or the GNU-style long options. Traditional style optionsstart
with a single , while GNU long optionsstart with . GNU-style long optionsare provided for both GNU-specific features
and for mandated features. Other implementationsof the awk language are likely to only accept the traditional one-letter
options.
Following the standard, gawk-specific optionsare supplied via argumentsto the W option. Multiple W optionsmay be
supplied, or multiple argumentsmay be supplied together if they are separated by commas, or enclosed in quotesand
separated by whitespace. Case isignored in argumentsto the W option. Each W option hasa corresponding GNU-style long
option, asdetailed below. Argumentsto GNU-style long optionsare either joined with the option by an = sign, with no
intervening spaces, or they may be provided in the next command-line argument.
gawk acceptsthe following options:
F f s , field-separator=f s Use f s for the input field separator (the value of the FS-predefined variable).
v var =val , assign=var =val Assign the value val , to the variable var , before execution of the program begins. Such
variable valuesare available to the BEGIN block of an awk program.
f pr ogr am- f i l e, Read the awk program source from the file pr ogr am- f i l e, instead of from the first
file=pr ogr am- f i l e command-line argument. Multiple f (or file) optionsmay be used.
mf=NNN, mr=NNN Set variousmemory limitsto the value NNN. The f flag setsthe maximum number of fields,
and the r flag setsthe maximum record size. These two flagsand the m option are from the
AT&T Bell Labsresearch version of awk. They are ignored by gawk, since gawk hasno
predefined limits.
gawk
Part I: User Commands
162
W compat, compat Run in compatibility mode. In compatibility mode, gawk behavesidentically to awk; none of
the GNU-specific extensionsare recognized. See GNU Extensions, later in thismanual
page, for more information.
W copyleft, W copyright, Print the short version of the GNU copyright information message on the error output.
copyleft, copyright
W help, W usage Print a relatively short summary of the available optionson the error output. Per the GNU
help, usage Coding Standards, these optionscause an immediate, successful exit.
W lint, lint Provide warningsabout constructsthat are dubiousor nonportable to other awk implemen-
tations.
W posix, posix Thisturnson compatibility mode, with the following additional restrictions:\x escape
sequencesare not recognized.
The synonym func for the keyword function isnot recognized.
The operators** and **= cannot be used in place of and =.
W source=pr ogr am- t ext , Use pr ogr am- t ext asawk program source code. Thisoption allowsthe easy intermixing of
source=pr ogr am- t ext library functions(used via the f and file options) with source code entered on the
command line. It isintended primarily for medium to large awk programsused in shell
scripts.
The W source= form of thisoption usesthe rest of the command-line argument for
pr ogr am- t ext ; no other optionsto W will be recognized in the same argument.
W version, version Print version information for thisparticular copy of gawk on the error output. Thisisuseful
mainly for knowing if the current copy of gawk on your system isup-to-date with respect to
whatever the Free Software Foundation isdistributing. Per the GNU Coding Standards,
these optionscause an immediate, successful exit.
Signal the end of options. Thisisuseful to allow further argumentsto the awk program itself
to start with a . Thisismainly for consistency with the argument-parsing convention used
by most other programs.
In compatibility mode, any other optionsare flagged asillegal, but are otherwise ignored. In normal operation, aslong as
program text hasbeen supplied, unknown optionsare passed on to the awk program in the ARGV array for processing. Thisis
particularly useful for running awk programsvia the #! executable interpreter mechanism.
awk PROGRAM EXECUTION
An awk program consistsof a sequence of pattern-action statementsand optional function definitions:
pat t er n { act i on st at ement s }
f unct i on name(par amet er l i s t ) { st at ement s }
gawk first readsthe program source from the program-file(s) if specified, from argumentsto W source=, or from the first
nonoption argument on the command line. The f and W source= optionsmay be used multiple timeson the command
line. gawk will read the program text asif all the program-filesand command-line source textshad been concatenated
together. Thisisuseful for building librariesof awk functions, without having to include them in each new awk program that
usesthem. It also providesthe ability to mix library functionswith command-line programs.
The environment variable AWKPATH specifiesa search path to use when finding source filesnamed with the f option. If this
variable doesnot exist, the default path is.:/usr/lib/awk:/usr/local/lib/awk.
If a filename given to the f option containsa / character, no path search isperformed.
gawk executesawk programsin the following order. First, all variable assignmentsspecified via the v option are performed.
Next, gawk compilesthe program into an internal form. Then, gawk executesthe code in the BEGIN block(s) (if any), and then
proceedsto read each file named in the ARGV array. If there are no filesnamed on the command line, gawk readsthe standard
input.
If a filename on the command line hasthe form var =val , it istreated asa variable assignment. The variable var will be
assigned the value val . (Thishappensafter any BEGIN block(s) have been run.) Command-line variable assignment ismost
163
useful for dynamically assigning valuesto the variablesawk usesto control how input isbroken into fieldsand records. It is
also useful for controlling state if multiple passesare needed over a single data file.
If the value of a particular element of ARGV isempty (), gawk skipsover it.
For each line in the input, gawk teststo see if it matchesany pattern in the awk program. For each pattern that the line
matches, the associated action isexecuted. The patternsare tested in the order they occur in the program.
Finally, after all the input isexhausted, gawk executesthe code in the END block(s) (if any).
VARIABLES AND FIELDS
awk variablesare dynamic; they come into existence when they are first used. Their valuesare either floating-point numbers
or strings, or both, depending upon how they are used. awk also hasone-dimensional arrays; arrayswith multiple dimensions
may be simulated. Several predefined variablesare set asa program runs; these will be described asneeded and summarized
in the Built-In Variables subsection.
FIELDS
Aseach input line isread, gawk splitsthe line into fields, using the value of the FS variable asthe field separator. If FS isa
single character, fieldsare separated by that character. Otherwise, FS isexpected to be a full regular expression. In the special
case that FS isa single blank, fieldsare separated by runsof blanksor tabs. Note that the value of IGNORECASE (see the
following) will also affect how fieldsare split when FS isa regular expression.
If the FIELDWIDTHS variable isset to a space separated list of numbers, each field isexpected to have fixed width, and gawk will
split up the record using the specified widths. The value of FS isignored. Assigning a new value to FS overridesthe use of
FIELDWIDTHS, and restoresthe default behavior.
Each field in the input line may be referenced by itsposition, $1, $2, and so on. $0 isthe whole line. The value of a field may
be assigned to aswell. Fieldsneed not be referenced by constants:
n =5
print $n
printsthe fifth field in the input line. The variable NF isset to the total number of fieldsin the input line.
Referencesto nonexistent fields(that is, fieldsafter $NF) produce the null-string. However, assigning to a nonexistent field
(for example, $(NF+2) = 5) will increase the value of NF, create any intervening fieldswith the null string astheir value, and
cause the value of $0 to be recomputed, with the fieldsbeing separated by the value of OFS. Referencesto negative-numbered
fieldscause a fatal error.
BUILT-IN VARIABLES
awksbuilt-in variablesare the following:
ARGC The number of command-line arguments(doesnot include optionsto gawk, or the program source).
ARGIND The index in ARGV of the current file being processed.
ARGV Array of command-line arguments. The array isindexed from 0 to ARGC 1. Dynamically changing the
contentsof ARGV can control the filesused for data.
CONVFMT The conversion format for numbers, %.6g, by default.
ENVIRON An array containing the valuesof the current environment. The array isindexed by the environment
variables, each element being the value of that variable (for example, ENVIRON[HOME] might be /u/arnold).
Changing thisarray doesnot affect the environment seen by programswhich gawk spawnsvia redirection
or the system() function. (Thismay change in a future version of gawk.)
ERRNO If a system error occurseither doing a redirection for getline, during a read for getline, or during a
close(), then ERRNO will contain a string describing the error.
FIELDWIDTHS A whitespace-separated list of fieldwidths. When set, gawk parsesthe input into fieldsof fixed width,
instead of using the value of the FS variable asthe field separator. The fixed field width facility isstill
experimental; expect the semanticsto change asgawk evolvesover time.
gawk
Part I: User Commands
164
FILENAME The name of the current input file. If no filesare specified on the command line, the value of FILENAME is.
However, FILENAME isundefined inside the BEGIN block.
FNR The input record number in the current input file.
FS The input field separator, a blank by default.
IGNORECASE Controlsthe case-sensitivity of all regular expression operations. If IGNORECASE hasa nonzero value, then
pattern matching in rules, field splitting with FS, regular expression matching with and !, and the
gsub( ), index( ), match( ), split( ),and sub( ) predefined functionswill all ignore case when doing regular
expression operations. Thus, if IGNORECASE isnot equal to zero, /aB/ matchesall of the stringsab, aB, Ab,
and AB. Aswith all awk variables, the initial value of IGNORECASE iszero, so all regular expression operations
are normally case-sensitive.
NF The number of fieldsin the current input record.
NR The total number of input recordsseen so far.
OFMT The output format for numbers, %.6g, by default.
OFS The output field separator, a blank by default.
ORS The output record separator, by default a newline.
RS The input record separator, by default a newline. RS isexceptional in that only the first character of its
string value isused for separating records. (Thiswill probably change in a future release of gawk.) If RS isset
to the null string, then recordsare separated by blank lines. When RS isset to the null string, then the
newline character alwaysactsasa field separator, in addition to whatever value FS may have.
RSTART The index of the first character matched by match(); 0 if no match.
RLENGTH The length of the string matched by match(); 1 if no match.
SUBSEP The character used to separate multiple subscriptsin array elements, by default n034.
ARRAYS
Arraysare subscripted with an expression between square brackets. If the expression isan expression list (expr , expr ...)
then the array subscript isa string consisting of the concatenation of the (string) value of each expression, separated by the
value of the SUBSEP variable. Thisfacility isused to simulate multiply dimensioned arrays. For example,
i = A ; j = B ; k = C
x[i, j, k] = hello, world\n
assignsthe string hello, world\n to the element of the array x which isindexed by the string A\034B\034C. All arraysin awk
are associative, that isindexed by string values.
The special operator in may be used in an if or while statement to see if an array hasan index consisting of a particular
value:
if (val in array)
print array[val]
If the array hasmultiple subscripts, use (i,j)in array.
The in construct may also be used in a for loop to iterate over all the elementsof an array.
An element may be deleted from an array using the delete statement. The delete statement may also be used to delete the
entire contentsof an array.
VARIABLE TYPING AND CONVERSION
Variablesand fieldsmay be floating-point numbers, or strings, or both. How the value of a variable isinterpreted depends
upon itscontext. If used in a numeric expression, it will be treated asa number; if used asa string, it will be treated asa
string.
To force a variable to be treated asa number, add 0 to it; to force it to be treated asa string, concatenate it with the null
string.
165
When a string must be converted to a number, the conversion isaccomplished using atof(3). A number isconverted to a
string by using the value of CONVFMT asa format string for sprintf(3), with the numeric value of the variable asthe argument.
However, even though all numbersin awk are floating-point, integral valuesare alwaysconverted asintegers. Thus, given this:
CONVFMT = %2.2f
a =12
b =a
the variable b hasa string value of 12 and not 12.00.
gawk performscomparisonsasfollows: If two variablesare numeric, they are compared numerically. If one value isnumeric
and the other hasa string value that isa numeric string, then comparisonsare also done numerically. Otherwise, the
numeric value isconverted to a string and a string comparison isperformed. Two stringsare compared, of course, asstrings.
According to the standard, even if two stringsare numeric strings, a numeric comparison isperformed. However, thisis
clearly incorrect, and gawk doesnot do this.
Uninitialized variableshave the numeric value 0 and the string value (the null, or empty, string).
PATTERNS AND ACTIONS
awk isa line-oriented language. The pattern comesfirst, and then the action. Action statementsare enclosed in and .BR.
Either the pattern may be missing, or the action may be missing, but, of course, not both. If the pattern ismissing, the action
will be executed for every single line of input. A missing action isequivalent to
{ print }
which printsthe entire line.
Commentsbegin with the # character, and continue until the end of the line. Blank linesmay be used to separate state-
ments. Normally, a statement endswith a newline, however, thisisnot the case for linesending in a ,, {, ?, :, &&, or ||. Lines
ending in do or else also have their statementsautomatically continued on the following line. In other cases, a line can be
continued by ending it with a \, in which case the newline will be ignored.
Multiple statementsmay be put on one line by separating them with a semicolon. Thisappliesto both the statementswithin
the action part of a pattern-action pair (the usual case), and to the pattern-action statementsthemselves.
PATTERNS
awk patternsmay be one of the following:
BEGIN
END
/r egul ar expr essi on/
relational expression
pat t er n && pat t er n
pat t er n jj pat t er n
pat t er n ? pat t er n : pat t er n
(pat t er n)
! pat t er n
pat t er n1, pat t er n2
BEGIN and END are two special kindsof patternsthat are not tested against the input. The action partsof all BEGIN patternsare
merged asif all the statementshad been written in a single BEGIN block. They are executed before any of the input isread.
Similarly, all the END blocksare merged, and executed when all the input isexhausted (or when an exit statement is
executed). BEGIN and END patternscannot be combined with other patternsin pattern expressions. BEGIN and END patterns
cannot have missing action parts.
For /r egul ar expr essi on/ patterns, the associated statement isexecuted for each input line that matchesthe regular
expression. Regular expressionsare the same asthose in egrep(1), and are summarized asfollows:
gawk
Part I: User Commands
166
A r el at i onal ex pr essi on may use any of the operatorsdefined later in the section on actions. These generally test whether
certain fieldsmatch certain regular expressions.
The &&, ||, and ! operatorsare logical AND, logical OR, and logical NOT, respectively, asin C. They do short-circuit evaluation,
also asin C, and are used for combining more primitive pattern expressions. Asin most languages, parenthesesmay be used
to change the order of evaluation.
The ?: operator islike the same operator in C. If the first pattern istrue, then the pattern used for testing isthe second
pattern; otherwise, it isthe third. Only one of the second and third patternsisevaluated.
The pat t er n1, pat t er n2 form of an expression iscalled a rangepattern. It matchesall input recordsstarting with a line that
matchespat t er n1, and continuing until a record that matchespat t er n2, inclusive. It doesnot combine with any other sort of
pattern expression.
REGULAR EXPRESSIONS
Regular expressionsare the extended kind found in egrep. They are composed of charactersasfollows:
c Matchesthe non-meta-character c.
\c Matchesthe literal character c.
. Matchesany character except newline.
Matchesthe beginning of a line or a string.
$ Matchesthe end of a line or a string.
[abc. . . ] Character class, matchesany of the charactersabc....
[abc. . . ] Negated character class, matchesany character except abc... and newline.
r 1|r 2 Alternation: matcheseither r 1 or r 2.
r 1r 2 Concatenation: matchesr 1, and then r 2.
r + Matchesone or more r s.
r * Matcheszero or more r s.
r ? Matcheszero or one r s.
(r ) Grouping: matches r .
The escape sequencesthat are valid in string constantsare also legal in regular expressions.
ACTIONS
Action statementsare enclosed in braces, { and }. Action statementsconsist of the usual assignment, conditional, and looping
statementsfound in most languages. The operators, control statements, and input/output statementsavailable are patterned
after those in C.
OPERATORS
The operatorsin awk, in order of increasing precedence, are
=+== Assignment. Both absolute assignment (var = val ue) and operator-assignment (the other forms) are
*= /= %= = supported.
?: The C conditional expression. Thishasthe form expr 1 ? expr 2 : expr 3 .If expr 1 istrue, the value of the
expression isexpr 2; otherwise, it isexpr 3. Only one of expr 2 and expr 3 isevaluated.
|| Logical OR.
&& Logical AND.
! Regular expression match, negated match. NOTE: Do not use a constant regular expression (/foo/) to the
left of a or !. Only use one on the right side. The expression /foo/ exp hasthe same meaning as(($0
/foo/) exp). Thisisusually not what wasintended.
< >, <=>= The regular relational operators.
bl ank String concatenation.
+ Addition and subtraction.
167
*/% Multiplication, division, and modulus.
+! Unary plus, unary minus, and logical negation.
^ Exponentiation (** may also be used, and **= for the assignment operator).
++ Increment and decrement, both prefix and postfix.
$ Field reference.
CONTROL STATEMENTS
The control statementsare asfollows:
if (condition) statement [ else statement ]
while (condition) statement
do statement while (condition)
for (expr1; expr2; expr3) statement
for (var in array) statementbreak
continue
delete array[index]
delete array
exit [ expression ]
{ statements }
I/O STATEMENTS
The input/output statementsare asfollows:
close(f i l ename) Close file (or pipe, see paragraph following thislist).
getline Set $0 from next input record; set NF, NR, FNR.
getline <f i l e Set $0 from next record of f i l e; set NF.
getline var Set var from next input record; set NF, FNR.
getline var <f i l e Set var from next record of f i l e.
next Stop processing the current input record. The next input record isread and processing starts
over with the first pattern in the awk program. If the end of the input data isreached, the
END block(s), if any, are executed.
next file Stop processing the current input file. The next input record read comesfrom the next
input file. FILENAME isupdated, FNR isreset to 1, and processing startsover with the first
pattern in the awk program. If the end of the input data isreached, the END block(s), if any,
are executed.
print Printsthe current record.
print expr - l i st Printsexpressions. Each expression isseparated by the value of the OFS variable. The output
record isterminated with the value of the ORS variable.
print expr - l i st >f i l e Printsexpressionson f i l e. Each expression isseparated by the value of the OFS variable. The
output record isterminated with the value of the ORS variable.
printf f mt , expr - l i s t Format and print.
printf f mt , expr - l i s t >f i l e Format and print on f i l e.
system(cmd- l i ne) Execute the command cmd- l i ne, and return the exit status. (Thismay not be available on -
POSIX systems.)
Other input/output redirectionsare also allowed. For print and printf, >>f i l e appendsoutput to the f i l e, while | command
writeson a pipe. In a similar fashion, command | getline pipesinto getline. The getline command will return 0 on end of
file, and 1 on an error.
THE printf STATEMENT
The awk versionsof the printf statement and sprintf() function accept the following conversion specification formats:
%c An ASCII character. If the argument used for %c isnumeric, it istreated asa character and printed.
Otherwise, the argument isassumed to be a string, and the only first character of that string isprinted.
gawk
Part I: User Commands
168
%d A decimal number (the integer part).
%i Just like %d.
%e A floating-point number of the form []d.ddddddE[+]dd.
%f A floating-point number of the form []ddd.dddddd.
%g Use e or f conversion, whichever isshorter, with nonsignificant zerossuppressed.
%o An unsigned octal number (again, an integer).
%s A character string.
%x An unsigned hexadecimal number (an integer).
%X Like %x, but using ABCDEF instead of abcdef.
%% A single % character; no argument isconverted.
There are optional, additional parametersthat may lie between the % and the control letter:
The expression should be left-justified within itsfield.
wi dt h The field should be padded to thiswidth. If the number hasa leading zero, then the field will be padded
with zeros. Otherwise, it ispadded with blanks. Thisapplieseven to the nonnumeric output formats.
.pr ec A number indicating the maximum width of stringsor digitsto the right of the decimal point.
The dynamic wi dt h and pr ec capabilitiesof the C printf() routinesare supported. A * in place of either the wi dt h or pr ec
specificationswill cause their valuesto be taken from the argument list to printf or sprintf().
SPECIAL FILENAMES
When doing I/O redirection from either print or printf into a file, or via getline from a file, gawk recognizescertain special
filenamesinternally. These filenamesallow accessto open file descriptorsinherited from gawksparent process(usually the
shell). Other special filenamesprovide accessinformation about the running gawk process. The filenamesare
/dev/pid Reading thisfile returnsthe processID of the current process, in decimal, terminated with a newline.
/dev/ppid Reading thisfile returnsthe parent processID of the current process, in decimal, terminated with a
newline.
/dev/pgrpid Reading thisfile returnsthe processgroup ID of the current process, in decimal, terminated with a
newline.
/dev/user Reading thisfile returnsa single record terminated with a newline. The fieldsare separated with blanks. $1
isthe value of the getuid(2) system call, $2 isthe value of the geteuid(2) system call, $3 isthe value of the
getgid(2) system call, and $4 isthe value of the getegid( 2) system call. If there are any additional fields,
they are the group IDsreturned by getgroups(2). Multiple groupsmay not be supported on all systems.
/dev/stdin The standard input.
/dev/stdout The standard output.
/dev/stderr The standard error output.
/dev/fd/n The file associated with the open file descriptor n.
These are particularly useful for error messages. For example, you could use
print You blew it! > /dev/stderr
whereasyou would otherwise have to use
print You blew it! j cat 1>&2
These filenamesmay also be used on the command line to name data files.
NUMERIC FUNCTIONS
awk hasthe following predefined arithmetic functions:
atan2(y , x ) Returnsthe arctangent of y/x in radians.
cos(expr ) Returnsthe cosine in radians.
169
exp(expr ) The exponential function.
int(expr ) Truncatesto integer.
log(expr ) The natural logarithm function.
rand() Returnsa random number between 0 and 1.
sin(expr ) Returnsthe sine in radians.
sqrt(expr ) The square root function.
srand(expr ) Use expr asa new seed for the random number generator. If no expr isprovided, the time of day will be
used. The return value isthe previousseed for the random number generator.
STRING FUNCTIONS
awk hasthe following predefined string functions:
gsub(r , s, t ) For each substring matching the regular expression r in the string t , substitute the string s,
and return the number of substitutions. If t isnot supplied, use $0.
index(s , t ) Returnsthe index of the string t in the string s,or 0 if t isnot present.
length(s ) Returnsthe length of the string s, or the length of $0 if s isnot supplied.
match(s , r ) Returnsthe position in s where the regular expression r occurs, or 0 if u isnot present, and
setsthe valuesof RSTART and RLENGTH.
split(s , a, r ) Splitsthe string s into the array a on the regular expression r , and returnsthe number of
fields. If r isomitted, FS isused instead. The array a iscleared first.
sprintf(f mt , expr - l i st ) Printsexpr - l i st according to f mt , and returnsthe resulting string.
sub(r , s , t ) Just like gsub(), but only the first matching substring isreplaced.
substr(s, i , n) Returnsthe n-character substring of s starting at i . If n isomitted, the rest of s isused.
tolower(st r ) Returnsa copy of the string st r , with all the uppercase charactersin st r translated to their
corresponding lowercase counterparts. Nonalphabetic charactersare left unchanged.
toupper(st r ) Returnsa copy of the string st r , with all the lowercase charactersin st r translated to their
corresponding uppercase counterparts. Nonalphabetic charactersare left unchanged.
TIME FUNCTIONS
Since one of the primary usesof awk programsisprocessing log filesthat contain time stamp information, gawk providesthe
following two functionsfor obtaining time stampsand formatting them.
systime() Returnsthe current time of day asthe number of secondssince the Epoch (Midnight UTC,
January 1, 1970 on systems).
strftime(f or mat , t i mest amp) Formatst i mest amp according to the specification in f or mat . The t i mest amp should be of the
same form asreturned by systime(). If t i mest amp ismissing, the current time of day isused.
See the specification for the strftime() function in C for the format conversionsthat are
guaranteed to be available. A public-domain version of strftime(3) and a man page for it are
shipped with gawk; if that version wasused to build gawk, then all of the conversions
described in that man page are available to gawk.
STRING CONSTANTS
String constantsin awk are sequencesof charactersenclosed between double quotes(). Within strings, certain escape
sequencesare recognized, asin C. These are
\\ A literal backslash.
\a The alert character; usually the ASCII BEL character.
\b Backspace.
\f Formfeed.
\n Newline.
gawk
Part I: User Commands
170
\r Carriage return.
\t Horizontal tab.
\v Vertical tab.
\xhex di gi t s The character represented by the string of hexadecimal digitsfollowing the \x. Asin C, all following
hexadecimal digitsare considered part of the escape sequence. (Thisfeature should tell ussomething about
language design by committee.) For example, \x1B isthe ASCII ESC (escape) character.
\ ddd The character represented by the 1-, 2-, or 3-digit sequence of octal digits. For example, \033 isthe
ASCII ESC (escape) character.
\ c The literal character c.
The escape sequencesmay also be used inside constant regular expressions(for example, /[\\t\f\n\r\v]/ matcheswhitespace
characters).
FUNCTIONS
Functionsin awk are defined asfollows:
f unct i on name(par amet er l i s t ) { st at ement s }
Functionsare executed when called from within the action partsof regular pattern-action statements. Actual parameters
supplied in the function call are used to instantiate the formal parametersdeclared in the function. Arraysare passed by
reference, other variablesare passed by value.
Functionswere not originally part of the awk language, so the provision for local variablesisrather clumsy: They are declared
asextra parametersin the parameter list. The convention isto separate local variablesfrom real parametersby extra spacesin
the parameter list. For example
function f(p, q, a, b) { # a & b are local
..... }
/abc/ { ... ; f(1, 2) ; ... }
The left parenthesisin a function call isrequired to immediately follow the function name, without any intervening
whitespace. Thisisto avoid a syntactic ambiguity with the concatenation operator. Thisrestriction doesnot apply to the
built-in functionslisted earlier.
Functionsmay call each other and may be recursive. Function parametersused aslocal variablesare initialized to the null
string and the number zero upon function invocation.
The word func may be used in place of function.
EXAMPLES
Print and sort the login namesof all users:
BEGIN { FS = : }
{ print $1 j sort }
Count linesin a file:
{ nlines++ }
END { print nlines }
Precede each line by itsnumber in the file:
{ print FNR, $0 }
Concatenate and line number (a variation on a theme):
{ print NR, $0 }
171
SEE ALSO
egrep(1), getpid(2), getppid(2), getpgrp(2), getuid(2), geteuid(2), getgid(2), getegid(2), get-groups(2)
TheAWK ProgrammingLanguage, Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger, Addison-Wesley, 1988. ISBN
0-201-07981-X.
TheGAWK Manual, Edition 0.15, published by the Free Software Foundation, 1993.
POSIX COMPATIBILITY
A primary goal for gawk iscompatibility with the standard, aswell aswith the latest version of awk. To thisend, gawk
incorporatesthe following user-visible featuresthat are not described in the awk book, but are part of awk in System V
Release 4, and are in the standard.
The v option for assigning variablesbefore program execution startsisnew. The book indicatesthat command-line variable
assignment happenswhen awk would otherwise open the argument asa file, which isafter the BEGIN block isexecuted.
However, in earlier implementations, when such an assignment appeared before any filenames, the assignment would happen
beforethe BEGIN block wasrun. Applicationscame to depend on thisfeature. When awk waschanged to match its
documentation, thisoption wasadded to accommodate applicationsthat depended upon the old behavior. (Thisfeature was
agreed on by both the AT&T and GNU developers.)
The W option for implementation-specific featuresisfrom the standard.
When processing arguments, gawk usesthe special option to signal the end of arguments. In compatibility mode, it will
warn about, but otherwise ignore, undefined options. In normal operation, such argumentsare passed on to the awk program
for it to process.
The awk book doesnot define the return value of srand(). The System V Release 4 version of awk (and the standard) hasit
return the seed it wasusing, to allow keeping track of random number sequences. Therefore, srand() in gawk also returnsits
current seed.
Other new featuresare: the use of multiple f options(from MKS awk); the ENVIRON array; the \a, and \v escape sequences
(done originally in gawk and fed back into AT&Tsversion); the tolower() and toupper() built-in functions(from AT&T);
and the C conversion specificationsin printf (done first in AT&Tsversion).
GNU EXTENSIONS
gawk hassome extensionsto awk. They are described in thissection. All the extensionsdescribed here can be disabled by
invoking gawk with the W compat option.
The following featuresof gawk are not available in awk:
The \x escape sequence.
The systime() and strftime() functions.
The special filenamesavailable for I/O redirection are not recognized.
The ARGIND and ERRNO variablesare not special.
The IGNORECASE variable and itsside effects.
The FIELDWIDTHS variable and fixed width field splitting.
No path search isperformed for filesnamed via the f option. Therefore, the AWKPATH environment variable isnot special.
The use of next file to abandon processing of the current input file.
The use of delete ar r ay to delete the entire contentsof an array.
The awk book doesnot define the return value of the close() function. gawksclose() returnsthe value from fclose(3), or
pclose(3), when closing a file or pipe, respectively.
When gawk isinvoked with the W compat option, if the fs argument to the F option ist, then FS will be set to the tab
character. Since thisisa rather ugly special case, it isnot the default behavior. Thisbehavior also doesnot occur if Wposix
hasbeen specified.
gawk
Part I: User Commands
172
HISTORICAL FEATURES
There are two featuresof historical awk implementationsthat gawk supports. First, it ispossible to call the length() built-in
function not only with no argument, but even without parentheses! Thus, this:
a = length
isthe same aseither of these:
a = length()
a = length($0)
Thisfeature ismarked asdeprecated in the standard, and gawk will issue a warning about itsuse if W lint isspecified on
the command line.
The other feature isthe use of either the continue or the break statementsoutside the body of a while, for, or do loop.
Traditional awk implementationshave treated such usage asequivalent to the next statement. gawk will support thisusage
if W compat hasbeen specified.
ENVIRONMENT VARIABLES
If POSIXLY_CORRECT existsin the environment, then gawk behavesexactly asif -posix had been specified on the command
line. If -lint hasbeen specified, gawk will issue a warning message to thiseffect.
BUGS
The F option isnot necessary given the command-line variable assignment feature; it remainsonly for backwardscompat-
ibility.
If your system actually hassupport for /dev/fd and the associated /dev/stdin, /dev/stdout, and /dev/stderr files, you may get
different output from gawk than you would get on a system without those files. When gawk interpretsthese filesinternally, it
synchronizesoutput to the standard output with output to /dev/stdout, while on a system with those files, the output is
actually to different open files. Caveat emptor.
VERSION INFORMATION
Thisman page documentsgawk, version 2.15.
Starting with the 2.15 version of gawk, the c, V, C, D, a, and e optionsof the 2.11 version are no longer recognized. This
fact will not even be documented in the manual page for the next major version.
AUTHORS
The original version of awk wasdesigned and implemented by Alfred Aho, Peter Weinberger, and Brian Kernighan of AT&T
Bell Labs. Brian Kernighan continuesto maintain and enhance it.
Paul Rubin and Jay Fenlason, of the Free Software Foundation, wrote gawk, to be compatible with the original version of awk
distributed in the seventh edition. John Woodscontributed a number of bug fixes. David Trueman, with contributionsfrom
Arnold Robbins, made gawk compatible with the new version of awk. Arnold Robbinsisthe current maintainer.
The initial DOS port wasdone by Conrad Kwok and Scott Garfinkle. Scott Deifik isthe current DOSmaintainer. Pat
Rankin did the port to VMS, and Michal Jaegermann did the port to the Atari ST. The port to OS/2 wasdone by Kai Uwe
Rommel, with contributionsand help from Darrel Hankerson.
BUG REPORTS
If you find a bug in gawk, please send electronic mail to
bug-gnu-utils@prep.ai.mit.edu,
with a copy to arnold@gnu.ai.mit.edu. Please include your operating system and itsrevision, the version of gawk, what C
compiler you used to compile it, and a test program and data that are assmall aspossible for reproducing the problem.
173
Before sending a bug report, please do two things. First, verify that you have the latest version of gawk. Many bugs(usually
subtle ones) are fixed at each release, and if yoursisout of date, the problem may already have been solved. Second, please
read thisman page and the reference manual carefully to be sure that what you think isa bug really is, instead of just a quirk
in the language.
ACKNOWLEDGMENTS
Brian Kernighan of Bell Labsprovided valuable assistance during testing and debugging.
We thank him.
FreeSoftwareFoundation, 24 November 1994
gcal
gcalDisplaysmonth/year calendar sheets, eternal holiday listsfor Julian and Gregorian years, and fixed date warning
listsall in a variety of ways.
SYNOPSIS
gcal [[ Opt i on... ][%Dat e ][@Fi l e... ]] [ Command ]
DESCRIPTION
gcal isa program similar the standard calendar programsBSDcal and calendar.
gcal displaysGregorian calendars, Julian calendars(before September 1752).
If gcal isstarted without any optionsor commands, a calendar of the current month isdisplayed.
If the calendar of a definite year iswanted, the year must be fully specified. For example, gcal 94 displaysa year calendar of
the year 94, not of the year 1994.
If two argumentsare given in the command part, the first argument denotesthe month and the second argument denotesthe
year. In case any illegal commands are given running gcal, the program will use internal defaults.
The Gregorian Reformation isassumed to have occurred in 1752 on the 3rd of September. Ten daysfollowing that date
were eliminated by the reformation, so the calendar for that month isa bit unusual.
MORE PROGRAM INFORMATION
You get more program information if you start gcal asfollows:
gcal -h gcal -? gcal help
resp.,
gcal -hh gcal -?? gcal long-help[=ARG]j[=?] gcal usage[=ARG]j[=?]
A hypertext file gcal.info containing detailed online information should be available, which you can inspect using your
GNU Infobrowser.
COPYRIGHT
gcal copyright 1994, 1995, 1996 by ThomasEsken. Thissoftware doesnt claim completeness, correctness, or usability.
On principle, I will not be liable for any damagesor losses(implicit or explicit), which result from using or handling my
software. If you use thissoftware, you agree without any exception to thisagreement, which bindsyou legally.
gcal isfree software and distributed under the termsof the GNU General Public License; published by the Free Software
Foundation; version 2 or (at your option) any later version.
Any suggestions, improvements, extensions, bug reports, donations, proposalsfor contract work, and so forth are welcome!
If you like thistool, Id appreciate a postcard from you!
Enjoy it =8)
gcal
Part I: User Commands
174
AUTHOR
ThomasEsken (esken@uni-muenster.de)
Im Hagenfeld 84
D-48147 Muenster; Germany
Phone : +49 251 232585
SEE ALSO
cal(1), calendar(1)
16 July1996
gcc, g++
gcc, g++GNU project C and C++ Compiler (v2.7)
SYNOPSIS
gcc [ opt i on j f i l ename ]. . .
g++ [ opt i on j f i l ename ]...
WARNING
The information in thisman page isan extract from the full documentation of the GNU C compiler and islimited to the
meaning of the options.
Thisman page isnot kept up-to-date except when volunteerswant to maintain it. If you find a discrepancy between the man
page and the software, please check the info file, which isthe authoritative documentation.
If we find that the thingsin thisman page that are out of date cause significant confusion or complaints, we will stop
distributing the man page. The alternative, updating the man page when we update the info file, isimpossible because the
rest of the work of maintaining GNU CC leavesusno time for that. The GNU project regardsman pagesasobsolete and
should not let them take time away from other things.
For complete and current documentation, refer to the info file gcc or the manual Usingand PortingGNU CC (for version
2.0). Both are made from the Texinfo source file gcc.texinfo.
DESCRIPTION
The C and C++ compilersare integrated. Both processinput filesthrough one or more of four stages: preprocessing,
compilation, assembly, and linking. Source filename suffixesidentify the source language, but which name you use for the
compiler governsdefault assumptions:
gcc Assumespreprocessed (.i) filesare C and assumesC-style linking.
g++ Assumespreprocessed (.i) filesare C++ and assumesC++-style linking.
Suffixesof source filenamesindicate the language and kind of processing to be done:
.c C source; preprocess, compile, assemble
.C C++ source; preprocess, compile, assemble
.cc C++ source; preprocess, compile, assemble
.cxx C++ source; preprocess, compile, assemble
.m Objective-C source; preprocess, compile, assemble
.i Preprocessed C; compile, assemble
.ii Preprocessed C++; compile, assemble
.s Assembler source; assemble
175
.S Assembler source; preprocess, assemble
.h Preprocessor file; not usually named on command line
Fileswith other suffixesare passed to the linker. Common casesinclude
.o Object file
.a Archive file
Linking isalwaysthe last stage unlessyou use one of the c, S, or E optionsto avoid it (or unlesscompilation errorsstop
the whole process). For the link stage, all .o filescorresponding to source files, l libraries, unrecognized filenames(including
named .o object files, and .a archives) are passed to the linker in command-line order.
OPTIONS
Optionsmust be separate: dr isquite different from d r.
Most f and W optionshave two contrary forms: fname and fno-name (or Wname and Wnoname). Only the nondefault forms
are shown here.
Here isa summary of all the options, grouped by type. Explanationsare in the following sections.
Overall Options
c S E o f i l e pipe v x l anguage
Language Options
ansi fallvirtual fcondmismatch
fdollarsinidentifiers fenumintequiv fexternaltemplates
fnoasm fnobuiltin fnostrictprototype
fsignedbitfields fsignedchar fthisisvariable
funsignedbitfields funsignedchar fwritablestrings
traditional traditionalcpp trigraphs
Warning Options
fsyntaxonly pedantic pedanticerrors
w W Wall Waggregatereturn Wcastalign
Wcastqual Wcharsubscript Wcomment
Wconversion Wenumclash Werror
Wformat Widclashlen Wimplicit
Winline Wmissingprototypes Wmissingdeclarations
Wnestedexterns Wnoimport Wparentheses
Wpointerarith Wredundantdecls Wreturntype
Wshadow Wstrictprototypes Wswitch
Wtemplatedebugging Wtraditional Wtrigraphs
Wuninitialized Wunused Wwritestrings
Debugging Options
a dl et t er s fpretendfloat g gl evel gcoff gxcoff gxcoff+ gdwarf gdwarf+ gstabs gstabs+ ggdb p pg
save temps printfilename=l i br ar y printlibgccfilename printprogname=pr ogr am
Optimization Options
fcallersaves fcsefollowjumps fcseskipblocks
fdelayedbranch felideconstructors fexpensiveoptimizations
ffastmath ffloatstore fforceaddr
fforcemem finlinefunctions fkeepinlinefunctions
gcc, g++
Part I: User Commands
176
fmemorizelookups fnodefaultinline fnodeferpop
fnofunctioncse fnoinline fnopeephole
fomitframepointer freruncseafterloop fscheduleinsns
fscheduleinsns2 fstrengthreduce fthreadjumps
funrollallloops funrollloops O O2
Preprocessor Options
Aasser t i on C dD dM dN Dmacr o[=def n ]E H idirafter di r include f i l e imacros f i l e iprefix f i l e
iwithprefix di r M MD MM MMD nostdinc P Umacr o undef
Assembler Option
Wa,opt i on
Linker Options
ll i br ar y nostartfiles nostdlib static shared symbolic Xlinkernopt i on Wl,opt i on u symbol
Directory Options
Bpr ef i x Idi r I Ldi r
Target Options
b machine V ver si on
Configuration-Dependent Options
M680x0 Options
m68000m68020 m6802040m68030m68040m68881 mbitfield mc68000 mc68020 mfpa mnobitfield mrtd mshort msoft
float
VAX Options
mg mgnu munix
SPARC Options
mepilogue mfpu mhardfloat mnofpu mnoepilogue msoftfloat msparclite mv8 msupersparc mcypress
Convex Options
margcount mc1 mc2 mnoargcount
AMD29K Options
m29000m29050 mbw mdw mkernelregisters mlarge mnbw mnodw msmall mstackcheck muserregisters
M88K Options
m88000 m88100 m88110 mbigpic
mcheckzerodivision mhandlelargeshift
midentifyrevision mnocheckzerodivision
mnoocsdebuginfo mnoocsframeposition
mnooptimizeargarea mnoserializevolatile
mnounderscores mocsdebuginfo
mocsframeposition moptimizeargarea
mserializevolatile mshortdatanum
msvr3 msvr4 mtraplargeshift
musedivinstruction mversion03.00
mwarnpassedstructs
177
RS6000 Options
mfpintoc mnofopintoc
RT Options
mcalllibmul mfparginfpregs mfpargingregs
mfullfpblocks mhcstructreturn minlinemul
mminimumfpblocks mnohcstructreturn
MIPS Options
mcpu=cpu t ype mips2 mips3 mint64 mlong64
mlonglong128 mmipsas mgas mrnames
mnornames mgpopt mnogpopt mstats
mnostats mmemcpy mnomemcpy mnomipstfile
mmipstfile msoftfloat mhardfloat mabicalls
mnoabicalls mhalfpic mnohalfpic G num nocpp
i386 Options
m486 mno486 msoftfloat mnofpretin387
HPPA Options
mparisc10 mparisc11 mkernel msharedlibs mnosharedlibsmlongcallsmdisablefpregsmdisable
indexing mtrailingcolon
i960 Options
mcpu-type
mnumerics msoftfloat mleafprocedures
mnoleafprocedures mtailcall mnotailcall
mcomplexaddr mnocomplexaddr mcodealign
mnocodealign miccompat mic2.0compat
mic3.0compat masmcompat mintelasm
mstrictalign mnostrictalign moldalign
mnooldalign
DEC Alpha Options
mfpregs mnofpregs mnosoftfloat msoftfloat
SystemV Options
G Qy Qn YP,paths Ym,dir
Code-Generation Options
fcallsavedr eg fcallused
r eg ffixedr eg finhibit
sizedirective fnonnull
objects fnocommon fnoident
fnognulinker fpccstruct
return fpic fPIC freg
struct return fshareddata
fshortenums fshortdouble
fvolatile fvolatileglobal
fverboseasm
gcc, g++
Part I: User Commands
178
OVERALL OPTIONS
x l anguage Specify explicitly the l anguage for the following input files(rather than choosing a default based on the
filename suffix). Thisoption appliesto all following input filesuntil the next x option. Possible valuesof
l anguage are c, objectivec, cheader, c++, cppoutput, assembler, and assemblerwithcpp.
x none Turn off any specification of a language, so that subsequent filesare handled according to their filename
suffixes(asthey are if x hasnot been used at all).
If you want only some of the four stages(preprocess, compile, assemble, link), you can use x (or filename suffixes) to tell gcc
where to start, and one of the optionsc, S, or E to say where gcc isto stop. Note that some combinations(for example, x
cppoutput E) instruct gcc to do nothing at all.
c Compile or assemble the source files, but do not link. The compiler output isan object file corresponding
to each source file.
By default, gcc makesthe object filename for a source file by replacing the suffix .c, .i, .s, and so on, with
.o. Use o to select another name.
gcc ignoresany unrecognized input files(those that do not require compilation or assembly) with the c
option.
S Stop after the stage of compilation proper; do not assemble. The output isan assembler code file for each
nonassembler input file specified.
By default, gcc makesthe assembler filename for a source file by replacing the suffix .c, .i, and so on, with
.s. Use o to select another name.
gcc ignoresany input filesthat dont require compilation.
E Stop after the preprocessing stage; do not run the compiler proper. The output ispreprocessed source
code, which issent to the standard output.
gcc ignoresinput filesthat dont require preprocessing.
o f i l e Place output in file f i l e. Thisappliesregardlessto whatever sort of output gcc isproducing, whether it be
an executable file, an object file, an assembler file, or preprocessed C code.
Since only one output file can be specified, it doesnot make sense to use o when compiling more than
one input file, unlessyou are producing an executable file asoutput.
If you do not specify o, the default isto put an executable file in a.out, the object file for sour ce.suf f i x in
sour ce.o, itsassembler file in sour ce.s, and all preprocessed C source on standard output.
v Print (on standard error output) the commandsexecuted to run the stagesof compilation. Also print the
version number of the compiler driver program and of the preprocessor and the compiler proper.
pipe Use pipesrather than temporary filesfor communication between the variousstagesof compilation. This
failsto work on some systemswhere the assembler cannot read from a pipe; but the GNU assembler has
no trouble.
LANGUAGE OPTIONS
The following optionscontrol the dialect of C that the compiler accepts:
ansi Support all ANSI standard C programs.
Thisturnsoff certain featuresof GNU C that are incompatible with ANSI C, such asthe asm,
inline, and typeof keywords, and predefined macrossuch asunix and vax that identify the type
of system you are using. It also enablesthe undesirable and rarely used ANSI trigraph feature,
and disallows$ aspart of identifiers. The alternate keywords__asm__, __extension__,
__inline__, and __typeof__ continue to work despite ansi. You would not want to use them
in an ANSI C program, of course, but it isuseful to put them in header filesthat might be
included in compilationsdone with ansi. Alternate predefined macrossuch as__unix__ and
__vax__ are also available, with or without ansi.
The ansi option doesnot cause non-ANSI programsto be rejected gratuitously. For that,
pedantic isrequired in addition to ansi.
179
The preprocessor predefinesa macro __STRICT_ANSI__ when you use the ansi option. Some
header filesmay notice thismacro and refrain from declaring certain functionsor defining
certain macrosthat the ANSI standard doesnt call for; thisisto avoid interfering with any
programsthat might use these namesfor other things.
fnoasm Do not recognize asm, inline, or typeof asa keyword. These wordsmay then be used as
identifiers. You can use __asm__, __inline__, and __typeof__ instead. ansi impliesfnoasm.
fnobuiltin Dont recognize built-in functionsthat do not begin with two leading underscores. Currently,
the functionsaffected include _exit, abort, abs, alloca, cos, exit, fabs, labs, memcmp, memcpy,
sin, sqrt, strcmp, strcpy,and strlen.
The ansi option preventsalloca and _exit from being built-in functions.
fnostrictprototype Treat a function declaration with no arguments, such asint foo();, asC would treat itas
saying nothing about the number of argumentsor their types(C++ only). Normally, such a
declaration in C++ meansthat the function foo takesno arguments.
trigraphs Support ANSI C trigraphs. The ansi option impliestrigraphs.
traditional Attempt to support some aspectsof traditional C compilers. For details, see the GNU C
Manual; the duplicate list here hasbeen deleted so that we wont get complaintswhen it isout
of date.
But one note about C++ programsonly (not C). traditional hasone additional effect for
C++: assignment to thisispermitted. Thisisthe same asthe effect of fthisisvariable.
traditionalcpp Attempt to support some aspectsof traditional C preprocessors. Thisincludesthe itemsthat
specifically mention the preprocessor previously, but none of the other effectsof traditional.
fdollarsinidentifiers Permit the use of $ in identifiers(C++ only). You can also use fnodollarsinidentifiers to
explicitly prohibit use of $. (GNU C++ allows$ by default on some target systemsbut not
others.)
fenumintequiv Permit implicit conversion of int to enumeration types(C++ only). Normally GNU C++
allowsconversion of enum to int, but not the other way around.
fexternaltemplates Produce smaller code for template declarations, by generating only a single copy of each
template function where it isdefined (C++ only). To use thisoption successfully, you must also
mark all filesthat use templateswith either #pragma implementation (the definition) or #pragma
interface (declarations).
When your code iscompiled with fexternaltemplates, all template instantiationsare external.
You must arrange for all necessary instantiationsto appear in the implementation file; you can
do thiswith a typedef that referenceseach instantiation needed. Conversely, when you compile
using the default option fnoexternaltemplates, all template instantiationsare explicitly
internal.
fallvirtual Treat all possible member functionsasvirtual, implicitly. All member functions(except for
constructor functionsand new or delete member operators) are treated asvirtual functionsof
the classwhere they appear. Thisdoesnot mean that all callsto these member functionswill be
made through the internal table of virtual functions. Under some circumstances, the compiler
can determine that a call to a given virtual function can be made directly; in these cases, the
callsare direct in any case.
fcondmismatch Allow conditional expressionswith mismatched typesin the second and third arguments. The
value of such an expression isvoid.
fthisisvariable Permit assignment to this (C++ only). The incorporation of user-defined free store manage-
ment into C++ hasmade assignment to this an anachronism. Therefore, by default it isinvalid
to assign to thiswithin a classmember function. However, for backwardscompatibility, you
can make it valid with fthis-is-variable.
funsignedchar Let the type char be unsigned, like unsigned char.
Each kind of machine hasa default for what char should be. It iseither like unsigned char by
default or like signed char by default.
gcc, g++
Part I: User Commands
180
Ideally, a portable program should alwaysuse signed char or unsigned char when it dependson
the signednessof an object. But many programshave been written to use plain char and expect
it to be signed, or expect it to be unsigned, depending on the machinesthey were written for.
Thisoption, and itsinverse, letsyou make such a program work with the opposite default.
The type char isalwaysa distinct type from each of signed char and unsigned char, even though
itsbehavior isalwaysjust like one of those two.
fsignedchar Let the type char be signed, like signed char.
Note that thisisequivalent to fnounsignedchar, which isthe negative form of funsigned
char. Likewise, fnosignedchar isequivalent to funsignedchar.
fsignedbitfields These optionscontrol whether a bitfield issigned or unsigned, when declared with no explicit
funsignedbitfields or unsigned qualifier.
fnosignedbitfields By default, such a bitfield issigned, because thisisconsistent: The basic integer typessuch as
int
fnounsignedbitfields signed are signed types.
However, when you specify traditional, bitfieldsare all unsigned no matter what.
fwritablestrings Store string constantsin the writable data segment and dont uniquize them. Thisisfor
compatibility with old programswhich assume they can write into string constants. tradi-
tional also hasthiseffect.
Writing into string constantsisa very bad idea; constantsshould be constant.
PREPROCESSOR OPTIONS
These optionscontrol the C preprocessor, which isrun on each C source file before actual compilation.
If you use the E option, gcc doesnothing except preprocessing. Some of these optionsmake sense only together with E
because they cause the preprocessor output to be unsuitable for actual compilation.
include f i l e Processf i l e asinput before processing the regular input file. In effect, the contentsof f i l e
are compiled first. Any D and U optionson the command line are alwaysprocessed before
include f i l e, regardlessof the order in which they are written. All the include and imacros
optionsare processed in the order in which they are written.
imacros f i l e Processf i l e asinput, discarding the resulting output, before processing the regular input file.
Because the output generated from f i l e isdiscarded, the only effect of imacros f i l e isto make
the macrosdefined in f i l e available for use in the main input. The preprocessor evaluatesany
D and U optionson the command line before processing imacros f i l e, regardlessof the order
in which they are written. All the include and imacros optionsare processed in the order in
which they are written.
idirafter di r Add the directory di r to the second include path. The directorieson the second include path
are searched when a header file isnot found in any of the directoriesin the main include path
(the one that I addsto).
iprefix pr ef i x Specify pr ef i x asthe prefix for subsequent iwithprefix options.
iwithprefix di r Add a directory to the second include path. The directorysname ismade by concatenating
pr ef i x and di r , where pr ef i x wasspecified previously with iprefix.
nostdinc Do not search the standard system directoriesfor header files. Only the directoriesyou have
specified with I options(and the current directory, if appropriate) are searched.
By using both nostdinc and I, you can limit the include file search file to only those
directoriesyou specify explicitly.
nostdinc++ Do not search for header filesin the C++specific standard directories, but do still search the
other standard directories. (Thisoption isused when building libg++.)
undef Do not predefine any nonstandard macros(including architecture flags).
E Run only the C preprocessor. Preprocessall the C source filesspecified and output the resultsto
standard output or to the specified output file.
C Tell the preprocessor not to discard comments. Used with the E option.
181
P Tell the preprocessor not to generate #line commands. Used with the E option.
M [MG] Tell the preprocessor to output a rule suitable for make describing the dependenciesof each
object file. For each source file, the preprocessor outputsone make -rule whose target isthe
object filename for that source file and whose dependenciesare all the filesthat have been
included with #include. Thisrule may be a single line or may be continued with \-newline if it
islong. The list of rulesisprinted on standard output instead of the preprocessed C program.
M impliesE.
MG saysto treat missing header filesasgenerated filesand assume they live in the same directory
asthe source file. It must be specified in addition to M.
MM [MG] Like M but the output mentionsonly the user header filesincluded with #include f i l e .
System header filesincluded with #include < f i l e > are omitted.
MD Like M but the dependency information iswritten to fileswith namesmade by replacing .o
with .d at the end of the output filenames. Thisisin addition to compiling the file asspecified;
MD doesnot inhibit ordinary compilation the way M does.
The Mach utility md can be used to merge the .d filesinto a single dependency file suitable for
using with the make command.
MMD Like MD except mention only user header files, not system header files.
H Print the name of each header file used, in addition to other normal activities.
Aquest i on(answer ) Assert the answer answer for quest i on, in case it istested with a preprocessor conditional such as
#if #quest i on(answer ). A disablesthe standard assertionsthat normally describe the target
machine.
Aquest i on ( answer ) Assert the answer answer for quest i on, in case it istested with a preprocessor conditional such as
#if # quest i on ( answer ). Adisablesthe standard assertionsthat normally describe the target
machine.
Dmacr o Define macro macr o with the string 1 asitsdefinition.
Dmacr o=def n Define macro macr o asdef n. All instancesof D on the command line are processed before any
U options.
Umacr o Undefine macro macr o. U optionsare evaluated after all D options, but before any include and
imacros options.
dM Tell the preprocessor to output only a list of the macro definitionsthat are in effect at the end
of preprocessing. Used with the E option.
dD Tell the preprocessor to passall macro definitionsinto the output, in their proper sequence in
the rest of the output.
dN Like dD except that the macro argumentsand contentsare omitted. Only #define name is
included in the output.
ASSEMBLER OPTION
Wa,opt i on Passopt i on asan option to the assembler. If opt i on containscommas, it issplit into multiple
optionsat the commas.
LINKER OPTIONS
These optionscome into play when the compiler linksobject filesinto an executable output file. They are meaninglessif the
compiler isnot doing a link step.
obj ect - f i l e- name A filename that doesnot end in a special recognized suffix isconsidered to name an object file
or library. (Object filesare distinguished from librariesby the linker according to the file
contents.) If gcc doesa link step, these object filesare used asinput to the linker.
ll i br ar y Use the library named l i br ar y when linking.
The linker searchesa standard list of directoriesfor the library, which isactually a file named
lib l i br ar y .a. The linker then usesthisfile asif it had been specified precisely by name.
gcc, g++
Part I: User Commands
182
The directoriessearched include several standard system directoriesplusany that you specify
with L.
Normally, the filesfound thisway are library filesarchive fileswhose membersare object files.
The linker handlesan archive file by scanning through it for membersthat define symbolsthat
have so far been referenced but not defined. However, if the linker findsan ordinary object file
rather than a library, the object file islinked in the usual fashion. The only difference between
using an l option and specifying a filename isthat l surroundsl i br ar y with lib and .a and
searchesseveral directories.
lobjc You need thisspecial case of the l option in order to link an Objective C program.
nostartfiles Do not use the standard system startup fileswhen linking. The standard librariesare used
normally.
nostdlib Dont use the standard system librariesand startup fileswhen linking. Only the filesyou specify
will be passed to the linker.
static On systemsthat support dynamic linking, thispreventslinking with the shared libraries. On
other systems, thisoption hasno effect.
shared Produce a shared object which can then be linked with other objectsto form an executable.
Only a few systemssupport thisoption.
symbolic Bind referencesto global symbolswhen building a shared object. Warn about any unresolved
references(unlessoverridden by the link editor option Xlinker z Xlinker defs). Only a few
systemssupport thisoption.
Xlinker option Passoption asan option to the linker. You can use thisto supply system-specific linker options
which GNU CC doesnot know how to recognize.
If you want to passan option that takesan argument, you must use Xlinker twice: once for the
option and once for the argument. For example, to passassert definitions, you must write
Xlinker assert Xlinker definitions. It doesnot work to write Xlinker assert
definitions, because thispassesthe entire string asa single argument, which isnot what the
linker expects.
Wl,option Passoption asan option to the linker. If option containscommas, it issplit into multiple
optionsat the commas.
u symbol Pretend the symbol symbol isundefined, to force linking of library modulesto define it. You
can use u multiple timeswith different symbolsto force loading of additional library modules.
DIRECTORY OPTIONS
These optionsspecify directoriesto search for header files, for libraries, and for partsof the compiler:
Idi r Append directory di r to the list of directoriessearched for include files.
I Any directoriesyou specify with I optionsbefore the I option are searched only for the case
of #include f i l e; they are not searched for #include <f i l e>.
If additional directoriesare specified with I optionsafter the I, these directoriesare searched
for all #include directives. (Ordinarily all I directoriesare used thisway.)
In addition, the I option inhibitsthe use of the current directory (where the current input file
came from) asthe first search directory for #include f i l e . There isno way to override this
effect of I. With I. you can specify searching the directory that wascurrent when the
compiler wasinvoked. That isnot exactly the same aswhat the preprocessor doesby default,
but it isoften satisfactory.
I doesnot inhibit the use of the standard system directoriesfor header files. Thus, I and
nostdinc are independent.
Ldi r Add directory di r to the list of directoriesto be searched for l.
Bpr ef i x Thisoption specifieswhere to find the executables, libraries, and data filesof the compiler itself.
The compiler driver program runsone or more of the subprogramscpp, cc1 (or, for C++,
cc1plus), as, and ld. It triespr ef i x asa prefix for each program it triesto run, both with and
without machi ne / ver si on /.
183
For each subprogram to be run, the compiler driver first triesthe B prefix, if any. If that name
isnot found, or if B wasnot specified, the driver triestwo standard prefixes, which are /usr/
lib/gcc/ and /usr/local/lib/gcc-lib/. If neither of those resultsin a filename that isfound, the
compiler driver searchesfor the unmodified program name, using the directoriesspecified in
your PATH environment variable.
The runtime support file libgcc.a isalso searched for using the B prefix, if needed. If it isnot
found there, the two standard prefixes(preceding paragraph) are tried, and that isall. The file is
left out of the link if it isnot found by those means. Most of the time, on most machines,
libgcc.a isnot actually necessary.
You can get a similar result from the environment variable GCC_EXEC_PREFIX; if it isdefined, its
value isused asa prefix in the same way. If both the B option and the GCC_EXEC_PREFIX variable
are present, the B option isused first and the environment variable value second.
WARNING OPTIONS
Warningsare diagnostic messagesthat report constructionsthat are not inherently erroneousbut are risky or suggest there
may have been an error.
These optionscontrol the amount and kindsof warningsproduced by GNU CC:
fsyntaxonly Check the code for syntax errors, but dont emit any output.
w Inhibit all warning messages.
Wnoimport Inhibit warning messagesabout the use of #import.
pedantic Issue all the warningsdemanded by strict ANSI standard C; reject all programsthat use
forbidden extensions.
Valid ANSI standard C programsshould compile properly with or without thisoption (though
a rare few will require ansi). However, without thisoption, certain GNU extensionsand
traditional C featuresare supported aswell. With thisoption, they are rejected. There isno
reason to use thisoption; it existsonly to satisfy pedants.
pedantic doesnot cause warning messagesfor use of the alternate keywordswhose namesbegin
and end with __. Pedantic warningsare also disabled in the expression that followsextension.
However, only system header filesshould use these escape routes; application programsshould
avoid them.
pedanticerrors Like pedantic, except that errorsare produced rather than warnings.
W Print extra warning messagesfor these events:
A nonvolatile automatic variable might be changed by a call to longjmp. These warningsare
possible only in optimizing compilation. The compiler seesonly the callsto setjmp. It cannot
know where longjmp will be called; in fact, a signal handler could call it at any point in the code.
Asa result, you may get a warning even when there isin fact no problem because longjmp
cannot in fact be called at the place which would cause a problem.
A function can return either with or without a value. (Falling off the end of the function body
isconsidered returning without a value.) For example, thisfunction would evoke such a
warning:
foo (a)
{
if (a > 0)
return a;
}
Spuriouswarningscan occur because GNU CC doesnot realize that certain functions
(including abort and longjmp) will never return.
An expression-statement or the left side of a comma expression containsno side effects. To
suppressthe warning, cast the unused expression to void. For example, an expression such as
x[i,j] will cause a warning, but x[(void)i,j] will not.
An unsigned value iscompared against zero with > or <=.
gcc, g++
Part I: User Commands
184
Wimplicit Warn whenever a function or parameter isimplicitly declared.
Wreturntype Warn whenever a function isdefined with a return-type that defaultsto int. Also warn about
any return statement with no return-value in a function whose return-type isnot void.
Wunused Warn whenever a local variable isunused aside from itsdeclaration, whenever a function is
declared static but never defined, and whenever a statement computesa result that isexplicitly
not used.
Wswitch Warn whenever a switch statement hasan index of enumeral type and lacksa case for one or
more of the named codesof that enumeration. (The presence of a default label preventsthis
warning.) case labelsoutside the enumeration range also provoke warningswhen thisoption is
used.
Wcomment Warn whenever a comment-start sequence / appearsin a comment.
Wtrigraphs Warn if any trigraphsare encountered (assuming they are enabled).
Wformat Check callsto printf and scanf, and so on, to make sure that the argumentssupplied have
typesappropriate to the format string specified.
Wcharsubscripts Warn if an array subscript hastype char. Thisisa common cause of error, asprogrammers
often forget that thistype issigned on some machines.
Wuninitialized An automatic variable isused without first being initialized.
These warningsare possible only in optimizing compilation, because they require data flow
information that iscomputed only when optimizing. If you dont specify O, you simply wont
get these warnings.
These warningsoccur only for variablesthat are candidatesfor register allocation. Therefore,
they do not occur for a variable that isdeclared volatile, or whose addressistaken, or whose size
isother than 1, 2, 4, or 8 bytes. Also, they do not occur for structures, unions, or arrays, even
when they are in registers.
Note that there may be no warning about a variable that isused only to compute a value that
itself isnever used, because such computationsmay be deleted by data flow analysisbefore the
warningsare printed.
These warningsare made optional because GNU CC isnot smart enough to see all the reasons
why the code might be correct despite appearing to have an error. Here isone example of how
thiscan happen:
{
int x;
switch (y)
{
case 1: x = 1;
break;
case 2: x = 4;
break;
case 3: x = 5;
}
foo (x);
}
If the value of y isalways1, 2, or 3, then x isalwaysinitialized, but GNU CC doesnt know this.
Here isanother common case:
{
int save_y;
if (change_y) save_y =y,y =new_y;
...
if (change_y)y =save_y;
}
Thishasno bug because save_y isused only if it isset.
Some spuriouswarningscan be avoided if you declare asvolatile all the functionsyou use that
never return.
185
Wparentheses Warn if parenthesesare omitted in certain contexts.
Wtemplatedebugging When using templatesin a C++ program, warn if debugging isnot yet fully available (C++
only).
Wall All of the preceding W optionscombined. These are all the optionsthat pertain to usage that
we recommend avoiding and that we believe iseasy to avoid, even in conjunction with macros.
The remaining W... optionsare not implied by Wall because they warn about constructionsthat we consider reasonable to
use, on occasion, in clean programs.
Wtraditional Warn about certain constructsthat behave differently in traditional and ANSI C:
Macro argumentsoccurring within string constantsin the macro body. These would substitute
the argument in traditional C, but are part of the constant in ANSI C.
A function declared external in one block and then used after the end of the block.
A switch statement hasan operand of type long.
Wshadow Warn whenever a local variable shadowsanother local variable.
Widclashl en Warn whenever two distinct identifiersmatch in the first l en characters. Thismay help you
prepare a program that will compile with certain obsolete, brain-damaged compilers.
Wpointerarith Warn about anything that dependson the size of a function type or of void. GNU C assigns
these typesa size of 1, for convenience in calculationswith void pointersand pointersto
functions.
Wcastqual Warn whenever a pointer iscast so asto remove a type qualifier from the target type. For
example, warn if a const char iscast to an ordinary char.
Wcastalign Warn whenever a pointer iscast such that the required alignment of the target isincreased. For
example, warn if a char iscast to an int on machineswhere integerscan only be accessed at
two- or four-byte boundaries.
Wwritestrings Give string constantsthe type const char[ l engt h ] so that copying the addressof one into a
non-const char pointer will get a warning. These warningswill help you find at compile time
code that can try to write into a string constant, but only if you have been very careful about
using const in declarationsand prototypes. Otherwise, it will just be a nuisance; thisiswhy we
did not make Wall request these warnings.
Wconversion Warn if a prototype causesa type conversion that isdifferent from what would happen to the
same argument in the absence of a prototype. Thisincludesconversionsof fixed point to
floating and vice versa, and conversionschanging the width or signednessof a fixed point
argument except when the same asthe default promotion.
Waggregatereturn Warn if any functionsthat return structuresor unionsare defined or called. (In languages
where you can return an array, thisalso elicitsa warning.)
Wstrictprototypes Warn if a function isdeclared or defined without specifying the argument types. (An old-style
function definition ispermitted without a warning if preceded by a declaration which specifies
the argument types.)
Wmissingprototypes Warn if a global function isdefined without a previousprototype declaration. Thiswarning is
issued even if the definition itself providesa prototype. The aim isto detect global functions
that fail to be declared in header files.
Wmissingdeclarations Warn if a global function isdefined without a previousdeclaration. Do so even if the definition
itself providesa prototype. Use thisoption to detect global functionsthat are not declared in
header files.
Wredundant-decls Warn if anything isdeclared more than once in the same scope, even in caseswhere multiple
declaration isvalid and changesnothing.
Wnested-externs Warn if an extern declaration isencountered within an function.
Wenumclash Warn about conversion between different enumeration types(C++ only).
Woverloadedvirtual (C++ only.) In a derived class, the definitionsof virtual functionsmust match the type signature
of a virtual function declared in the base class. Use thisoption to request warningswhen a
derived classdeclaresa function that may be an erroneousattempt to define a virtual function;
gcc, g++
Part I: User Commands
186
that is, warn when there isa function with the same name asa virtual function in the base class,
but with a type signature that doesnt match any virtual functionsfrom the base class.
Winline Warn if a function cannot be inlined, and either it wasdeclared asinline, or else the finline
functions option wasgiven.
Werror Treat warningsaserrors; abort compilation after any warning.
DEBUGGING OPTIONS
GNU CC hasvariousspecial optionsthat are used for debugging either your program or gcc:
g Produce debugging information in the operating systemsnative format (stabs, COFF, XCOFF,
or DWARF). GDB (the GNU debugger) can work with thisdebugging information.
On most systemsthat usestabsformat, g enablesuseof extra debugging information that only GDB
can use; thisextra information makesdebugging work better in GDB but will probably make
other debuggerscrash or refuse to read the program. If you want to control for certain whether
to generate the extra information, use gstabs, gstabs, gxcoff+, gxcoff, gdwarf+, or gdwarf.
Unlike most other C compilers, GNU CC allowsyou to use g with O. The shortcutstaken by
optimized code may occasionally produce surprising results: Some variablesyou declared may
not exist at all; flow of control may briefly move where you did not expect it; some statements
may not be executed because they compute constant resultsor their valueswere already at hand;
some statementsmay execute in different placesbecause they were moved out of loops.
Nevertheless, it provespossible to debug optimized output. Thismakesit reasonable to use the
optimizer for programsthat might have bugs.
The following optionsare useful when GNU CC isgenerated with the capability for more than one debugging format.
ggdb Produce debugging information in the native format (if that issupported), including GDB
extensionsif at all possible.
gstabs Produce debugging information in stabs format (if that issupported), without GDB exten-
sions. Thisisthe format used by DBX on most BSD systems.
gstabs+ Produce debugging information in stabsformat (if that issupported), using GNU extensions
understood only by the GNU debugger (GDB). The use of these extensionsislikely to make
other debuggerscrash or refuse to read the program.
gcoff Produce debugging information in COFF format (if that issupported). Thisisthe format used
by SDB on most System V systemsprior to System V Release 4.
gxcoff Produce debugging information in XCOFF format (if that issupported). Thisisthe format
used by the DBX debugger on IBM RS/6000 systems.
gxcoff+ Produce debugging information in XCOFF format (if that issupported), using GNU
extensionsunderstood only by the GNU debugger (GDB). The use of these extensionsislikely
to make other debuggerscrash or refuse to read the program.
gdwarf Produce debugging information in DWARF format (if that issupported). Thisisthe format
used by SDB on most System V Release 4 systems.
gdwarf+ Produce debugging information in DWARF format (if that issupported), using GNU
extensionsunderstood only by the GNU debugger (GDB). The use of these extensionsislikely
to make other debuggerscrash or refuse to read the program.
glevel
ggdbl evel
gstabsl evel
gcoffl evel gxcoffl evel
gdwarfl evel Request debugging information and also use l evel to specify how much information. The
default level is2.
Level 1 producesminimal information, enough for making backtracesin partsof the program
that you dont plan to debug. Thisincludesdescriptionsof functionsand external variables, but
no information about local variablesand no line numbers.
187
Level 3 includesextra information, such asall the macro definitionspresent in the program.
Some debuggerssupport macro expansion when you use g3.
p Generate extra code to write profile information suitable for the analysisprogram prof.
pg Generate extra code to write profile information suitable for the analysisprogram gprof.
a Generate extra code to write profile information for basic blocks, which will record the number
of timeseach basic block isexecuted. Thisdata could be analyzed by a program like tcov. Note,
however, that the format of the data isnot what tcov expects. Eventually, GNU gprof should
be extended to processthisdata.
dl et t er s Saysto make debugging dumpsduring compilation at timesspecified by l et t er s. Thisisused
for debugging the compiler. The filenamesfor most of the dumpsare made by appending a
word to the source filename (for example, foo.c.rtl or foo.c.jump).
dM Dump all macro definitionsat the end of preprocessing, and write no output.
dN Dump all macro names, at the end of preprocessing.
dD Dump all macro definitionsat the end of preprocessing, in addition to normal output.
dy Dump debugging information during parsing, to standard error.
dr Dump after RTL generation, to f i l e. rtl.
dx Just generate RTL for a function instead of compiling it. Usually used with r.
dj Dump after first jump optimization, to f i l e . jump.
ds Dump after CSE (including the jump optimization that sometimesfollowsCSE), to f i l e . cse.
dL Dump after loop optimization, to f i l e . loop.
dt Dump after the second CSE pass(including the jump optimization that sometimesfollows
CSE), to f i l e . cse2.
df Dump after flow analysis, to f i l e . flow.
dc Dump after instruction combination, to f i l e . combine.
dS Dump after the first instruction scheduling pass, to f i l e . sched.
dl Dump after local register allocation, to f i l e . lreg.
dg Dump after global register allocation, to f i l e . greg.
dR Dump after the second instruction scheduling pass, to f i l e .sched2.
dJ Dump after last jump optimization, to f i l e .jump2.
dd Dump after delayed branch scheduling, to f i l e .dbr.
dk Dump after conversion from registersto stack, to f i l e .stack.
da Produce all the dumpslisted previously.
dm Print statisticson memory usage, at the end of the run, to standard error.
dp Annotate the assembler output with a comment indicating which pattern and alternative was
used.
fpretendfloat When running a cross-compiler, pretend that the target machine usesthe same floating-point
format asthe host machine. Thiscausesincorrect output of the actual floating constants, but
the actual instruction sequence will probably be the same asGNU CC would make when
running on the target machine.
savetemps Store the usual temporary intermediate filespermanently; place them in the current directory
and name them based on the source file. Thus, compiling foo.c with c savetemps would
produce filesfoo.cpp and foo.s, aswell asfoo.o.
printfilename=l i br ar y Print the full absolute name of the library file l i br ar y would be used when linking, and do not
do anything else. With thisoption, GNU CC doesnot compile or link anything; it just prints
the filename.
printlibgccfilename Same asprintfilename=libgcc.a.
printprogname=pr ogr am Like printfilename, but searchesfor a program such ascpp.
gcc, g++
Part I: User Commands
188
OPTIMIZATION OPTIONS
These optionscontrol varioussortsof optimizations:
O, O1 Optimize. Optimizing compilation takessomewhat more time, and a lot more memory for a
large function.
Without O, the compilersgoal isto reduce the cost of compilation and to make debugging
produce the expected results. Statementsare independent: If you stop the program with a
breakpoint between statements, you can then assign a new value to any variable or change the
program counter to any other statement in the function and get exactly the resultsyou would
expect from the source code.
Without O, only variablesdeclared register are allocated in registers. The resulting compiled
code isa little worse than produced by PCC without O.
With O, the compiler triesto reduce code size and execution time.
When you specify O, the two optionsfthreadjumps and fdeferpop are turned on. On
machinesthat have delay slots, the fdelayedbranch option isturned on. For those machines
that can support debugging even without a frame pointer, the fomitframepointer option is
turned on. On some machinesother flagsmay also be turned on.
O2 Optimize even more. Nearly all supported optimizationsthat do not involve a space-speed
tradeoff are performed. Loop unrolling and function inlining are not done, for example. As
compared to O, thisoption increasesboth compilation time and the performance of the
generated code.
O3 Optimize yet more. Thisturnson everything O2 does, along with also turning on finline
functions.
O0 Do not optimize.
If you use multiple O options, with or without level numbers, the last such option isthe one
that iseffective.
Optionsof the form f f l ag specify machine-independent flags. Most flagshave both positive and negative forms; the
negative form of ffoo would be fnofoo. The following list showsonly one formthe one which isnot the default. You
can figure out the other form by either removing no or adding it.
ffloatstore Do not store floating-point variablesin registers. Thispreventsundesirable excessprecision on
machinessuch asthe 68000 where the floating registers(of the 68881) keep more precision
than a double issupposed to have.
For most programs, the excessprecision doesonly good, but a few programsrely on the precise
definition of IEEE floating point. Use ffloatstore for such programs.
fmemorizelookups Use heuristicsto compile faster (C++ only). These heuristicsare not enabled by default,
fsavememorized since they are only effective for certain input files. Other input filescompile more slowly.
The first time the compiler must build a call to a member function (or reference to a data
member), it must (1) determine whether the classimplementsmember functionsof that name;
(2) resolve which member function to call (which involvesfiguring out what sortsof type
conversionsneed to be made); and (3) check the visibility of the member function to the caller.
All of thisaddsup to slower compilation. Normally, the second time a call ismade to that
member function (or reference to that data member), it must go through the same lengthy
processagain. Thismeansthat code like this:
cout << This << p << has<< \ << legs.\n
makessix passesthrough all three steps. By using a software cache, a hit significantly reduces
thiscost. Unfortunately, using the cache introducesanother layer of mechanismswhich must
be implemented, and so incursitsown overhead. fmemorize lookups enablesthe software
cache.
Because accessprivileges(visibility) to membersand member functionsmay differ from one
function context to the next, g++ may need to flush the cache. With the fmemorizelookups
flag, the cache isflushed after every function that iscompiled. The fsavememorized flag
189
enablesthe same software cache, but when the compiler determinesthat the context of the last
function compiled would yield the same accessprivilegesof the next function to compile, it
preservesthe cache. Thisismost helpful when defining many member functionsfor the same
class: with the exception of member functionswhich are friendsof other classes, each member
function hasexactly the same accessprivilegesasevery other, and the cache need not be flushed.
fnodefaultinline Dont make member functionsinline by default merely because they are defined inside the class
scope (C++ only).
fnodeferpop Alwayspop the argumentsto each function call assoon asthat function returns. For machines
which must pop argumentsafter a function call, the compiler normally letsarguments
accumulate on the stack for several function callsand popsthem all at once.
fforcemem Force memory operandsto be copied into registersbefore doing arithmetic on them. Thismay
produce better code by making all memory referencespotential common subexpressions. When
they are not common subexpressions, instruction combination should eliminate the separate
register-load. I am interested in hearing about the difference thismakes.
fforceaddr Force memory addressconstantsto be copied into registersbefore doing arithmetic on them.
Thismay produce better code just asfforcemem may. I am interested in hearing about the
difference thismakes.
fomitframepointer Dont keep the frame pointer in a register for functionsthat dont need one. Thisavoidsthe
instructionsto save, set up and restore frame pointers; it also makesan extra register available in
many functions. It also makesdebugging impossible on most machines.
On some machines, such asthe VAX, thisflag hasno effect because the standard calling
sequence automatically handlesthe frame pointer and nothing issaved by pretending it doesnt
exist. The machine-description macro FRAME_POINTER_REQUIRED controlswhether a target
machine supportsthisflag.
finlinefunctions Integrate all simple functionsinto their callers. The compiler heuristically decideswhich
functionsare simple enough to be worth integrating in thisway.
If all callsto a given function are integrated, and the function isdeclared static, then gcc
normally doesnot output the function asassembler code in itsown right.
fcallersaves Enable valuesto be allocated in registersthat will be clobbered by function calls, by emitting
extra instructionsto save and restore the registersaround such calls. Such allocation isdone
only when it seemsto result in better code than would otherwise be produced.
Thisoption isenabled by default on certain machines, usually those which have no call-
preserved registersto use instead.
fkeepinlinefunctions Even if all callsto a given function are integrated, and the function isdeclared static,
neverthelessoutput a separate runtime callable version of the function.
fnofunctioncse Do not put function addressesin registers; make each instruction that callsa constant function
contain the functionsaddressexplicitly.
Thisoption resultsin lessefficient code, but some strange hacksthat alter the assembler output
may be confused by the optimizationsperformed when thisoption isnot used.
fnopeephole Disable any machine-specific peephole optimizations.
ffast-math Thisoption allowsgcc to violate some ANSI or IEEE specificationsin the interest of optimiz-
ing code for speed. For example, it allowsthe compiler to assume argumentsto the sqrt
function are nonnegative numbers.
Thisoption should never be turned on by any O option because it can result in incorrect
output for programswhich depend on an exact implementation of IEEE or ANSI rules/
specificationsfor math functions.
The following optionscontrol specific optimizations. The O2 option turnson all of these optimizationsexcept funroll
loops and funrollallloops.
The O option usually turnson the fthreadjumps and fdelayedbranch options, but specific machinesmay change the
default optimizations.
gcc, g++
Part I: User Commands
190
You can use the following flagsin the rare caseswhen fine-tuning of optimizationsto be performed isdesired:
fstrengthreduce Perform the optimizationsof loop strength reduction and elimination of iteration variables.
fthreadjumps Perform optimizationswhere we check to see if a jump branchesto a location where another
comparison subsumed by the first isfound. If so, the first branch isredirected to either the
destination of the second branch or a point immediately following it, depending on whether
the condition isknown to be true or false.
funrollloops Perform the optimization of loop unrolling. Thisisonly done for loopswhose number of
iterationscan be determined at compile time or runtime.
funrollallloops Perform the optimization of loop unrolling. Thisisdone for all loops. Thisusually makes
programsrun more slowly.
fcsefollowjumps In common subexpression elimination, scan through jump instructionswhen the target of the
jump isnot reached by any other path. For example, when CSE encountersan if statement
with an else clause, CSE will follow the jump when the condition tested isfalse.
fcseskipblocks Thisissimilar to fcsefollowjumps, but causesCSE to follow jumpswhich conditionally skip
over blocks. When CSE encountersa simple if statement with no else clause, fcseskip
blocks causesCSE to follow the jump around the body of the if.
freruncseafterloop Rerun common subexpression elimination after loop optimizationshasbeen performed.
felideconstructors Elide constructorswhen thisseemsplausible (C++ only). With thisflag, GNU C++ initializesy
directly from the call to foo without going through a temporary in the following code:
A foo (); A y = foo ( );
Without thisoption, GNU C++ first initializesy by calling the appropriate constructor for type
A; then assignsthe result of foo to a temporary; and, finally, replacesthe initial value of y with
the temporary.
The default behavior (fnoelideconstructors) isspecified by the draft ANSI C++ standard. If
your programsconstructorshave side effects, using felide-constructors can make your
program act differently, since some constructor callsmay be omitted.
fexpensiveoptimizations Perform a number of minor optimizationsthat are relatively expensive.
fdelayedbranch If supported for the target machine, attempt to reorder instructionsto exploit instruction slots
available after delayed branch instructions.
fscheduleinsns If supported for the target machine, attempt to reorder instructionsto eliminate execution stalls
due to required data being unavailable. Thishelpsmachinesthat have slow floating point or
memory load instructionsby allowing other instructionsto be issued until the result of the load
or floating point instruction isrequired.
fscheduleinsns2 Similar to fscheduleinsns, but requestsan additional passof instruction scheduling after
register allocation hasbeen done. Thisisespecially useful on machineswith a relatively small
number of registersand where memory load instructionstake more than one cycle.
TARGET OPTIONS
By default, GNU CC compilescode for the same type of machine that you are using.
However, it can also be installed asa cross-compiler, to compile for some other type of machine. In fact, several different
configurationsof GNU CC, for different target machines, can be installed side by side. Then you specify which one to use
with the b option.
In addition, older and newer versionsof GNU CC can be installed side by side. One of them (probably the newest) will be
the default, but you may sometimeswant to use another.
b machi ne The argument machi ne specifiesthe target machine for compilation. Thisisuseful when you
have installed GNU CC asa cross-compiler.
The value to use for machi ne isthe same aswasspecified asthe machine type when configuring
GNU CC asa cross-compiler. For example, if a cross-compiler wasconfigured with configure
191
i386v, meaning to compile for an 80386 running System V, then you would specify b i386v to
run that crosscompiler.
When you do not specify b, it normally meansto compile for the same type of machine that
you are using.
V ver si on The argument ver si on specifieswhich version of GNU CC to run. Thisisuseful when multiple
versionsare installed. For example, ver si on might be 2.0, meaning to run GNU CC version
2.0.
The default version, when you do not specify V, iscontrolled by the way GNU CC isinstalled.
Normally, it will be a version that isrecommended for general use.
MACHINE-DEPENDENT OPTIONS
Each of the target machine typescan have itsown special options, starting with m, to choose among varioushardware
modelsor configurationsfor example, 68010 versus68020, floating coprocessor or none. A single installed version of the
compiler can compile for any model or configuration, according to the optionsspecified.
Some configurationsof the compiler also support additional special options, usually for command-line compatibility with
other compilerson the same platform.
These are the m optionsdefined for the 68000 series:
m68000 Generate output for a 68000. Thisisthe default when the compiler isconfigured for 68000-
mc68000 based systems.
m68020 Generate output for a 68020 (rather than a 68000). Thisisthe default when the compiler is
mc68020 configured for 68020-based systems.
m68881 Generate output containing 68881 instructionsfor floating point. Thisisthe default for most
68020-based systemsunlessnfp wasspecified when the compiler wasconfigured.
m68030 Generate output for a 68030. Thisisthe default when the compiler isconfigured for 68030-
based systems.
m68040 Generate output for a 68040. Thisisthe default when the compiler isconfigured for 68040-
based systems.
m6802040 Generate output for a 68040, without using any of the new instructions. Thisresultsin code
which can run relatively efficiently on either a 68020/68881 or a 68030 or a 68040.
mfpa Generate output containing Sun FPA instructionsfor floating point.
msoftfloat Generate output containing library callsfor floating point.
WARNING
The requisite librariesare not part of GNU CC. Normally, the facilitiesof the machinesusual C compiler are used, but
thiscant be done directly in cross-compilation. You must make your own arrangementsto provide suitable library func-
tionsfor cross-compilation.
mshort Consider type int to be 16 bitswide, like short int.
mnobitfield Do not use the bit-field instructions. m68000 impliesmnobitfield.
mbitfield Do use the bit-field instructions. m68020 impliesmbitfield. Thisisthe default if you use the
unmodified sources.
mrtd Use a different function-calling convention, in which functionsthat take a fixed number of
argumentsreturn with the rtd instruction, which popstheir argumentswhile returning. This
savesone instruction in the caller since there isno need to pop the argumentsthere.
Thiscalling convention isincompatible with the one normally used on UNIX, so you cannot
use it if you need to call librariescompiled with the UNIX compiler.
gcc, g++
Part I: User Commands
192
Also, you must provide function prototypesfor all functionsthat take variable numbersof
arguments(including printf ); otherwise, incorrect code will be generated for callsto those
functions.
In addition, seriously incorrect code will result if you call a function with too many arguments.
(Normally, extra argumentsare harmlessly ignored.)
The rtd instruction issupported by the 68010 and 68020 processors, but not by the 68000.
These m optionsare defined for the VAX:
munix Do not output certain jump instructions(aobleq and so on) that the UNIX assembler for the
VAX cannot handle acrosslong ranges.
mgnu Do output those jump instructions, on the assumption that you will assemble with the GNU
assembler.
mg Output code for g-format floating-point numbersinstead of d-format.
These m switchesare supported on the SPARC:
mfpu Generate output containing floating-point instructions. Thisisthe default.
mhardfloat
mnofpu Generate output containing library callsfor floating point.
msoftfloat
WARNING
There isno GNU floating-point library for SPARC. Normally, the facilitiesof the machinesusual C compiler are used,
but thiscannot be done directly in cross-compilation. You must make your own arrangementsto provide suitable library
functionsfor cross-compilation.
msoftfloat Changesthe calling convention in the output file; therefore, it isonly useful if you compile all
of a program with thisoption.
mnoepilogue With mepilogue (the default), the compiler alwaysemitscode for function exit at the end of
mepilogue each function. Any function exit in the middle of the function (such asa return statement in C)
will generate a jump to the exit code at the end of the function. With mnoepilogue, the
compiler triesto emit exit code inline at every function exit.
mnov8 These three optionsselect variationson the SPARC architecture. By default (unlessspecifically
mv8 configured for the Fujitsu SPARClite), gcc generatescode for the v7 variant of the SPARC
msparclite architecture.
mv8 will give you SPARC v8 code. The only difference from v7 code isthat the compiler emits
the integer multiply and integer divide instructionsthat exist in SPARC v8 but not in SPARC v7.
msparclite will give you SPARClite code. Thisaddsthe integer multiply, integer divide step
and scan (ffs) instructionsthat exist in SPARClite but not in SPARC v7.
mcypress These two optionsselect the processor for which the code isoptimized.
msupersparc With mcypress (the default), the compiler optimizescode for the CypressCY7C602 chip, as
used in the SparcStation and SparcServer 3xx series. Thisisalso appropriate for the older
SparcStation 1, 2, IPX, and so on.
With msupersparc the compiler optimizescode for the SuperSparc cpu, asused in the
SparcStation 10, 1000, and 2000 series. Thisflag also enablesuse of the full SPARC v8
instruction set.
These m optionsare defined for the Convex:
mc1 Generate output for a C1. Thisisthe default when the compiler isconfigured for a C1.
mc2 Generate output for a C2. Thisisthe default when the compiler isconfigured for a C2.
193
margcount Generate code which putsan argument count in the word preceding each argument list. Some
nonportable Convex and VAX programsneed thisword. (Debuggersdont, except for
functionswith variable-length argument lists; thisinformation isin the symbol table.)
mnoargcount Omit the argument count word. Thisisthe default if you use the unmodified sources.
These m optionsare defined for the AMD Am29000:
mdw Generate code that assumesthe DW bit isset, that is, that byte and half-word operationsare
directly supported by the hardware. Thisisthe default.
mnodw Generate code that assumesthe DW bit isnot set.
mbw Generate code that assumesthe system supportsbyte and halfword write operations. Thisisthe
default.
mnbw Generate code that assumesthe systemsdoesnot support byte and halfword write operations.
Thisimpliesmnodw.
msmall Use a small memory model that assumesthat all function addressesare either within a single
256KB segment or at an absolute addressof lessthan 256K. Thisallowsthe call instruction to
be used instead of a const, consth, calli sequence.
mlarge Do not assume that the call instruction can be used; thisisthe default.
m29050 Generate code for the Am29050.
m29000 Generate code for the Am29000. Thisisthe default.
mkernelregisters Generate referencesto registersgr64gr95 instead of gr96gr127. Thisoption can be used when
compiling kernel code that wantsa set of global registersdisjoint from that used by user-mode
code.
Note that when thisoption isused, register namesin f flagsmust use the normal, user-mode,
names.
muserregisters Use the normal set of global registers, gr96gr127. Thisisthe default.
mstackcheck Insert a call to msp check after each stack adjustment. Thisisoften used for kernel code.
These m optionsare defined for Motorola 88K architectures:
m88000 Generate code that workswell on both the m88100 and the m88110.
m88100 Generate code that worksbest for the m88100, but that also runson the m88110.
m88110 Generate code that worksbest for the m88110, and may not run on the m88100.
midentifyrevision Include an ident directive in the assembler output recording the source filename, compiler
name and version, timestamp, and compilation flagsused.
mnounderscores In assembler output, emit symbol nameswithout adding an underscore character at the
beginning of each name. The default isto use an underscore asprefix on each name.
mcheckzerodivision Early modelsof the 88K architecture had problemswith division by zero; in particular, many of
mnocheckzerodivision them didnt trap. Use these optionsto avoid including (or to include explicitly) additional code
to detect division by zero and signal an exception. All gcc configurationsfor the 88K use
mcheckzerodivision by default.
mocsdebuginfo Include (or omit) additional debugging information (about registersused in each stack frame)
mnoocsdebuginfo asspecified in the 88Open Object Compatibility Standard, OCS. Thisextra information isnot
needed by GDB. The default for DG/UX, SVr4, and Delta 88 SVr3.2 isto include this
information; other 88K configurationsomit thisinformation by default.
mocsframeposition Force (or do not require) register valuesto be stored in a particular place in stack frames, as
mnoocsframeposition specified in OCS. The DG/UX, Delta88 SVr3.2, and BCS configurationsuse mocsframe
position; other 88K configurationshave the default mnoocs frameposition.
moptimizeargarea Control how to store function argumentsin stack frames. moptimizeargarea savesspace, but
mnooptimizeargarea may break some debuggers(not GDB). mnooptimizeargarea conformsbetter to standards.
By default gcc doesnot optimize the argument area.
gcc, g++
Part I: User Commands
194
mshortdatanum Generate smaller data referencesby making them relative to r0, which allowsloading a value
using a single instruction (rather than the usual two). You control which data referencesare
affected by specifying num with thisoption. For example, if you specify mshortdata512,
then the data referencesaffected are those involving displacementsof lessthan 512 bytes.
mshortdata-num isnot effective for num greater than 64K.
mserialize-volatile Do, or do not, generate code to guarantee sequential consistency of volatile memory references.
mno-serialize-volatile GNU CC alwaysguaranteesconsistency by default, for the preferred processor submodel. How
thisisdone dependson the submodel.
The m88100 processor doesnot reorder memory referencesand so alwaysprovidessequential
consistency. If you use m88100, GNU CC doesnot generate any special instructionsfor
sequential consistency.
The order of memory referencesmade by the m88110 processor doesnot alwaysmatch the
order of the instructionsrequesting those references. In particular, a load instruction may
execute before a preceding store instruction. Such reordering violatessequential consistency of
volatile memory references, when there are multiple processors. When you use m88000 or
m88110, GNU CC generatesspecial instructionswhen appropriate, to force execution in the
proper order.
The extra code generated to guarantee consistency may affect the performance of your
application. If you know that you can safely forgo thisguarantee, you may use the option
mno-serialize-volatile.
If you use the m88100 option but require sequential consistency when running on the m88110
processor, you should use mserialize-volatile.
msvr4, msvr3 Turn on (msvr4) or off (msvr3) compiler extensionsrelated to System V release 4 (SVr4). This
controlsthe following:
Which variant of the assembler syntax to emit (which you can select independently using
mversion03.00).
msvr4 makesthe C preprocessor recognize #pragma weak.
msvr4 makesgcc issue additional declaration directivesused in SVr4.
msvr3 isthe default for all m88K configurationsexcept the SVr4 configuration.
mtraplargeshift Include code to detect bit-shiftsof more than 31 bits; respectively, trap such shiftsor emit code
mhandlelargeshift to handle them properly. By default, gcc makesno special provision for large bit shifts.
musedivinstruction Very early modelsof the 88K architecture didnt have a divide instruction, so gcc avoidsthat
instruction by default. Use thisoption to specify that itssafe to use the divide instruction.
mversion03.00 In the DG/UX configuration, there are two flavorsof SVr4. Thisoption modifiesmsvr4 to
select whether the hybrid-COFF or real-ELF flavor isused. All other configurationsignore this
option.
mwarnpassedstructs Warn when a function passesa struct asan argument or result. Structure-passing conventions
have changed during the evolution of the C language, and are often the source of portability
problems. By default, gcc issuesno such warning.
These optionsare defined for the IBM RS6000:
mfpintoc Control whether or not floating-point constantsgo in the table of contents(TOC), a table of
mnofpintoc all global variable and function addresses. By default gcc putsfloating-point constantsthere; if
the TOC overflows, mnofpintoc will reduce the size of the TOC, which may avoid the
overflow.
These m optionsare defined for the IBM RT PC:
minlinemul Use an inline code sequence for integer multiplies. Thisisthe default.
mcalllibmul Call lmul$$ for integer multiples.
mfullfpblocks Generate full-size floating-point data blocks, including the minimum amount of scratch space
recommended by IBM. Thisisthe default.
195
mminimumfpblocks Do not include extra scratch space in floating-point data blocks. Thisresultsin smaller code,
but slower execution, since scratch space must be allocated dynamically.
mfparginfpregs Use a calling sequence incompatible with the IBM calling convention in which floating-point
argumentsare passed in floating-point registers. Note that varargs.h and stdargs.h will not
work with floating-point operandsif thisoption isspecified.
mfpargingregs Use the normal calling convention for floating-point arguments. Thisisthe default.
mhcstructreturn Return structuresof more than one word in memory, rather than in a register. Thisprovides
compatibility with the MetaWare HighC (hc) compiler. Use fpccstructreturn for compat-
ibility with the Portable C Compiler (PCC).
mnohcstructreturn Return some structuresof more than one word in registers, when convenient. Thisisthe
default. For compatibility with the IBM-supplied compilers, use either fpccstructreturn or
mhcstructreturn.
These m optionsare defined for the MIPS family of computers:
mcpu=cpu- t ype Assume the defaultsfor the machine type cpu- t ype when scheduling instructions. The default
cpu- t ype isdefault, which picksthe longest cyclestimesfor any of the machines, in order that
the code run at reasonable rateson all MIPS CPUs. Other choicesfor cpu- t ype are r2000, r3000,
r4000,and r6000. While picking a specific cpu- t ype will schedule thingsappropriately for that
particular chip, the compiler will not generate any code that doesnot meet level 1 of the MIPS
ISA (instruction set architecture) with-out the mips2 or mips3 switchesbeing used.
mips2 Issue instructionsfrom level 2 of the MIPS ISA (branch likely, square root instructions).
The mcpu=r4000 or mcpu=r6000 switch must be used in conjunction with mips2.
mips3 Issue instructionsfrom level 3 of the MIPS ISA (64-bit instructions). The mcpu=r4000 switch
must be used in conjunction with mips2.
mint64, mlong64 These optionsdont work at present.
mlonglong128
mmipsas Generate code for the MIPSassembler, and invoke mipstfile to add normal debug informa-
tion. Thisisthe default for all platformsexcept for the OSF/1 reference platform, using the
OSF/rose object format. If any of the ggdb, gstabs, or gstabs+ switchesare used, the mips
tfile program will encapsulate the stabswithin MIPS ECOFF.
mgas Generate code for the GNU assembler. Thisisthe default on the OSF/1 reference platform,
using the OSF/rose object format.
mrnames, mnornames The mrnames switch saysto output code using the MIPSsoftware namesfor the registers,
instead of the hardware names(for example, a0 instead of $4). The GNU assembler doesnot
support the mrnames switch, and the MIPS assembler will be instructed to run the MIPSC
preprocessor over the source file. The mnornames switch isdefault.
mgpopt, mnogpopt The mgpopt switch saysto write all of the data declarationsbefore the instructionsin the text
section, to all the MIPS assembler to generate one-word memory referencesinstead of using
two wordsfor short global or static data items. Thisison by default if optimization isselected.
mstats, mnostats For each noninline function processed, the mstats switch causesthe compiler to emit one line
to the standard error file to print statisticsabout the program (number of registerssaved, stack
size, and so on).
mmemcpy, mnomemcpy The mmemcpy switch makesall block movescall the appropriate string function (memcpy or
bcopy) instead of possibly generating inline code.
mmipstfile The mnomipstfile switch causesthe compiler to not post-processthe object file with the
mnomipstfile mipstfile program, after the MIPS assembler hasgenerated it to add debug support. If mips
tfile isnot run, then no local variableswill be available to the debugger. In addition, stage2
and stage3 objectswill have the temporary filenamespassed to the assembler embedded in the
object file, which meansthe objectswill not compare the same.
msoftfloat Generate output containing library callsfor floating point.
gcc, g++
Part I: User Commands
196
WARNING
The requisite librariesare not part of GNU CC. Normally, the facilitiesof the machinesusual C compiler are used, but
thiscant be done directly in cross-compilation. You must make your own arrangementsto provide suitable library func-
tionsfor cross-compilation.
mhardfloat Generate output containing floating point instructions. Thisisthe default if you use the
unmodified sources.
mfp64 Assume that the FR bit in the statusword ison, and that there are 32 64-bit floating-point
registers, instead of 32 32-bit floating-point registers. You must also specify the mcpu=r4000 and
mips3 switches.
mfp32 Assume that there are 32 32-bit floating-point registers. Thisisthe default.
mabicalls Emit (or do not emit) the .abicalls, .cpload, and .cprestore pseudo operationsthat some
mnoabicalls System V.4 portsuse for position-independent code.
mhalfpic The mhalfpic switch saysto put pointersto extern referencesinto the data section and load
mnohalfpic them up, rather than put the referencesin the text section. Thisoption doesnot work at
present.
Gnum Put global and static itemslessthan or equal to num bytesinto the small data or bss sections
instead of the normal data or bss section. Thisallowsthe assembler to emit one-word memory
reference instructionsbased on the global pointer (gp or $28), instead of the normal two words
used. By default, num is8 when the MIPS assembler isused, and 0 when the GNU assembler is
used. The Gnum switch isalso passed to the assembler and linker. All modulesshould be
compiled with the same Gnum value.
nocpp Tell the MIPS assembler to not run itspreprocessor over user assembler files(with an .s suffix)
when assembling them.
These m optionsare defined for the Intel 80386 family of computers:
m486, mno486 Control whether or not code isoptimized for a 486 instead of a 386. Code generated for a 486
will run on a 386 and vice versa.
msoftfloat Generate output containing library callsfor floating point.
WARNING
The requisite librariesare not part of GNU CC. Normally, the facilitiesof the machinesusual C compiler are used, but
thiscant be done directly in cross-compilation. You must make your own arrangementsto provide suitable library func-
tionsfor cross-compilation.
On machineswhere a function returnsfloating point resultsin the 80387 register stack, some
floating-point opcodesmay be emitted even if msoft-float isused.
mno-fp-ret-in-387 Do not use the FPU registersfor return valuesof functions.
The usual calling convention hasfunctionsreturn valuesof typesfloat and double in an FPU
register, even if there isno FPU. The idea isthat the operating system should emulate an FPU.
The option mno-fp-ret-in-387 causessuch valuesto be returned in ordinary CPU registers
instead.
These m optionsare defined for the HPPA family of computers:
mpa-risc-1-0 Generate code for a PA 1.0 processor.
mpa-risc-1-1 Generate code for a PA 1.1 processor.
197
mkernel Generate code which issuitable for use in kernels. Specifically, avoid add instructionsin which
one of the argumentsisthe DP register; generate addil instructionsinstead. Thisavoidsa rather
seriousbug in the HP-UX linker.
mshared-libs Generate code that can be linked against HP-UX shared libraries. Thisoption isnot fully
functioning yet, and isnot on by default for any PA target. Using thisoption can cause
incorrect code to be generated by the compiler.
mno-shared-libs Dont generate code that will be linked against shared libraries. Thisisthe default for all PA
targets.
mlong-calls Generate code which allowscallsto functionsgreater than 256K away from the caller when the
caller and callee are in the same source file. Do not turn thisoption on unlesscode refusesto
link with branch out of range errorsfrom the linker.
mdisable-fpregs Prevent floating-point registersfrom being used in any manner. Thisisnecessary for compiling
kernelsthat perform lazy context switching of floating-point registers. If you use thisoption
and attempt to perform floating-point operations, the compiler will abort.
mdisable-indexing Prevent the compiler from using indexing addressmodes. Thisavoidssome rather obscure
problemswhen compiling MIG-generated code under MACH.
mtrailing-colon Add a colon to the end of label definitions(for ELF assemblers).
These m optionsare defined for the Intel 80960 family of computers:
mcpu- t ype Assume the defaultsfor the machine type cpu- t ype for instruction and addressing-mode
availability and alignment. The default cpu- t ype iskb; other choicesare ka, mc, ca, cf, sa, and sb.
mnumerics The mnumerics option indicatesthat the processor doessupport floating-point instructions.
msoftfloat The msoftfloat option indicatesthat floating-point support should not be assumed.
mleafprocedures Do (or do not) attempt to alter leaf proceduresto be callable with the bal instruction aswell as
mnoleafprocedures cal l . Thiswill result in more efficient code for explicit callswhen the bal instruction can be
substituted by the assembler or linker, but lessefficient code in other cases, such ascallsvia
function pointers, or using a linker that doesnt support thisoptimization.
mtailcall Do (or do not) make additional attempts(beyond those of the machine-independent portions
mnotailcall of the compiler) to optimize tail-recursive callsinto branches. You may not want to do this
because the detection of caseswhere thisisnot valid isnot totally complete. The default is
mnotailcall.
mcomplexaddr Assume (or do not assume) that the use of a complex addressing mode isa win on thisimple-
mnocomplexaddr mentation of the i960. Complex addressing modesmay not be worthwhile on the K-series, but
they definitely are on the C-series. The default iscurrently mcomplexaddr for all processors
except the CB and CC.
mcodealign Align code to 8-byte boundariesfor faster fetching (or dont bother). Currently turned on by
mnocodealign default for C-seriesimplementationsonly.
miccompat Enable compatibility with iC960 v2.0 or v3.0.
mic2.0compat
mic3.0compat
masmcompat Enable compatibility with the iC960 assembler.
mintelasm
mstrictalign Do not permit (do permit) unaligned accesses.
mnostrictalign
moldalign Enable structure-alignment compatibility with Intelsgcc release version 1.3 (based on gcc
1.37). Currently thisisbuggy in that #pragma align 1 isalwaysassumed aswell, and cannot be
turned off.
gcc, g++
Part I: User Commands
198
These m optionsare defined for the DEC Alpha implementations:
mno-soft-float Use (do not use) the hardware floating-point instructionsfor floating-point operations. When
msoft-float msoft-float isspecified, functionsin libgcc1.c will be used to perform floating-point
operations. Unlessthey are replaced by routinesthat emulate the floating-point operations, or
compiled in such a way asto call such emulationsroutines, these routineswill issue floating-
point operations. If you are compiling for an Alpha without floating-point operations, you
must ensure that the library isbuilt so asnot to call them.
Note that Alpha implementationswithout floating-point operationsare required to have
floating-point registers.
mfp-reg, mno-fp-regs Generate code that uses(doesnot use) the floating-point register set. mno-fp-regs implies
msoft-float. If the floating-point register set isnot used, floating-point operandsare passed in
integer registersasif they were integersand floating-point resultsare passed in $0 instead of $f0.
Thisisa nonstandard calling sequence, so any function with a floating-point argument or
return value called by code compiled with mno-fp-regs must also be compiled with that
option.
A typical use of thisoption isbuilding a kernel that doesnot use, and hence need not save and
restore, any floating-point registers.
These additional optionsare available on System V Release 4 for compatibility with other compilerson those systems:
G On SVr4 systems, gcc acceptsthe option G (and passesit to the system linker), for compatibil-
ity with other compilers. However, we suggest you use symbolic or shared asappropriate,
instead of supplying linker optionson the gcc command line.
Qy Identify the versionsof each tool used by the compiler, in an .ident assembler directive in the
output.
Qn Refrain from adding .ident directivesto the output file (thisisthe default).
YP,di r s Search the directoriesdi r s, and no others, for librariesspecified with l. You can separate
directory entriesin di r s from one another with colons.
Ym,di r Look in the directory di r to find the M4 preprocessor. The assembler usesthisoption.
CODE GENERATION OPTIONS
These machine-independent optionscontrol the interface conventionsused in code generation.
Most of them begin with f. These optionshave both positive and negative forms; the negative form of ffoo would be fno
foo. In the following table, only one of the formsislistedthe one which isnot the default. You can figure out the other
form by either removing no or adding it.
fnonnullobjects Assume that objectsreached through referencesare not null (C++ only).
Normally, GNU C++ makesconservative assumptionsabout objectsreached through
references. For example, the compiler must check that a isnot null in code like the following:
obj &a = g (); a.f (2);
Checking that referencesof thissort have nonnull valuesrequiresextra code, however, and it is
unnecessary for many programs. You can use fnonnull-objects to omit the checksfor null, if
your program doesnt require checking.
fpccstructreturn Use the same convention for returning struct and union valuesthat isused by the usual C
compiler on your system. Thisconvention islessefficient for small structures, and on many
machinesit failsto be reentrant; but it hasthe advantage of allowing intercallability between
gcc-compiled code and pcc-compiled code.
fregstructreturn Use the convention that struct and union valuesare returned in registerswhen possible. Thisis
more efficient for small structuresthan fpccstructreturn.
If you specify neither fpccstructreturn nor fregstructreturn, GNU CC defaultsto
whichever convention isstandard for the target. If there isno standard convention, GNU CC
defaultsto fpccstructreturn.
199
fshortenums Allocate to an enum type only asmany bytesasit needsfor the declared range of possible values.
Specifically, the enum type will be equivalent to the smallest integer type that hasenough room.
fshortdouble Use the same size for double asfor float.
fshareddata Requeststhat the data and non-const variablesof thiscompilation be shared data rather than
private data. The distinction makessense only on certain operating systems, where shared data
isshared between processesrunning the same program, while private data existsin one copy per
process.
fnocommon Allocate even uninitialized global variablesin the bss section of the object file, rather than
generating them ascommon blocks. Thishasthe effect that if the same variable isdeclared
(without extern) in two different compilations, you will get an error when you link them. The
only reason thismight be useful isif you want to verify that the program will work on other
systemswhich alwayswork thisway.
fnoident Ignore the #ident directive.
fnognulinker Do not output global initializations(such asC++ constructorsand destructors) in the form
used by the GNU linker (on systemswhere the GNU linker isthe standard method of handling
them). Use thisoption when you want to use a non-GNU linker, which also requiresusing the
collect2 program to make sure the system linker includesconstructorsand destructors.
(collect2 isincluded in the GNU CC distribution.) For systemsthat must use collect2, the
compiler driver gcc isconfigured to do thisautomatically.
finhibit-size-directive Dont output a .size assembler directive, or anything else that would cause trouble if the
function issplit in the middle, and the two halvesare placed at locationsfar apart in memory.
Thisoption isused when compiling crtstuff.c; you should not need to use it for anything else.
fverbose-asm Put extra commentary information in the generated assembly code to make it more readable.
Thisoption isgenerally only of use to those who actually need to read the generated assembly
code (perhapswhile debugging the compiler itself).
fvolatile Consider all memory referencesthrough pointersto be volatile.
fvolatileglobal Consider all memory referencesto extern and global data itemsto be volatile.
fpic If supported for the target machines, generate position-independent code, suitable for use in a
shared library.
fPIC If supported for the target machine, emit position-independent code, suitable for dynamic
linking, even if branchesneed large displacements.
ffixedr eg Treat the register named r eg asa fixed register; generated code should never refer to it (except
perhapsasa stack pointer, frame pointer, or in some other fixed role).
r eg must be the name of a register. The register namesaccepted are machine-specific and are
defined in the REGISTER_NAMES macro in the machine description macro file.
Thisflag doesnot have a negative form, because it specifiesa three-way choice.
fcallusedr eg Treat the register named r eg asan allocable register that isclobbered by function calls. It may
be allocated for temporariesor variablesthat do not live acrossa call. Functionscompiled this
way will not save and restore the register r eg.
Use of thisflag for a register that hasa fixed pervasive role in the machinesexecution model,
such asthe stack pointer or frame pointer, will produce disastrousresults.
Thisflag doesnot have a negative form, because it specifiesa three-way choice.
fcallsavedr eg Treat the register named r eg asan allocable register saved by functions. It may be allocated even
for temporariesor variablesthat live acrossa call. Functionscompiled thisway will save and
restore the register r eg if they use it.
Use of thisflag for a register that hasa fixed pervasive role in the machinesexecution model,
such asthe stack pointer or frame pointer, will produce disastrousresults.
A different sort of disaster will result from the use of thisflag for a register in which function
valuesmay be returned.
Thisflag doesnot have a negative form, because it specifiesa three-way choice.
gcc, g++
Part I: User Commands
200
PRAGMAS
Two #pragma directivesare supported for GNU C++ to permit using the same header file for two purposes: asa definition of
interfacesto a given object class, and asthe full definition of the contentsof that object class.
#pragma interface (C++ only.) Use thisdirective in header filesthat define object classes, to save space in most of
the object filesthat use those classes. Normally, local copiesof certain information (backup
copiesof inline member functions, debugging information, and the internal tablesthat
implement virtual functions) must be kept in each object file that includesclassdefinitions. You
can use thispragma to avoid such duplication. When a header file containing #pragma
interface isincluded in a compilation, thisauxiliary information will not be generated (unless
the main input source file itself uses#pragma implementation). Instead, the object fileswill
contain referencesto be resolved at link time.
#pragma implementation (C++ only.) Use thispragma in a main input file, when you want full output from included
#pragma implementation header filesto be generated (and made globally visible). The included header file, in turn,
obj ect s .h should use #pragma interface. Backup copiesof inline member functions, debugging informa-
tion, and the internal tablesused to implement virtual functionsare all generated in implemen-
tation files.
If you use #pragma implementation with no argument, it appliesto an include file with the same
basename asyour source file; for example, in allclass.cc, #pragma implementation by itself is
equivalent to #pragma i-plementation allclass.h. Use the string argument if you want a
single implementation file to include code from multiple header files.
There isno way to split up the contentsof a single header file into multiple implementation
files.
FILES
file.c C source file
file.h C header (preprocessor) file
file.i Preprocessed C source file
file.C C++ source file
file.cc C++ source file
file.cxx C++ source file
file.m Objective-C source file
file.s Assembly language file
file.o Object file
a.out Link edited output
TMPDI R/cc Temporary files
LI BDI R/cpp Preprocessor
LI BDI R/cc1 Compiler for C
LI BDI R/cc1plus Compiler for C++
LI BDI R/collect Linker front end needed on some machines
LI BDI R/libgcc.a gcc subroutine library
/lib/crt[01n].o Startup routine
LI BDI R/ccrt0 Additional startup routine for C++
/lib/libc.a Standard C library; see intro(3)
/usr/include Standard directory for #include files
LI BDI R/include Standard gcc directory for #include files
LI BDI R/g++include Additional g++ directory for #include
LI BDI R isusually /usr/local/lib/machi ne/ver si on.
TMPDI R comesfrom the environment variable TMPDIR (default /usr/tmp if available; otherwise, /tmp.).
201
SEE ALSO
cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
gcc, cpp, as, ld, and gdb entriesin info.
Usingand PortingGNU CC (for version 2.0), Richard M. Stallman; TheC Preprocessor, Richard M. Stallman; Debugging
with GDB: theGNU Source-Level Debugger, Richard M. Stallman and Roland H. Pesch; Usingas: theGNU Assembler, Dean
Elsner, Jay Fenlason & friends; ld: theGNU Linker, Steve Chamberlain and Roland Pesch.
BUGS
For instructionson reporting bugs, see the GCC manual.
COPYING
Copyright 1991, 1992, 1993 Free Software Foundation, Inc.
Permission isgranted to make and distribute verbatim copiesof thismanual provided the copyright notice and this
permission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the preceding
conditionsfor modified versions, except that thispermission notice may be included in translationsapproved by the Free
Software Foundation instead of in the original English.
AUTHORS
See the GNU CC manual for the contributorsto GNU CC.
GNU Tools, 13 October 1993
gemtopbm
gemtopbmConvert a GEM IMG file into a portable bitmap
SYNOPSIS
gemtopbm [-d] [ gemfile ]
DESCRIPTION
Readsa GEM IMG file asinput. Readsfrom stdin if input file isomitted. Producesa portable bitmap asoutput.
OPTIONS
-d Produce output describing the contentsof the IMG file.
BUGS
Doesnot support filescontaining more than one plane.
SEE ALSO
pbmtogem(1), pbm(5)
AUTHOR
Copyright 1988 DiomidisD. Spinellis(dds@cc.ic.ac.uk).
11 July1992
gemtopbm
Part I: User Commands
202
geqn
geqnFormat equationsfor troff
SYNOPSIS
geqn [ rvCNR ][dcc ][Tname ][Mdi r ][fF ][sn ][pn ][mn ][f i l es ... ]
DESCRIPTION
Thismanual page describesthe GNU version of eqn, which ispart of the groff document formatting system. eqn compiles
descriptionsof equationsembedded within troff input filesinto commandsthat are understood by troff. Normally, it
should be invoked using the e option of groff. The syntax isquite compatible with UNIX eqn. The output of GNU eqn
cannot be processed with UNIX troff; it must be processed with GNU troff. If no filesare given on the command line, the
standard input will be read. A filename of will cause the standard input to be read.
eqn searchesfor the file eqnrc using the path .:/usr/lib/groff/tmac:/usr/lib/tmac. If it exists, eqn will processit before the
other input files. The R option preventsthis.
GNU eqn doesnot provide the functionality of neqn: it doesnot support low-resolution, typewriter-like devices(although it
may work adequately for very simple input).
OPTIONS
C Recognize .EQ and .EN even when followed by a character other than space or newline.
N Dont allow newlineswithin delimiters. Thisoption allowseqn to recover better from missing closing
delimiters.
v Print the version number.
r Only one size reduction.
mn The minimum point-size isn. eqn will not reduce the size of subscriptsor superscriptsto a smaller size
than n.
Tname The output isfor device name. The only effect of thisisto define a macro name with a value of 1. Typically,
eqnrc will use thisto provide definitionsappropriate for the output device. The default output device isps.
Mdi r Search di r for eqnrc before the default directories.
R Dont load eqnrc.
fF Thisisequivalent to a gfontF command.
sn Thisisequivalent to a gsizen command. Thisoption isdeprecated. eqn will normally set equationsat
whatever the current pointsize iswhen the equation isencountered.
pn Thissaysthat subscriptsand superscriptsshould be n pointssmaller than the surrounding text. Thisoption
isdeprecated. Normally, eqn makessetssubscriptsand superscriptsat 70 percent of the size of the
surrounding text.
USAGE
Only the differencesbetween GNU eqn and UNIX eqn are described here.
Most of the new featuresof GNU eqn are based on TeX. There are some referencesto the differencesbetween TeX and
GNU eqn asfollows; these may safely be ignored if you do not know TeX.
AUTOMATIC SPACING
eqn giveseach component of an equation a type, and adjuststhe spacing between componentsusing that type. Possible types
are
ordinary An ordinary character such as1 or x
operator A large operator such as;
binary A binary operator such as+
relation A relation such as=
203
opening An opening bracket such as(
closing A closing bracket such as)
punctuation A punctuation character such as,
inner A subformula contained within brackets
suppress Spacing that suppressesautomatic spacing adjustment
Componentsof an equation get a type in one of two ways:
typet e Thisyieldsan equation component that containse but that hastype t , where t isone of the types
mentioned previously. For example, timesisdefined as
type binary \(mu
The name of the type doesnt have to be quoted, but quoting protectsfrom macro expansion.
chartypet text Unquoted groupsof charactersare split up into individual characters, and the type of each character is
looked up; thischangesthe type that isstored for each character; it saysthat the charactersin t ext from
now on have type t . For example
chartype punctuation .,;:
would make the characters.,;: have type punctuation whenever they subsequently appeared in an
equation. The type t can also be letter or digit; in these cases, chartype changesthe font type of the
characters. See the Fonts section, later in thismanual page.
NEW PRIMITIVES
e1smallovere2 Thisissimilar to over; smallover reducesthe size of e1 and e2; it also putslessvertical space between e1 or
e2 and the fraction bar. The over primitive correspondsto the \over primitive in display styles; smallover
correspondsto \over in nondisplay styles.
vcentere Thisvertically centerse about the math axis. The math axisisthe vertical position about which characters
such as+ and - are centered; also it isthe vertical position used for the bar of fractions. For example, sum is
defined as
{ type operator vcenter size +5 \(*S }
e1accente2 Thissetse2 asan accent over e1. e2 isassumed to be at the correct height for a lowercase letter; e2 will be
moved down according if e1 istaller or shorter than a lowercase letter. For example, hat isdefined as
accent { }
dotdot, dot, tilde, vec, and dyad are also defined using the accent primitive.
e1uaccente2 Thissetse2 asan accent under e1. e2 isassumed to be at the correct height for a character without a
descender; e2 will be moved down if e1 hasa descender. utilde ispredefined using uaccent asa tilde accent
below the baseline.
splittext Thishasthe same effect assimply text, but text isnot subject to macro expansion because it isquoted;
text will be split up and the spacing between individual characterswill be adjusted.
nosplitt ext Thishasthe same effect astext, but because t ext isnot quoted it will be subject to macro expansion; t ext
will not be split up and the spacing between individual characterswill not be adjusted.
eopprime Thisisa variant of prime that actsasan operator on e.It producesa different result from prime in a case
such asAopprimesub1: With opprime the 1 will be tucked under the prime asa subscript to the A (asis
conventional in mathematical typesetting), whereaswith prime the 1 will be a subscript to the prime
character. The precedence of opprime isthe same asthat of bar and under, which ishigher than that of
everything except accent and uaccent. In unquoted text, a that isnot the first character will be treated
like opprime.
specialt ext e Thisconstructsa new object from e using a gtroff(1) macro named t ext . When the macro iscalled, the
string 0s will contain the output for e, and the number registers0w, 0h, 0d, 0skern and 0skew will contain
the width, height, depth, subscript kern, and skew of e. (The subscript kern of an object sayshow much a
subscript on that object should be tucked in; the skew of an object sayshow far to the right of the center of
the object an accent over the object should be placed.) The macro must modify 0s so that it will output
the desired result with itsorigin at the current point, and increase the current horizontal position by the
width of the object. The number registersmust also be modified so that they correspond to the result.
geqn
Part I: User Commands
204
For example, suppose you wanted a construct that cancelsan expression by drawing a diagonal line through it:
.EQ
define cancel special Ca
.EN
.de Ca
.ds 0s \Z\\*(0s\v\\n(0du\Dl \\n(0wu -\\n(0hu-\\n(0du\v\\n(0hu
..
Then you could cancel an expression U with cancel e.
Heresa more complicated construct that drawsa box around an expression:
.EQ
define box special Bx
.EN
.de Bx
.ds 0s \Z\h1n\\*(0s\
\Z\v\\n(0du+1n\Dl \\n(0wu+2n 0'\Dl 0 -\\n(0hu-\\n(0du-2n\
\Dl -\\n(0wu-2n 0'\Dl 0 \\n(0hu+\\n(0du+2n\h\\n(0wu+2n
.nr 0w +2n
.nr 0d +1n
.nr 0h +1n
..
CUSTOMIZATION
The appearance of equationsiscontrolled by a large number of parameters. These can be set using the set command.
setpn Thissetsparameter p to value n; n isan integer. For example
set x_height 45
saysthat eqn should assume an x height of 0.45 ems.
Possible parametersare asfollows. Valuesare in unitsof hundredthsof an em unlessotherwise stated. These descriptionsare
intended to be expository rather than definitive.
minimum_size eqn will not set anything at a smaller point size than this. The value isin points.
fat_offset The fat primitive emboldensan equation by overprinting two copiesof the equation horizontally
offset by thisamount.
over_hang A fraction bar will be longer by twice thisamount than the maximum of the widthsof the
numerator and denominator; in other words, it will overhang the numerator and denominator by
at least thisamount.
accent_width When bar or under isapplied to a single character, the line will be thislong. Normally, bar or
under producesa line whose length isthe width of the object to which it applies; in the case of a
single character, thistendsto produce a line that lookstoo long.
delimiter_factor Extensible delimitersproduced with the left and right primitiveswill have a combined height and
depth of at least thismany thousandthsof twice the maximum amount by which the subequation
that the delimitersenclose extendsaway from the axis.
delimiter_shortfall Extensible delimitersproduced with the left and right primitiveswill have a combined height and
depth not lessthan the difference of twice the maximum amount by which the subequation that
the delimitersenclose extendsaway from the axisand thisamount.
null_delimiter_space Thismuch horizontal space isinserted on each side of a fraction.
script_space The width of subscriptsand superscriptsisincreased by thisamount.
thin_space Thisamount of space isautomatically inserted after punctuation characters.
medium_space Thisamount of space isautomatically inserted on either side of binary operators.
thick_space Thisamount of space isautomatically inserted on either side of relations.
205
x_height The height of lowercase letterswithout ascenderssuch asx.
axis_height The height above the baseline of the center of characterssuch as+ and -. It isimportant that this
value be correct for the font you are using.
default_rule_thickness Thisshould set to the thicknessof the \(ru character, or the thicknessof horizontal linesproduced
with the \D escape sequence.
num1 The over command will shift up the numerator by at least thisamount.
num2 The smallover command will shift up the numerator by at least thisamount.
denom1 The over command will shift down the denominator by at least thisamount.
denom2 The smallover command will shift down the denominator by at least thisamount.
sup1 Normally superscriptswill be shifted up by at least thisamount.
sup2 Superscriptswithin superscriptsor upper limitsor numeratorsof smallover fractionswill be shifted
up by at least thisamount. Thisisusually lessthan sup1.
sup3 Superscriptswithin denominatorsor square rootsor subscriptsor lower limitswill be shifted up by
at least thisamount. Thisisusually lessthan sup2.
sub1 Subscriptswill normally be shifted down by at least thisamount.
sub2 When there isboth a subscript and a superscript, the subscript will be shifted down by at least this
amount.
sup_drop The baseline of a superscript will be no more than thisamount below the top of the object on
which the superscript isset.
sub_drop The baseline of a subscript will be at least thismuch below the bottom of the object on which the
subscript isset.
big_op_spacing1 The baseline of an upper limit will be at least thismuch above the top of the object on which the
limit isset.
big_op_spacing2 The baseline of a lower limit will be at least thismuch below the bottom of the object on which the
limit isset.
big_op_spacing3 The bottom of an upper limit will be at least thismuch above the top of the object on which the
limit isset.
big_op_spacing4 The top of a lower limit will be at least thismuch below the bottom of the object on which the
limit isset.
big_op_spacing5 Thismuch vertical space will be added above and below limits.
baseline_sep The baselinesof the rowsin a pile or matrix will normally be thisfar apart. In most cases, this
should be equal to the sum of num1 and denom1.
shift_down The midpoint between the top baseline and the bottom baseline in a matrix or pile will be shifted
down by thismuch from the axis. In most cases, thisshould be equal to axis_height.
column_sep Thismuch space will be added between columnsin a matrix.
matrix_side_sep Thismuch space will be added at each side of a matrix.
draw_lines If thisisnonzero, lineswill be drawn using the \D escape sequence, rather than with the \l escape
sequence and the \(ru character.
body_height The amount by which the height of the equation exceedsthiswill be added asextra space before
the line containing the equation (using \x.) The default value is85.
body_depth The amount by which the depth of the equation exceedsthiswill be added asextra space after the
line containing the equation (using \x.) The default value is35.
nroff If thisisnonzero, then ndefine will behave like define and tdefine will be ignored; otherwise,
tdefine will behave like define and ndefine will be ignored. The default value is0. (Thisistypically
changed to 1 by the eqnrc file for the ascii and latin1 devices.)
A more precise description of the role of many of these parameterscan be found in Appendix H of TheTeXbook.
geqn
Part I: User Commands
206
MACROS
Macroscan take arguments. In a macro body, $ n where n isbetween 1 and 9, will be replaced by the nth argument if the
macro iscalled with arguments; if there are fewer than n arguments, it will be replaced by nothing. A word containing a left
parenthesiswhere the part of the word before the left parenthesishasbeen defined using the define command will be
recognized asa macro call with arguments; charactersfollowing the left parenthesisup to a matching right parenthesiswill be
treated ascomma-separated arguments; commasinside nested parenthesesdo not terminate an argument.
sdefinenameXanyt hi ngX Thisislike the define command, but name will not be recognized if called with arguments.
includef i l e Include the contentsof f i l e. Linesof f i l e beginning with .EQ or .EN will be ignored.
ifdefnameXanyt hi ngX If name hasbeen defined by define (or hasbeen automatically defined because name isthe output
device), processanyt hi ng; otherwise ignore anyt hi ng.
X can be any character not appearing in anyt hi ng.
FONTS
eqn normally usesat least two fontsto set an equation: an italic font for letters, and a Roman font for everything else. The
existing gfont command changesthe font that isused asthe italic font. By default thisisI. The font that isused asthe
Roman font can be changed by using the new grfont command.
grfontf Set the Roman font to f .
The italic primitive usesthe current italic font set by gfont; the Roman primitive usesthe current Roman font set by grfont.
There isalso a new gbfont command, which changesthe font used by the bold primitive. If you only use the Roman, italic,
and bold primitivesto change fontswithin an equation, you can change all the fontsused by your equationsjust by using
gfont, grfont, and gbfont commands.
You can control which charactersare treated asletters(and therefore set in italic) by using the chartype command described
earlier. A type of letter will cause a character to be set in italic type. A type of digit will cause a character to be set in Roman
type.
FILES
/usr/lib/groff/tmac/eqnrc Initialization file
BUGS
Inline equationswill be set at the pointsize that iscurrent at the beginning of the input line.
SEE ALSO
groff(1), gtroff(1), groff_font(5), TheTeXbook
getlist
getlistGet a list from an NNTP server
SYNOPSIS
getlist [ h host ][l i st [ pat t er n [ t ypes ]]]
DESCRIPTION
The getlist program obtainsa list from an NNTP server and sendsit to standard output.
The list may be one of active, active.times, distributions, or newsgroups. These valuesrequest the active(5),
active.times, /news/lib/distributions, or /news/lib/newsgroups files, respectively.
If the h flag isused, then the program connectsto the server on the specified host. The default isto connect to the server
specified in the inn.conf(5) file.
207
If the l i st parameter isactive, then the pattern and types parametersmay be used to limit the output. When pattern is
used, only active lineswith groupsthat match according to wildmat(3) are printed. When t ypes isalso given, only active lines
that have a fourth field starting with a character found in t ypes are printed.
For example, the following command will obtain the one-line descriptionsof all newsgroupsfound on UUNET:
getlist -h news.uu.net newsgroups
The following line listsall groupswhere local postingsare permitted, moderated, or aliased:
getlist active * ym=
Note that the listing filesother than the active file isa common extension to the NNTP protocol and may not be available
on all servers.
HISTORY
Written by Landon Curt Noll (<chongo@toad.com>) for InterNetNews.
SEE ALSO
active(5), nnrpd(8), wildmat(3)
getopt
getoptParse command options
SYNOPSIS
set getopt optstring $*
DESCRIPTION
getopt isused to break up optionsin command linesfor easy parsing by shell procedures, and to check for legal options.
optstring isa string of recognized option letters; see getopt(3). If a letter isfollowed by a colon, the option isexpected to
have an argument that may or may not be separated from it by whitespace. The special option - isused to delimit the end
of the options. getopt will place - in the argumentsat the end of the options, or recognize it if used explicitly. The shell
arguments($1 $2 ...) are reset so that each option ispreceded by a and in itsown shell argument; each option argument
isalso in itsown shell argument.
EXAMPLE
The following code fragment showshow one might processthe argumentsfor a command that can take the optionsa and b,
and the option o, which requiresan argument:
set getopt abo: $*
if test $? != 0
then
echo Usage: ...
exit 2
fi
for i
do
case $i
in
-a|-b)
flag=$i; shift;;
-o)
oarg=$2; shift; shift;;
--)
shift; break;;
esac
done
getopt
Part I: User Commands
208
Thiscode will accept any of the following asequivalent:
cmd -aoarg file file
cmd -a -o arg file file
cmd -oarg -a file file
cmd -a -oarg -- file file
SEE ALSO
sh(1), getopt(3)
DIAGNOSTICS
getopt printsan error message on the standard error output when it encountersan option letter not included in optstring.
HISTORY
Written by Henry Spencer, working from a Bell Labsmanual page. Behavior believed identical to the Bell version.
BUGS
Whatever getopt(3) has.
Argumentscontaining whitespace or embedded shell meta charactersgenerally will not survive intact; thislookseasy to fix
but isnt.
The error message for an invalid option isidentified ascoming from getopt rather than from the shell procedure containing
the invocation of getopt; this, again, ishard to fix.
The precise best way to use the set command to set the argumentswithout disrupting the value(s) of shell optionsvaries
from one shell version to another.
21 June1993
giftopnm
giftopnmConvert a GIF file into a portable anymap
SYNOPSIS
giftopnm [-verbose][-comments][-image N][GI Ff i l e]
DESCRIPTION
Readsa GIF file for input, and outputsportable anymap.
OPTIONS
-verbose Producesverbose output about the GIF file input.
-comments Only outputsGIF89 comment fields.
-image Outputsthe specified GIF image from the input GIF archive (where N is1, 2, 20...). Normally, there is
only one image per file, so thisoption isnot needed.
All flagscan be abbreviated to their shortest unique prefix.
BUGS
Thisdoesnot correctly handle the Plain Text Extension of the GIF89 standard, since I did not have any example input files
containing them.
209
SEE ALSO
ppmtogif(1), ppm(5)
AUTHOR
Copyright 1993 by David Koblas(koblas@netcom.com)
29 September 1993
gindxbib
gindxbibMake inverted index for bibliographic databases
SYNOPSIS
gindxbib [vw] [c f i l e] [d di r ] [f f i l e] [h n] [i st r i ng]
[k n] [l n] [n n] [o f i l e] [t n] [f i l ename ...]
DESCRIPTION
gindxbib makesan inverted index for the bibliographic databasesin f i l ename... for use with grefer(1), glookbib(1), and
lkbib(1). The index will be named f i l ename.i; the index iswritten to a temporary file which isthen renamed to this. If no
filenamesare given on the command line because the f option hasbeen used, and no o option isgiven, the index will be
named Ind.i.
Bibliographic databasesare divided into recordsby blank lines. Within a record, each fieldsstartswith a % character at the
beginning of a line. Fieldshave a one-letter name that followsthe % character.
The valuesset by the c, n, l, and t optionsare stored in the index; when the index issearched, keyswill be discarded and
truncated in a manner appropriate to these options; the original keyswill be used for verifying that any record found using
the index actually containsthe keys. Thismeansthat a user of an index need not know whether these optionswere used in
the creation of the index, provided that not all the keysto be searched for would have been discarded during indexing and
that the user suppliesat least the part of each key that would have remained after being truncated during indexing. The value
set by the i option isalso stored in the index and will be used in verifying recordsfound using the index.
OPTIONS
v Print the version number.
w Index whole files. Each file isa separate record.
cf i l e Read the list of common wordsfrom f i l e instead of /usr/lib/groff/eign.
ddi r Use di r asthe pathname of the current working directory to store in the index, instead of the path printed
by pwd(1). Usually di r will be a symbolic link that pointsto the directory printed by pwd(1).
ff i l e Read the filesto be indexed from f i l e. If fileis, fileswill be read from the standard input. The f option
can be given at most once.
ist r i ng Dont index the contentsof fieldswhose namesare in st r i ng. Initially, st r i ng isXYZ.
hn Use the first prime greater than or equal to n for the size of the hash table. Larger valuesof n will usually
make searching faster, but will make the index larger and gindxbib use more memory. Initially, n is997.
kn Use at most n keysper input record. Initially, n is100.
ln Discard keysthat are shorter than n. Initially, n is3.
nn Discard the n most common words. Initially, n is100.
obasename The index should be named basename.i.
tn Truncate keysto n. Initially, n is6.
gindxbib
Part I: User Commands
210
FILES
f i l ename.i Index
Ind.i Default index name
/usr/lib/groff/eign List of common words
indxbibXXXXXX Temporary file
SEE ALSO
grefer(1), lkbib(1), glookbib(1)
Groff Version 1.09, 16 April 1993
glookbib
glookbibSearch bibliographic databases
SYNOPSIS
glookbib [ v ][ist r i ng ][tn ] f i l ename ...
DESCRIPTION
glookbib printsa prompt on the standard error (unlessthe standard input isnot a terminal), readsfrom the standard input a
line containing a set of keywords, searchesthe bibliographic databasesf i l ename ... for referencescontaining those keywords,
printsany referencesfound on the standard output, and repeatsthisprocessuntil the end of input. For each database
f i l ename to be searched, if an index f i l ename.i created by gindxbib(1) exists, then it will be searched instead; each index can
cover multiple databases.
OPTIONS
v Print the version number.
ist r i ng When searching filesfor which no index exists, ignore the contentsof fieldswhose namesare in st r i ng.
tn Only require the first n charactersof keysto be given. Initially, n is6.
FILE
f i l ename.i Index files
SEE ALSO
grefer(1), lkbib(1), gindxbib(1)
gnroff
gnroffEmulate nroff command with groff
SYNOPSIS
gnroff [ h ][i ][mname ][nnum ][ol i st ][rcn ][Tname ][f i l e. . . ]
DESCRIPTION
The gnroff script emulatesthe nroff command using groff. The T option with an argument other than ascii and latin1
will be ignored. The h option isequivalent to the grotty h option. The i, n, m, o, and r optionshave the effect
described in gtroff(1). In addition, gnroff silently ignoresoptionsof e, q, or s.
211
SEE ALSO
groff(1), gtroff(1), grotty(1)
Groff Version 1.09, 17 May1993
gouldtoppm
gouldtoppmConvert Gould scanner file into a portable pixmap
SYNOPSIS
gouldtoppm[goul df i l e]
DESCRIPTION
Readsa file produced by the Gould scanner asinput. Producesa portable pixmap asoutput.
SEE ALSO
ppm(5)
AUTHOR
Copyright 1990 by Stephen Paul Lesniewski
20 May1990
gpic
gpicCompile picturesfor troff or TeX
SYNOPSIS
gpic [ nvC ][f i l ename ... ] gpic t [ cvzC ][f i l ename ... ]
DESCRIPTION
Thismanual page describesthe GNU version of pic, which ispart of the groff document formatting system. pic compiles
descriptionsof picturesembedded within troff or TeX input filesinto commandsthat are understood by TeX or troff.
Each picture startswith a line beginning with .PS and endswith a line beginning with .PE. Anything outside of .PS and .PE
ispassed through without change.
It isthe usersresponsibility to provide appropriate definitionsof the PS and PE macros. When the macro package being used
doesnot supply such definitions(for example, old versionsof ms), appropriate definitionscan be obtained with mpic: These
will center each picture.
OPTIONS
Optionsthat do not take argumentsmay be grouped behind a single . The special option can be used to mark the end of
the options. A filename of refersto the standard input.
C Recognize .PS and .PE even when followed by a character other than space or newline.
n Dont use the groff extensionsto the troff drawing commands. You should use thisif you are using a
postprocessor that doesnt support these extensions. The extensionsare described in groff_out(5). The n option
also causespic not to use zero-length linesto draw dotsin troff mode.
t TeX mode.
c Be more compatible with tpic. Impliest. Linesbeginning with n are not passed through transparently. Lines
beginning with . are passed through with the initial . changed to \. A line beginning with .ps isgiven special
gpic
Part I: User Commands
212
treatment: It takesan optional integer argument specifying the line thickness(pen size) in milli-inches; a missing
argument restoresthe previousline thickness; the default line thicknessis8 milli-inches. The line thicknessthus
specified takeseffect only when a nonnegative line thicknesshasnot been specified by use of the thickness
attribute or by setting the linethick variable.
v Print the version number.
z In TeX mode draw dotsusing zero-length lines.
The following optionssupported by other versionsof pic are ignored:
D Draw all linesusing the \D escape sequence. pic alwaysdoesthis.
Tdev Generate output for the troff device dev . Thisisunnecessary because the troff output generated by pic isdevice-
independent.
USAGE
Thissection describesonly the differencesbetween GNU pic and the original version of pic. Many of these differencesalso
apply to newer versionsof UNIX pic.
mode
mode isenabled by the t option. In mode, pic will define a vbox called ngraph for each picture. You must yourself print that
vbox using, for example, the command:
\centerline{\box\graph}
Actually, since the vbox hasa height of zero, thiswill produce slightly more vertical space above the picture than below it, the
line
\centerline{\raise 1em\box\graph}
would avoid this.
You must use a driver that supportsthe tpic specials, version 2.
Linesbeginning with \are passed through transparently; a % isadded to the end of the line to avoid unwanted spaces. You
can safely use thisfeature to change fontsor to change the value of \baselineskip. Anything else may well produce undesir-
able results; use at your own risk. Linesbeginning with a period are not given any special treatment.
COMMANDS
for var i abl e = expr 1 to expr 2 While the value of var i abl e islessthan or equal to expr 2, do body and increment
by [*]expr 3] do X body X var i abl e by expr 3; if by isnot given, increment var i abl e by 1. If expr 3 isprefixed
[Set var i abl e to expr 1 by * then var i abl e will instead be multiplied by expr 3. X can be any character not
occurring in body.
if expr then X i f - t r ue X Evaluate expr ; if it isnonzero,do i f - t r ue; otherwise, do i f - f al se. u can be any
[else Y i f - f al se Y] character not occurring in i f - t r ue. Y can be any character not occurring in i f - f al se.
print ar g ... Concatenate the argumentsand print asa line on stderr. Each ar g must be an
expression, a position, or text. Thisisuseful for debugging.
command ar g ... Concatenate the argumentsand passthem through asa line to troff or TeX. Each
ar g must be an expression, a position, or text. Thishasa similar effect to a line
beginning with . or \, but allowsthe valuesof variablesto be passed through.
sh X command X Passcommand to a shell. X can be any character not occurring in command.
copy f i l ename Include f i l ename at thispoint in the file.
copy [f i l ename] thru X body X Thisconstruct doesbody once for each line of f i l ename; the line issplit into blank-
[until wor d] delimited words, and occurrencesof $ i in body, for i between 1 and 9, are replaced
copy [f i l ename] thru macr o by the i -th word of the line. If f i l ename isnot given, linesare taken from the current
[until wor d] input up to .PE. If an until clause isspecified, lineswill be read only until a line the
first word of which iswor d; that line will then be discarded. X can be any character
not occurring in body . For example,
213
.PS
copy thru % circle at ($1,$2) % until END
1 2
3 4
5 6
END
box
.PE
isequivalent to
.PS
circle at (1,2)
circle at (3,4)
circle at (5,6)
box
.PE
The commandsto be performed for each line can also be taken from a macro
defined earlier by giving the name of the macro asthe argument to thru.
reset var i abl e1, var i abl e2 . . . Reset predefined variablesvar i abl e1, var i abl e2 ... to their default values. If no
argumentsare given, reset all predefined variablesto their default values. Note that
assigning a value to scale also causesall predefined variablesthat control dimensions
to be reset to their default valuestimesthe new value of scale.
plot expr [t ext ] Thisisa text object which isconstructed by using asa format string for t ext sprintf
with an argument of expr . If t ext isomitted, a format string of %g isused. Attributes
can be specified in the same way asfor a normal text object. Be very careful that you
specify an appropriate format string; pic doesonly very limited checking of the
string. Thisisdeprecated in favor of sprintf.
var i abl e:=expr Thisissimilar to = except var i abl e must already be defined, and the value of
var i abl e will be changed only in the innermost block in which it isdefined. (By
contrast, = definesthe variable in the current block if it isnot already defined there,
and then changesthe value in the current block.)
Argumentsof the form
XanythingX
are also allowed to be of the form:
anything
In thiscase, anything can contain balanced occurrencesof and .BR. Stringsmay contain X or imbalanced occurrencesof
and .BR.
EXPRESSIONS
The syntax for expressionshasbeen significantly extended:
xy (exponentiation)
sin(x)
cos(x)
atan2(y,x)
log(x) (base 10)
exp(x) (base 10, ie 10'-.4mx.4m)
sqrt(x)
int(x)
rand() (return a random number between 0 and 1)
rand(x) (return a random number between 1 and x; deprecated)
max(e1,e2)
min(e1,e2)
!e
gpic
Part I: User Commands
214
e1 && e2
e1 || e2
e1 == e2
e1 != e2
e1 >= e2
e1 > e2
e1 <= e2
e1 < e2
str1==str2"
str1!=str2"
String comparison expressionsmust be parenthesized in some contextsto avoid ambiguity.
OTHER CHANGES
A bare expression, expr, isacceptable asan attribute; it isequivalent to di r expr, where di r isthe current direction. For
example
line 2i
meansdraw a line 2 incheslong in the current direction.
The maximum width and height of the picture are taken from the variablesmaxpswid and maxpsht. Initially, these have values
8.5 and 11.
Scientific notation isallowed for numbers. For example
x = 5e2
Text attributescan be compounded. For example
foo above ljust
islegal.
There isno limit to the depth to which blockscan be examined. For example
[A: [B: [C: box ]]] with .A.B.C.sw at 1,2
circle at last [].A.B.C
isacceptable.
Arcsnow have compasspointsdetermined by the circle of which the arc isa part.
Circlesand arcscan be dotted or dashed. In mode, splinescan be dotted or dashed.
Boxescan have rounded corners. The rad attribute specifiesthe radiusof the quarter-circlesat each corner. If no rad or diam
attribute isgiven, a radiusof boxrad isused. Initially, boxrad hasa value of 0. A box with rounded cornerscan be dotted or
dashed.
The .PS line can have a second argument specifying a maximum height for the picture. If the width of zero isspecified, the
width will be ignored in computing the scaling factor for the picture. Note that GNU pic will alwaysscale a picture by the
same amount vertically ashorizontally. Thisisdifferent from the DWB 2.0 pic, which may scale a picture by a different
amount vertically than horizontally if a height isspecified.
Each text object hasan invisible box associated with it. The compasspointsof a text object are determined by thisbox. The
implicit motion associated with the object isalso determined by thisbox. The dimensionsof thisbox are taken from the
width and height attributes; if the width attribute isnot supplied, then the width will be taken to be textwid; if the height
attribute isnot supplied, then the height will be taken to be the number of text stringsassociated with the object times
textht. Initially textwid and textht have a value of 0.
In placeswhere a quoted text string can be used, an expression of the form:
sprintf(f or mat ,ar g,...)
215
can also be used; thiswill produce the argumentsformatted according to f or mat , which should be a string asdescribed in
printf(3), appropriate for the number of argumentssupplied, using only the e, f, g, or % format characters.
The thicknessof the linesused to draw objectsiscontrolled by the linethick variable. Thisgivesthe thicknessof linesin
points. A negative value meansuse the default thickness: in output mode, thismeansuse a thicknessof 8 milli-inches; in
output mode with the -c option, thismeansuse the line thicknessspecified by .ps lines; in troff output mode, thismeans
use a thicknessproportional to the point size. A zero value meansdraw the thinnest possible line supported by the output
device. Initially, it hasa value of -1. There isalso a thick[ness] attribute. For example,
circle thickness 1.5
would draw a circle using a line with a thicknessof 1.5 points. The thicknessof linesisnot affected by the value of the scale
variable, nor by the width or height given in the .PS line.
Boxes(including boxeswith rounded corners), circles, and ellipsescan be filled by giving then an attribute of fill[ed]. This
takesan optional argument of an expression with a value between 0 and 1; 0 will fill it with white, 1 with black, valuesin
between with a proportionally gray shade. A value greater than 1 can also be used: thismeansfill with the shade of gray that
iscurrently being used for text and lines. Normally thiswill be black, but output devicesmay provide a mechanism for
changing this. Without an argument, then the value of the variable fillval will be used. Initially, thishasa value of 0.5. The
invisible attribute doesnot affect the filling of objects. Any text associated with a filled object will be added after the object
hasbeen filled, so that the text will not be obscured by the filling.
Arrowheadswill be drawn assolid trianglesif the variable arrowhead isnonzero and either mode isenabled or the x option
hasbeen given. Initially, arrowhead hasa value of 1.
The troff output of pic isdevice-independent. The T option istherefore redundant. All numbersare taken to be in inches;
numbersare never interpreted to be in troff machine units.
Objectscan have an aligned attribute. Thiswill only work when the postprocessor isgrops. Any text associated with an
object having the aligned attribute will be rotated about the center of the object so that it isaligned in the direction from the
start point to the end point of the object. Note that thisattribute will have no effect for objectswhose start and end points
are coincident.
In placeswhere nth isallowed, expr th isalso allowed. Note that th isa single token: no space isallowed between the and
the th. For example,
fori =1 to 4 do{
line from ith box.nw to i+1th box.se
}
FILE
/usr/lib/groff/tmac/tmac.pic Sample definitionsof the PSand PE macros.
SEE ALSO
gtroff(1), groff_out(5), tex(1)
TPIC: PIC for AT&T Bell Laboratories, Computing Science Technical Report No. 116, PICA GraphicsLanguagefor
Typesetting. (Thiscan be obtained by sending an e-mail message to netlib@research.att.com with a body of send 116 from
research/cstr.)
BUGS
Input charactersthat are illegal for groff (those with ASCII code 0 or between 013 and 037 octal or between 0200 and 0237
octal) are rejected even in mode.
The interpretation of fillval isincompatible with the pic in 10th edition UNIX, which interprets0 asblack and 1 aswhite.
gpic
Part I: User Commands
216
gprof
gprofDisplay call graph profile data
SYNOPSIS
gprof [ abcsz ] [ ejE name ] [fjF name ][k f r omname toname ] [ obj f i l e [ gmon. out ]]
DESCRIPTION
gprof producesan execution profile of C, Pascal, or Fortran77 programs. The effect of called routinesisincorporated in the
profile of each caller. The profile data istaken from the call graph profile file (gmon.out default), which iscreated by programs
that are compiled with the pg option of cc(1), pc(1),and f77(1). The pg option also linksin versionsof the library routines
that are compiled for profiling. gprof readsthe given object file (the default isa.out) and establishesthe relation between its
symbol table and the call graph profile from gmon.out. If more than one profile file isspecified, the gprof output showsthe
sum of the profile information in the given profile files.
gprof calculatesthe amount of time spent in each routine. Next, these timesare propagated along the edgesof the call graph.
Cyclesare discovered, and callsinto a cycle are made to share the time of the cycle. The first listing showsthe functions
sorted according to the time they represent, including the time of their call graph descendants. Below each function entry is
shown its(direct) call graph children, and how their timesare propagated to thisfunction. A similar display above the
function showshow thisfunctionstime and the time of itsdescendantsispropagated to its(direct) call graph parents.
Cyclesare also shown, with an entry for the cycle asa whole and a listing of the membersof the cycle and their contributions
to the time and call countsof the cycle.
Second, a flat profile isgiven, similar to that provided by prof(1). Thislisting givesthe total execution times, the call counts,
the time in milliseconds, the call spent in the routine itself, and the time in millisecondsthe call spent in the routine itself,
including itsdescendants.
Finally, an index of the function namesisprovided.
OPTIONS
The following optionsare available:
a Suppressesthe printing of statically declared functions. If thisoption isgiven, all relevant information
about the static function (for example, time samples, callsto other functions, callsfrom other
functions) belongsto the function loaded just before the static function in the objfile file.
b Suppressesthe printing of a description of each field in the profile.
c The static call graph of the program isdiscovered by a heuristic that examinesthe text space of the
object file. Static-only parentsor children are shown with call countsof 0.
e name Suppressesthe printing of the graph profile entry for routine name and all itsdescendants(unlessthey
have other ancestorsthat arent suppressed). More than one e option may be given. Only one name
may be given with each e option.
E name Suppressesthe printing of the graph profile entry for routine name (and itsdescendants) ase,
previously and also excludesthe time spent in name (and itsdescendants) from the total and percentage
time computations. (For example, E mcount E mcl eanup isthe default.)
f name Printsthe graph profile entry of only the specified routine name and itsdescendants. More than one f
option may be given. Only one name may be given with each f option.
F name Printsthe graph profile entry of only the routine name and itsdescendants(asf, previously) and also
usesonly the timesof the printed routinesin total time and percentage computations. More than one
F option may be given. Only one name may be given with each F option. The F option overridesthe
E option.
k f r omname t oname Will delete any arcsfrom routine f r omname to routine t oname. Thiscan be used to break undesired
cycles. More than one k option may be given. Only one pair of routine namesmay be given with each
k option.
217
s A profile file gmon.sum isproduced that representsthe sum of the profile information in all the specified
profile files. Thissummary profile file may be given to later executionsof gprof (probably also with an
s) to accumulate profile data acrossseveral runsof an objfile file.
-v Printsthe version number for gprof, and then exits.
-z Displaysroutinesthat have zero usage (asshown by call countsand accumulated time). Thisisuseful
with the c option for discovering which routineswere never called.
FILES
a.out The name list and text space
gmon.out Dynamic call graph and profile
gmon.sum Summarized dynamic call graph and profile
SEE ALSO
monitor(3), profil(2), cc(1), prof(1)
An Execution Profiler for Modular Programs, by S. Graham, P. Kessler, M. McKusick; SoftwarePracticeand Experience,
Vol. 13, pp. 671-685, 1983.
gprof: A Call Graph Execution Profiler, by S. Graham, P. Kessler, M. McKusick; Proceedingsof theSIGPLAN 82
Symposiumon Compiler Construction, SIGPLAN Notices, Vol. 17, No 6, pp. 120-126, June 1982.
HISTORY
gprof appeared in 4.2 BSD.
BUGS
The granularity of the sampling isshown, but remainsstatistical at best. We assume that the time for each execution of a
function can be expressed by the total time for the function divided by the number of timesthe function iscalled. Thus, the
time propagated along the call graph arcsto the functionsparentsisdirectly proportional to the number of timesthat arc is
traversed.
Parentsthat are not themselvesprofiled will have the time of their profiled children propagated to them, but they will appear
to be spontaneously invoked in the call graph listing, and will not have their time propagated further. Similarly, signal
catchers, even though profiled, will appear to be spontaneous(although for more obscure reasons). Any profiled children of
signal catchersshould have their timespropagated properly, unlessthe signal catcher wasinvoked during the execution of the
profiling routine, in which case all islost.
The profiled program must call exit(2) or return normally for the profiling information to be saved in the gmon.out file.
29 January1993
grefer
greferPreprocessbibliographic referencesfor groff
SYNOPSIS
gr ef er [ benv CPRS] [ a n] [ c f i el ds] [ f n] [ i f i el ds] [ k f i el d] [l m,n] [p f i l ename] [s f i el ds] [t n] [B
field.macro] [f i l ename...]
DESCRIPTION
Thisfile documentsthe GNU version of refer, which ispart of the groff document formatting system. refer copiesthe
contentsof f i l ename... to the standard output, except that linesbetween .[ and .] are interpreted ascitations, and lines
between .R1 and .R2 are interpreted ascommandsabout how citationsare to be processed.
grefer
Part I: User Commands
218
Each citation specifiesa reference. The citation can specify a reference that iscontained in a bibliographic database by giving
a set of keywordsthat only that reference contains. Alternatively, it can specify a reference by supplying a database record in
the citation. A combination of these alternativesisalso possible.
For each citation, refer can produce a mark in the text. Thismark consistsof some label that can be separated from the text
and from other labelsin variousways. For each reference, it also outputsgroff commandsthat can be used by a macro
package to produce a formatted reference for each citation. The output of refer must therefore be processed using a suitable
macro package. The ms and me macrosare both suitable. The commandsto format a citationsreference can be output
immediately after the citation, or the referencesmay be accumulated, and the commandsoutput at some later point. If the
referencesare accumulated, then multiple citationsof the same reference will produce a single formatted reference.
The interpretation of linesbetween .R1 and .R2 ascommandsisa new feature of GNU refer. Documentsmaking use of this
feature can still be processed by UNIX refer just by adding the lines:
.de R1
.ig R2
..
to the beginning of the document. Thiswill cause troff to ignore everything between .R1 and .R2. The effect of some
commandscan also be achieved by options. These optionsare supported mainly for compatibility with UNIX refer. It is
usually more convenient to use commands.
refer generates.lf linesso that filenamesand line numbersin messagesproduced by commandsthat read refer output will
be correct; it also interpretslinesbeginning with .lf so that filenamesand line numbersin the messagesand .lf linesthat it
produceswill be accurate even if the input hasbeen preprocessed by a command such asgsoelim(1).
OPTIONS
Most optionsare equivalent to commands(for a description of these commands, see Commands, later in thismanual
page):
b no-label-in-text; no-label-in-reference
e accumulate
n no-default-database
C compatible
P move-punctuation
S label (A.n|Q) , (D.y|D); bracket-label ( ) ;
an reverse An
cf i el ds capitalize f i el ds
fn label %n
if i el ds search-ignore f i el ds
k label L%a
kf i el d label f i el d%a
l label A.nD.y%a
lm label A.n+mD.y%a
l,n label A.nD.yn%a
lm,n label A.n+mD.yn%a
pf i l ename database f i l ename
sspec sort spec
tn search-truncate n
These optionsare equivalent to the following commandswith the addition that the filenamesspecified on the command line
are processed asif they were argumentsto the bibliography command instead of in the normal way:
B Annotate X AP; no-label-in-reference
Bf i el d.macr o Annotate f i el d macr o; no-label-in-reference
219
The following optionshave no equivalent commands:
v Print the version number
R Dont recognize linesbeginning with .R1/.R2
USAGE
BIBLIOGRAPHIC DATABASES
The bibliographic database isa text file consisting of recordsseparated by one or more blank lines. Within each record, fields
start with a % at the beginning of a line. Each field hasa one-character name that immediately followsthe %. It isbest to use
only uppercase and lowercase lettersfor the namesof fields. The name of the field should be followed by exactly one space,
and then by the contentsof the field. Empty fieldsare ignored. The conventional meaning of each field isasfollows:
A The name of an author. If the name containsa title such asJr. at the end, it should be separated from the
last name by a comma. There can be multiple occurrencesof the A field. The order issignificant. It isa
good idea alwaysto supply an A field or a Q field.
B For an article that ispart of a book, the title of the book.
C The place (city) of publication.
D The date of publication. The year should be specified in full. If the month isspecified, the name rather
than the number of the month should be used, but only the first three lettersare required. It isa good idea
alwaysto supply a D field; if the date isunknown, a value such asin press or unknown can be used.
E For an article that ispart of a book, the name of an editor of the book. Where the work haseditorsand no
authors, the namesof the editorsshould be given asA fields(ed) or (eds) should be appended to the last
author.
G U.S. government ordering number.
I The publisher (issuer).
J For an article in a journal, the name of the journal.
K Keywordsto be used for searching.
L Label.
N Journal issue number.
O Other information. Thisisusually printed at the end of the reference.
P Page number. A range of pagescan be specified asmn.
Q The name of the author, if the author isnot a person. Thiswill only be used if there are no A fields. There
can only be one Q field.
R Technical report number.
S Seriesname.
T Title. For an article in a book or journal, thisshould be the title of the article.
V Volume number of the journal or book.
X Annotation.
For all fieldsexcept A and E, if there ismore than one occurrence of a particular field in a record, only the last such field will
be used.
If accent stringsare used, they should follow the character to be accented. Thismeansthat the AM macro must be used with
the ms macros. Accent stringsshould not be quoted: use one \ rather than two.
CITATIONS
The format of a citation is
.[openi ng- t ext
f l ags keywor ds
f i el ds
.]cl osi ng- t ext
grefer
Part I: User Commands
220
The openi ng- t ext , cl osi ng- t ext , and f l ags componentsare optional. Only one of the keywor ds and f i el ds componentsneed
be specified.
The keywor ds component saysto search the bibliographic databasesfor a reference that containsall the wordsin keywor ds. It
isan error if more than one reference if found.
The f i el ds componentsspecifiesadditional fieldsto replace or supplement those specified in the reference. When references
are being accumulated and the keywor ds component isnonempty, then additional fieldsshould be specified only on the first
occasion that a particular reference iscited, and will apply to all citationsof that reference.
The openi ng- t ext and cl osi ng- t ext component specifiesstringsto be used to bracket the label instead of the stringsspecified
in the bracket-label command. If either of these componentsisnonempty, the stringsspecified in the bracket-label
command will not be used; thisbehavior can be altered using the [ and ] flags. Note that leading and trailing spacesare
significant for these components.
The f l ags component isa list of nonalphanumeric characters, each of which modifiesthe treatment of thisparticular
citation. UNIX refer will treat these flagsaspart of the keywordsand so will ignore them because they are
nonalphanumeric. The following flagsare currently recognized:
# Thissaysto use the label specified by the short-label command, instead of that specified by the label command.
If no short label hasbeen specified, the normal label will be used. Typically, the short label isused with author-
date labelsand consistsof only the date and possibly a disambiguating letter; the # issupposed to be suggestive of
a numeric type of label.
[ Precede openi ng- t ext with the first string specified in the bracket-label command.
] Follow cl osi ng- t ext with the second string specified in the bracket-label command.
One advantage of using the [ and ] flagsrather than including the bracketsin openi ng- t ext and cl osi ng- t ext isthat you can
change the style of bracket used in the document just by changing the bracket-label command. Another advantage isthat
sorting and merging of citationswill not necessarily be inhibited if the flagsare used.
If a label isto be inserted into the text, it will be attached to the line preceding the .[ line. If there isno such line, then an
extra line will be inserted before the .[ line and a warning will be given.
There isno special notation for making a citation to multiple references. Just use a sequence of citations, one for each
reference. Dont put anything between the citations. The labelsfor all the citationswill be attached to the line preceding the
first citation. The labelsmay also be sorted or merged. (See the description of the <> label expression, and of the sort-
adjacent- labels and abbreviate-label-ranges command.) A label will not be merged if itscitation hasa nonempty openi ng-
t ext or cl osi ng- t ext . However, the labelsfor a citation using the ] flag and without any cl osi ng- t ext immediately followed
by a citation using the [ flag and without any openi ng- t ext may be sorted and merged even though the first citations
openi ng- t ext or the second citationscl osi ng- t ext isnonempty. (If you want to prevent this, just make the first citations
cl osi ng- t ext \ &.)
COMMANDS
Commandsare contained between linesstarting with .R1 and .R2. Recognition of these linescan be prevented by the R
option. When an .R1 line isrecognized, any accumulated referencesare flushed out. Neither .R1 nor .R2 lines, nor anything
between them, isoutput.
Commandsare separated by newlinesor semicolons. # introducesa comment that extendsto the end of the line (but does
not conceal the newline). Each command isbroken up into words. Wordsare separated by spacesor tabs. A word that begins
with an open quote () extendsto the next close quote () that isnot followed by another open quote (). If there isno such
open quote () the word extendsto the end of the line. Pairsof open quotes() in a word beginning with collapse to a single
open quote (). Neither # nor ; isrecognized inside open quotes(). A line can be continued by ending it with \; thisworks
everywhere except after a #.
Each command name that ismarked with * hasan associated negative command no-name that undoesthe effect of name. For
example, the no-sort command specifiesthat referencesshould not be sorted. The negative commandstake no arguments.
221
In the following description, each argument must be a single word; f i el d isused for a single uppercase or lowercase letter
naming a field; f i el ds isused for a sequence of such letters; m and n are used for a nonnegative numbers; st r i ng isused for an
arbitrary string; f i l ename isused for the name of a file.
abbreviate*f i el dsstring1 Abbreviate the first namesof f i el ds. An initial letter will be separated from another
st r i ng2string3st r i ng4 initial letter by st r i ng1, from the last name by st r i ng2, and from anything else (such
asa von or de) by st r i ng3. These default to a period followed by a space. In a
hyphenated first name, the initial of the first part of the name will be separated from
the hyphen by st r i ng4; thisdefaultsto a period. No attempt ismade to handle any
ambiguitiesthat might result from abbreviation. Namesare abbreviated before
sorting and before label construction.
abbreviate-label-ranges*st r i ng Three or more adjacent labelsthat refer to consecutive referenceswill be abbreviated
to a label consisting of the first label, followed by st r i ng, followed by the last label.
Thisismainly useful with numeric labels. If st r i ng isomitted it defaultsto .
accumulate* Accumulate referencesinstead of writing out each reference asit isencountered.
Accumulated referenceswill be written out whenever a reference of the form:
.[
$LIST$
.]
isencountered, after all input fileshave been processed, and whenever an .R1 line is
recognized.
annotate*f i el dstring f i el d isan annotation; print it at the end of the reference asa paragraph preceded by
the line
.string
If macro isomitted, it will default to AP;if field isalso omitted, it will default to X.
Only one field can be an annotation.
articlesst r i ng ... These are definite or indefinite articles, and should be ignored at the beginning of T
st r i ng ... fieldswhen sorting. Initially, the, a, and an are recognized asarticles.
bibliographyf i l ename ... Write out all the referencescontained in the bibliographic databasesf i l ename ...
bracket-labelst r i ng In the text, bracket each label with st r i ng1 and st r i ng2. An occurrence of st r i ng2
1string2st r i ng3 immediately followed by st r i ng1 will be turned into st r i ng3. The default behavior is
bracket-label \*([. \*(.] ,
capitalizef i el ds Convert f i el ds to capsand small caps.
compatible* Recognize .R1 and .R2 even when followed by a character other than space or
newline.
databasef i l ename... Search the bibliographic databasesf i l ename... For each f i l ename if an index
f i l ename.i created by gindxbib(1) exists, then it will be searched instead; each index
can cover multiple databases.
date-as-label*st r i ng st r i ng isa label expression that specifiesa string with which to replace the D field
after constructing the label. See Label Expressions, later in thismanual page, for a
description of label expressions. Thiscommand isuseful if you do not want explicit
labelsin the reference list, but instead want to handle any necessary disambiguation
by qualifying the date in some way. The label used in the text would typically be
some combination of the author and date. In most cases, you should also use the no-
label-in-reference command. For example,
date-as-label D.+yD.y%a*D.-y
would attach a disambiguating letter to the year part of the D field in the reference.
default-database* The default database should be searched. Thisisthe default behavior, so the negative
version of thiscommand ismore useful. refer determineswhether the default
database should be searched on the first occasion that it needsto do a search. Thus, a
no-default-database command must be given before then, in order to be effective.
grefer
Part I: User Commands
222
discard*f i el ds When the reference isread, f i el ds should be discarded; no string definitionsfor
f i el ds will be output. Initially, f i el ds are XYZ.
et-al*st r i ngmn Control use of et al in the evaluation of @ expressionsin label expressions. If the
number of authorsneeded to make the author sequence unambiguousisu and the
total number of authorsist , then the last t u authorswill be replaced by st r i ng,
provided that t u isnot lessthan m and t isnot lessthan n. The default behavior is
et-al et al 2 3.
includef i l ename Include f i l ename and interpret the contentsascommands.
join-authorsst r i ng1 Thissayshow authorsshould be joined together. When there are exactly two
string2st r i ng3 authors, they will be joined with st r i ng1. When there are more than two authors, all
but the last two will be joined with st r i ng2, and the last two authorswill be joined
with st r i ng3. If st r i ng3 isomitted, it will default to st r i ng1; if st r i ng2 isalso
omitted, it will also default to st r i ng1. For example,
join-authors and , , and
will restore the default method for joining authors.
label-in-reference* When outputting the reference, define the string [F to be the referenceslabel. This
isthe default behavior; so the negative version of thiscommand ismore useful.
label-in-text* For each reference, output a label in the text. The label will be separated from the
surrounding text asdescribed in the bracket-label command. Thisisthe default
behavior; so the negative version of thiscommand ismore useful.
labelst r i ng st r i ng isa label expression describing how to label each reference.
separate-label-second-parts When merging two-part labels, separate the second part of the second label from the
st r i ng first label with st r i ng. See the description of the <> label expression.
move-punctuation* In the text, move any punctuation at the end of line past the label. It isusually a
good idea to give thiscommand unlessyou are using superscripted numbersas
labels.
reverse*st r i ng Reverse the fieldswhose namesare in st r i ng. Each field name can be followed by a
number that sayshow many such fieldsshould be reversed. If no number isgiven for
a field, all such fieldswill be reversed.
search-ignore*f i el ds While searching for keysin databasesfor which no index exists, ignore the contents
of f i el ds. Initially, fieldsXYZ are ignored.
search-truncate*n Only require the first n charactersof keysto be given. In effect, when searching for a
given key, wordsin the database are truncated to the maximum of n and the length
of the key. Initially, n is6.
short-label*st r i ng st r i ng isa label expression that specifiesan alternative (usually shorter) style of label.
Thisisused when the # flag isgiven in the citation. When using author-date style
labels, the identity of the author or authorsissometimesclear from the context, and
so it may be desirable to omit the author or authorsfrom the label. The short-label
command will typically be used to specify a label containing just a date and possibly
a disambiguating letter.
sort*st r i ng Sort referencesaccording to string. Referenceswill automatically be accumulated.
st r i ng should be a list of field names, each followed by a number, indicating how
many fieldswith the name should be used for sorting. + can be used to indicate that
all the fieldswith the name should be used. Also, . can be used to indicate the
referencesshould be sorted using the (tentative) label. (The Label Expressions
subsection describesthe concept of a tentative label.)
sort-adjacent-labels* Sort labelsthat are adjacent in the text according to their position in the reference
list. Thiscommand should usually be given if the abbreviate-label-ranges
command hasbeen given, or if the label expression containsa <> expression. This
will have no effect unlessreferencesare being accumulated.
223
LABEL EXPRESSIONS
Label expressionscan be evaluated both normally and tentatively. The result of normal evaluation isused for output. The
result of tentative evaluation, called the tentative label, isused to gather the information that normal evaluation needsto
disambiguate the label. Label expressionsspecified by the date-as-label and short-label commandsare not evaluated
tentatively. Normal and tentative evaluation are the same for all typesof expression other than @, *, and % expressions. The
following description appliesto normal evaluation, except where otherwise specified.
field, field n The nth part of field. If n isomitted, it defaultsto 1.
st r i ng The charactersin st r i ng literally.
@ All the authorsjoined asspecified by the join-authors command. The whole of each authorsname
will be used. However, if the referencesare sorted by author (that isthe sort specification startswith
A+), then authors last nameswill be used instead, provided that thisdoesnot introduce ambiguity, and
also an initial subsequence of the authorsmay be used instead of all the authors, again provided that
thisdoesnot introduce ambiguity. The use of only the last name for the i -th author of some reference
isconsidered to be ambiguousif there issome other reference, such that the first i - 1 authorsof the
referencesare the same, the i-th authorsare not the same, but the i-th authors last namesare the
same. A proper initial subsequence of the sequence of authorsfor some reference isconsidered to be
ambiguousif there isa reference with some other sequence of authorsthat also hasthat subsequence as
a proper initial subsequence. When an initial subsequence of authorsisused, the remaining authorsare
replaced by the string specified by the et-al command; thiscommand may also specify additional
requirementsthat must be met before an initial subsequence can be used. @ tentatively evaluatesto a
canonical representation of the authors, such that authorsthat compare equally for sorting purpose will
have the same representation.
%n, %a, %A, %i, %I The serial number of the reference formatted according to the character following the %. The serial
number of a reference is1 plusthe number of earlier referenceswith same tentative label asthis
reference. These expressionstentatively evaluate to an empty string.
expr * If there isanother reference with the same tentative label asthisreference, then expr ; otherwise, an
empty string. It tentatively evaluatesto an empty string.
expr +n, expr n The first (+) or last () n uppercase or lowercase lettersor digitsof expr . troff special characters(such
as\(a) count asa single letter. Accent stringsare retained but do not count toward the total.
expr .l expr converted to lowercase.
expr .u expr converted to uppercase.
expr .c expr converted to capsand small caps.
expr .r expr reversed so that the last name isfirst.
expr .a expr with first namesabbreviated. Note that fieldsspecified in the abbreviate command are abbrevi-
ated before any labelsare evaluated. Thus.a isuseful only when you want a field to be abbreviated in a
label but not in a reference.
expr .y The year part of expr .
expr .+y The part of expr before the year, or the whole of expr if it doesnot contain a year.
expr .y The part of expr after the year, or an empty string if expr doesnot contain a year.
expr .n The last name part of expr .
expr 1expr 2 expr 1 except that if the last character of expr 1 is then it will be replaced by expr 2.
expr 1 expr 2 The concatenation of expr 1 and expr 2.
expr 1| expr 2 If expr 1 isnonempty, then expr 1; otherwise, expr 2.
expr 1&expr 2 If expr 1 isnonempty, then expr 2; otherwise, an empty string.
expr 1?expr 2:expr 3 If expr 1 isnonempty, then expr 2; otherwise, expr 3.
<expr > The label isin two parts, which are separated by expr . Two adjacent two-part labelsthat have the same
first part will be merged by appending the second part of the second label onto the first label separated
by the string specified in the separate-label-second-parts command (initially, a comma followed by a
grefer
Part I: User Commands
224
space); the resulting label will also be a two-part label with the same first part asbefore merging, and so
additional labelscan be merged into it. Note that it ispermissible for the first part to be empty; this
may be desirable for expressionsused in the short-label command.
(expr ) The same asexpr . Used for grouping.
The preceding expressionsare listed in order of precedence (highest first); & and | have the same precedence.
MACRO INTERFACE
Each reference startswith a call to the macro ]-. The string [F will be defined to be the label for thisreference, unlessthe no-
label-in-reference command hasbeen given. There then followsa seriesof string definitions, one for each field: string [X
correspondsto field X. The number register [P isset to 1 if the P field containsa range of pages. The [T, [A, and [O number
registersare set to 1 according asthe T, A, and O fieldsend with one of the characters.?!. The [E number register will be set
to 1 if the [E string containsmore than one name. The reference isfollowed by a call to the ][ macro. The first argument to
thismacro givesa number representing the type of the reference. If a reference containsa J field, it will be classified astype 1;
otherwise, if it containsa B field, it will be type 3; otherwise, if it containsa G or R field it will be type 4, otherwise if it
containsan I field, it will be type 2; otherwise, it will be type 0. The second argument isa symbolic name for the type: other,
journal-article, book, article-in-book, or tech-report. Groupsof referencesthat have been accumulated or are produced by
the bibliography command are preceded by a call to the ]< macro and followed by a call to the ]> macro.
FILES
/usr/dict/papers/Ind Default database
f i l e.i Index files
SEE ALSO
gindxbib(1), glookbib(1), lkbib(1)
BUGS
In label expressions, <> expressionsare ignored inside .char expressions.
Groff Version 1.09
grep, egrep, fgrep
grep, egrep, fgrepPrint linesmatching a pattern
SYNOPSIS
grep [ [[AB]]num ][[CEFGVBchilnsvwx]][e ] pat t er n j ff i l e ][f i l es. . . ]
DESCRIPTION
grep searchesthe named input f i l es (or standard input if no filesare named, or the filename isgiven) for linescontaining a
match to the given pat t er n. By default, grep printsthe matching lines.
There are three major variantsof grep, controlled by the following options:
G Interpret pat t er n asa basic regular expression (see the list following thisone). Thisisthe default.
E Interpret pat t er n asan extended regular expression.
F Interpret pat t er n asa list of fixed strings, separated by newlines, any of which isto be matched.
In addition, two variant programs, egrep and fgrep, are available. egrep issimilar (but not identical) to grepnE, and is
compatible with the historical UNIX egrep. Fgrep isthe same asgrepnF.
All variantsof grep understand the following options:
225
num Matcheswill be printed with num linesof leading and trailing context. However, grep will never print
any given line more than once.
A num Print num linesof trailing context after matching lines.
B num Print num linesof leading context before matching lines.
C Equivalent to 2.
V Print the version number of grep to standard error. Thisversion number should be included in all bug
reports.
b Print the byte offset within the input file before each line of output.
c Suppressnormal output; instead print a count of matching linesfor each input file. With the v
option, count nonmatching lines.
e pat t er n Use pat t er n asthe pattern; useful to protect patternsbeginning with .
f f i l e Obtain the pattern from f i l e.
h Suppressthe prefixing of filenameson output when multiple filesare searched.
i Ignore case distinctionsin both the pat t er n and the input files.
L Suppressnormal output; instead print the name of each input file from which no output would
normally have been printed.
l Suppressnormal output; instead print the name of each input file from which output would normally
have been printed.
n Prefix each line of output with the line number within itsinput file.
q Quiet; suppressnormal output.
s Suppresserror messagesabout nonexistent or unreadable files.
v Invert the sense of matching, to select nonmatching lines.
w Select only those linescontaining matchesthat form whole words. The test isthat the matching
substring must either be at the beginning of the line, or preceded by a nonword constituent character.
Similarly, it must be either at the end of the line or followed by a nonword-constituent character.
Word-constituent charactersare letters, digits, and the underscore.
x Select only those matchesthat exactly match the whole line.
REGULAR EXPRESSIONS
A regular expression isa pattern that describesa set of strings. Regular expressionsare constructed analogously to arithmetic
expressions, by using variousoperatorsto combine smaller expressions.
grep understandstwo different versionsof regular expression syntax: basicand extended. In GNU\grep, there isno difference
in available functionality using either syntax. In other implementations, basic regular expressionsare lesspowerful. The
following description appliesto extended regular expressions; differencesfor basic regular expressionsare summarized
afterwards.
The fundamental building blocksare the regular expressionsthat match a single character. Most characters, including all
lettersand digits, are regular expressionsthat match themselves. Any meta character with special meaning may be quoted by
preceding it with a backslash.
A list of charactersenclosed by [ and ] matchesany single character in that list; if the first character of the list isthe caret ()
then it matchesany character not in the list. For example, the regular expression [0123456789] matchesany single digit. A
range of ASCII charactersmay be specified by giving the first and last characters, separated by a hyphen. Finally, certain
named classesof charactersare predefined. Their namesare self-explanatory, and they are [:alnum:], [:alpha:], [:cntrl:],
[:digit:], [:graph:], [:lower:], [:print:], [:punct:], [:space:], [:upper:], and [:xdigit:]. For example, [[:alnum:]]
means[0-9A-Za- z], except the latter form isdependent upon the ASCII character encoding, whereasthe former isportable.
(Note that the bracketsin these classnamesare part of the symbolic names, and must be included in addition to the brackets
delimiting the bracket list.) Most meta characterslose their special meaning inside lists. To include a literal ], place it first in
the list. Similarly, to include a literal ^, place it anywhere but first. Finally, to include a literal -, place it last.
The period matchesany single character. The symbol \w isa synonym for [[:alnum:]] and \W isa synonym for [^[:alnum]].
grep, egrep, fgrep
Part I: User Commands
226
The caret and the dollar sign are meta charactersthat respectively match the empty string at the beginning and end of a line.
The symbols\< and \>, respectively, match the empty string at the beginning and end of a word. The symbol \b matchesthe
empty string at the edge of a word, and \B matchesthe empty string provided itsnot at the edge of a word.
A regular expression matching a single character may be followed by one of several repetition operators:
? The preceding item isoptional and matched at most once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
n The preceding item ismatched exactly n times.
n, The preceding item ismatched n or more times.
,m The preceding item isoptional and ismatched at most m times.
n,m The preceding item ismatched at least n times, but not more than m times.
Two regular expressionsmay be concatenated; the resulting regular expression matchesany string formed by concatenating
two substringsthat respectively match the concatenated subexpressions.
Two regular expressionsmay be joined by the infix operator |; the resulting regular expression matchesany string matching
either subexpression.
Repetition takesprecedence over concatenation, which in turn takesprecedence over alternation. A whole subexpression may
be enclosed in parenthesesto override these precedence rules.
The back reference \n, where n isa single digit, matchesthe substring previously matched by the nth parenthesized
subexpression of the regular expression.
In basic regular expressions, the meta characters|, (, and ) lose their special meaning; instead use the backslashed versions
\?, \+, \f, \j, \(, and \).
In egrep, the meta character { losesitsspecial meaning; instead use \{.
DIAGNOSTICS
Normally, exit statusis0 if matcheswere found, and 1 if no matcheswere found. (The .B v option invertsthe sense of the
exit status.) Exit statusis2 if there were syntax errorsin the pattern, inaccessible input files, or other system errors.
BUGS
E-mail bug reportsto bug-gnu-utils@prep.ai.mit.edu. Be sure to include the word grep somewhere in the Subject: field.
Large repetition countsin the m ,n construct may cause grep to use lotsof memory. In addition, certain other obscure regular
expressionsrequire exponential time and space, and may cause grep to run out of memory.
Back referencesare very slow, and may require exponential time.
GNU Project, 10 September 1992
grephistory
grephistoryDisplay filenamesfrom Usenet history file
SYNOPSIS
grephistory [ f f i l ename ][e ][n ][q ][l ][i ][s ][messagei d ]
DESCRIPTION
grephistory queriesthe dbz(3) index into the history(5) file for an article having a specified Message ID.
If messageid cannot be found in the database, the program printsNot found and exitswith a nonzero status. If messageid is
in the database, the program printsthe pathname and exitssuccessfully. If no pathname exists, the program will print /dev/
227
null and exit successfully. Thiscan happen when an article hasbeen canceled, or if it hasbeen expired but itshistory isstill
retained. Thisisdefault behavior, which can be obtained by using the n flag.
If the q flag isused, then no message isdisplayed. The program will still exit with the appropriate exit status. If the e flag is
used, then gr ephi st or y will only print the filename of an existing article.
If the l flag isused, then the entire line from the history file will be displayed.
If the i flag isused, then gr ephi st or y will read a list of Message-IDson standard input, one per line. Leading and trailing
whitespace isignored, asare any malformed lines. It will print on standard output those Message-IDsthat are not found in
the history database. Thisflag isused in processing ihave control messages.
If the s flag isused, then gr ephi st or y will read a similar list from itsstandard input. It will print on standard output a list of
filenamesfor each article that isstill available. Thisflag isused in processing sendme control messages.
To specify a different value for the history file and database, use the f flag.
HISTORY
Written by Rich $alz (rsalz@uunet.uu.net) for InterNetNews.
SEE ALSO
dbz(3), history(5)
grodvi
grodviConvert groff output to TeX dvi format
SYNOPSIS
grodvi [ dv ][wn ][Fdi r ][f i l es ... ]
DESCRIPTION
grodvi isa driver for groff that producesdvi format. Normally, it should be run by groffTdvi. Thiswill run gtroffTdvi; it
will also input the macros/usr/lib/groff/tmac/tmac.dvi; if the input isbeing preprocessed with geqn, it will also input /usr/
lib/groff/font/devdvi/eqnchar.
The dvi file generated by grodvi can be printed by any correctly written dvi driver. The troff drawing primitivesare
implemented using the tpic version 2 specials. If the driver doesnot support these, the \D commandswill not produce any
output.
There isan additional drawing command available:
\DRdhdv Draw a rule (solid black rectangle), with one corner at the current position, and the diagonally
opposite corner at the current position +(dh,dv). Afterwards, the current position will be at the
opposite corner. Thisproducesa rule in the dvi file and so can be printed even with a driver that does
not support the tpic specials, unlike the other \D commands.
The groff command \Xanyt hi ng istranslated into the same command in the dvi file aswould be produced by \special{
anything } in TeX; anyt hi ng may not contain a newline.
Font filesfor grodvi can be created from tfm filesusing tfmtodit(1). The font description file should contain the following
additional commands:
internalname name The name of the tfm file (without the .tfm extension) isname.
checksum n The checksum in the tfm file isn.
designsize n The designsize in the tfm file isn.
These are automatically generated by tfmtodit.
grodvi
Part I: User Commands
228
In troff, the \N escape sequence can be used to accesscharactersby their position in the corresponding tfm file; all characters
in the tfm file can be accessed thisway.
OPTIONS
d Do not use tpic specialsto implement drawing commands. Horizontal and vertical lineswill be implemented by
rules. Other drawing commandswill be ignored.
v Print the version number.
wn Set the default line thicknessto n thousandthsof an em.
Fdi r Search directory di r /devdvi for font and device description files.
FILES
/usr/lib/groff/font/devdvi/DESC Device description file
/usr/lib/groff/font/devdvi/ F Font description file for font F
/usr/lib/groff/tmac/tmac.dvi Macrosfor use with grodvi
BUGS
dvi filesproduced by grodvi use a different resolution (57,816 unitsper inch) than those produced by TeX. Incorrectly
written driversthat assume the resolution used by TeX, rather than using the resolution specified in the dvi file, will not
work with grodvi.
When using the d option with boxed tables, vertical and horizontal linescan sometimesprotrude by one pixel. Thisisa
consequence of the way TeX requiresthat the heightsand widthsof rulesbe rounded.
SEE ALSO
tfmtodit(1), groff(1), gtroff(1), geqn(1), groff_out(5), groff_font(5), groff_char(7)
Groff Version 1.09 14
groff
groffFront end for the groff document formatting system
SYNOPSIS
groff [ tpeszaivhblCENRVXZ][wname ][Wname ][mname ][Fdi r ][Tdev ] [ ff am ][Mdi r ][dcs ][rcn ][nnum ]
[ol i st ][Par g ][f i l es ... ]
DESCRIPTION
groff isa front-end to the groff document formatting system. Normally, it runsthe gtroff program and a postprocessor
appropriate for the selected device. Available devicesare
ps For PostScript printersand previewers
dvi For TeX dvi format
X75 For a 75 dpi X11 previewer
X100 For a 100dpi X11 previewer
ascii For typewriter-like devices
latin1 For typewriter-like devicesusing the ISO Latin-1 character set.
The postprocessor to be used for a device isspecified by the postpro command in the device description file. Thiscan be
overridden with the X option.
The default device isps. It can optionally preprocesswith any of gpic, geqn, gtbl, grefer, or gsoelim.
229
Optionswithout an argument can be grouped behind a single . A filename of denotesthe standard input.
The grog command can be used to guessthe correct groff command to use to format a file.
OPTIONS
h Print a help message.
e Preprocesswith geqn.
t Preprocesswith gtbl.
p Preprocesswith gpic.
s Preprocesswith gsoelim.
R Preprocesswith grefer. No mechanism isprovided for passing argumentsto grefer because most grefer options
have equivalent commandsthat can be included in the file. See grefer(1) for more details.
v Make programsrun by groff print out their version number.
V Print the pipeline on stdout instead of executing it.
z Suppressoutput from gtroff. Only error messageswill be printed.
Z Do not postprocessthe output of gtroff. Normally, groff will automatically run the appropriate postprocessor.
Par g Passar g to the postprocessor. Each argument should be passed with a separate P option. Note that groff doesnot
prepend to ar g before passing it to the postprocessor.
l Send the output to a printer. The command used for thisisspecified by the print command in the device
description file.
Lar g Passar g to the spooler. Each argument should be passed with a separate L option. Note that groff doesnot
prepend to ar g before passing it to the postprocessor.
Tdev Prepare output for device dev . The default device isps.
X Preview with gxditview instead of using the usual postprocessor. Thisisunlikely to produce good resultsexcept
with Tps.
N Dont allow newlineswith eqn delimiters. Thisisthe same asthe N option in geqn.
The options a, b, i, C, E, wname, Wname, mname, ol i st , dcs , rcn, Fdi r , Mdi r , ff am, and nnum are described in
gtroff(1).
ENVIRONMENT
GROFF_COMMAND_PREFIX If thisisset X, then groff will run Xtroff instead of gtroff. Thisalso appliesto tbl, pic, eqn, refer,
and soelim. It doesnot apply to grops, grodvi, grotty, and gxditview.
GROFF_TMAC_PATH A colon-separated list of directoriesin which to search for macro files.
GROFF_TYPESETTER Default device.
GROFF_FONT_PATH A colon-separated list of directoriesin which to search for the devname directory.
PATH The search path for commandsexecuted by groff.
GROFF_TMPDIR The directory in which temporary fileswill be created. If thisisnot set and TMPDIR isset, temporary
fileswill be created in that directory. Otherwise, temporary fileswill be created in /tmp. The
grops(1) and grefer(1) commandscan create temporary files.
FILES
/usr/lib/groff/font/devname/DESC Device description file for device name.
/usr/lib/groff/font/devname/F Font file for font F of device name.
AUTHOR
JamesClark (jjc@jclark.com)
groff
Part I: User Commands
230
BUGS
Report bugsto bug-groff@prep.ai.mit.edu. Include a complete, self-contained example that will allow the bug to be
reproduced, and say which version of groff you are using.
COPYRIGHT
Copyright 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
groff isfree software; you can redistribute it or modify it under the termsof the GNU General Public License aspublished
by the Free Software Foundation; either version 2, or (at your option) any later version.
groff isdistributed in the hope that it will be useful, but without any warranty; without even the implied warranty of
merchantability or fitnessfor a particular purpose. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with groff; see the file COPYING. If not, write to
the Free Software Foundation, 675 MassAve, Cambridge, MA 02139, USA.
AVAILABILITY
The most recent released version of groff isalwaysavailable for anonymousftp from prep.ai.mit.edu (18.71.0.38) in the
directory pub/gnu.
SEE ALSO
grog(1), gtroff(1), gtbl(1), gpic(1), geqn(1), gsoelim(1), grefer(1), grops(1), grodvi(1), grotty(1), gxditview(1),
groff_font(5), grof_out(5), groff_ms(7), groff_me(7), groff_char(7)
Groff Version 1.09, 29 October 1992
grog
grogGuessoptionsfor groff command
SYNOPSIS
grog [ opt i on ...][f i l es ... ]
DESCRIPTION
grog readsf i l es and guesseswhich of the groff(1) optionse, man, me, mm, ms, p, s,and t are required for printing
f i l es, and printsthe groff command including those optionson the standard output. A filename of istaken to refer to the
standard input. If no filesare specified, the standard input will be read. Any specified optionswill be included in the printed
command. No space isallowed between optionsand their arguments. For example,
grog Tdvi paper.ms
will guessthe appropriate command to print paper.ms and then run it after adding the Tdvi option.
SEE ALSO
doctype(1), groff(1), gtroff(1), gtbl(1), gpic(1), geqn(1), gsoelim(1)
Groff Version 1.09 14
grops
gropsPostScript driver for groff
SYNOPSIS
grops [ glv ][bn ][cn ][wn ][Fdi r ][f i l es ... ]
231
DESCRIPTION
grops translatesthe output of GNU troff to PostScript. Normally, grops should be invoked by using the groff command
with a Tps option. If no filesare given, grops will read the standard input. A filename of will also cause grops to read the
standard input. PostScript output iswritten to the standard output. When grops isrun by groff, optionscan be passed to
grops by using the groff P option.
OPTIONS
bn Work around broken spoolersand previewers. Normally grops producesoutput that conformsthe Document
Structuring Conventionsversion 3.0. Unfortunately, some spoolersand previewerscant handle such output. The
value of n controlswhat grops doesto itsoutput acceptable to such programs. A value of 0 will cause grops not to
employ any workarounds. Add 1 if no %%BeginDocumentSetup and %%EndDocumentSetup commentsshould be
generated; thisisneeded for early versionsof TranScript that get confused by anything between the %%EndProlog
comment and the first %%Page comment. Add 2 if linesin included filesbeginning with %! should be stripped out;
thisisneeded for Sunspageview previewer. Add 4 if %%Page, %%Trailer, and %%EndProlog commentsshould be
stripped out of included files; thisisneeded for spoolersthat dont understand the %%BeginDocument and
%%EndDocument comments. Add 8 if the first line of the PostScript output should be %!PS-Adobe-2.0 rather than
%!PS-Adobe-3.0; thisisneeded when using SunsNewsprint with a printer that requirespage reversal. The default
value can be specified by a brokenn command in the DESC file. Otherwise, the default value is0.
cn Print n copiesof each page.
g Guessthe page length. ThisgeneratesPostScript code that guessesthe page length. The guesswill be correct only
if the imageable area isvertically centered on the page. Thisoption allowsyou to generate documentsthat can be
printed both on letter (8.511) paper and on A4 paper without change.
l Print the document in landscape format.
Fdi r Search the directory di r /devname for font and device description files; name isthe name of the device, usually ps.
wn Linesshould be drawn using a thicknessof n thousandthsof an em.
v Print the version number.
USAGE
There are stylescalled R, I, B, and BI mounted at font positions1 to 4. The fontsare grouped into families A, BM, C, H, HN, N,
P, and T having membersin each of these styles:
AR AvantGarde-Book
AI AvantGarde-BookOblique
AB AvantGarde-Demi
ABI AvantGarde-DemiOblique
BMR Bookman-Light
BMI Bookman-LightItalic
BMB Bookman-Demi
BMBI Bookman-DemiItalic
CR Courier
CI Courier-Oblique
CB Courier-Bold
CBI Courier-BoldOblique
HR Helvetica
HI Helvetica-Oblique
HB Helvetica-Bold
HBI Helvetica-BoldOblique
HNR Helvetica-Narrow
HNI Helvetica-Narrow-Oblique
grops
Part I: User Commands
232
HNB Helvetica-Narrow-Bold
HNBI Helvetica-Narrow-BoldOblique
NR NewCenturySchlbk-Roman
NI NewCenturySchlbk-Italic
NB NewCenturySchlbk-Bold
NBI NewCenturySchlbk-BoldItalic
PR Palatino-Roman
PI Palatino-Italic
PB Palatino-Bold
PBI Palatino-BoldItalic
TR Times-Roman
TI Times-Italic
TB Times-Bold
TBI Times-BoldItalic
There isalso the following font which isnot a member of a family:
ZCMI ZapfChancery-MediumItalic
There are also some special fontscalled SS and S. Zapf Dingbatsisavailable asZD and a reversed version of ZapfDingbats
(with symbolspointing in the opposite direction) isavailable asZDR; most charactersin these fontsare unnamed and must be
accessed using \N.
grops understandsvariousX commandsproduced using the \X escape sequence; grops will only interpret commandsthat
begin with a ps: tag.
\Xps:exec code Thisexecutesthe arbitrary PostScript commandsin code. The PostScript currentpoint will be set to
the position of the \nX command before executing code. The origin will be at the top left corner of
the page, and y coordinateswill increase down the page. A procedure u will be defined that converts
groff unitsto the coordinate system in effect. For example,
\Xps: exec \nx u 0 rlineto stroke
will draw a horizontal line one inch long. code may make changesto the graphicsstate, but any
changeswill persist only to the end of the page. A dictionary containing the definitionsspecified by
def and mdef will be on top of the dictionary stack. If your code addsdefinitionsto thisdictionary,
you should allocate space for them using \Xpsmdef n. Any definitionswill persist only until the end
of the page. If you use the \Y escape sequence with an argument that namesa macro, code can
extend over multiple lines. For example,
.nr x 1i
.de y
ps: exec
\nx u 0 rlineto
stroke
..
\Yy
isanother way to draw a horizontal line one inch long.
\Xps:f i l ename Thisisthe same asthe exec command except that the PostScript code isread from file name.
\Xps:def code Place a PostScript definition contained in code in the prologue. There should be at most one
definition per \X command. Long definitionscan be split over several \X commands; all the code
argumentsare simply joined together separated by newlines. The definitionsare placed in a
dictionary which isautomatically pushed on the dictionary stack when an exec command is
executed. If you use the \Y escape sequence with an argument that namesa macro, code can extend
over multiple lines.
233
\Xps:mdef ncode Like def, except that code may contain up to n definitions. grops needsto know how many
definitionscode containsso that it can create an appropriately sized PostScript dictionary to contain
them.
\Xps:importfile Import a PostScript graphic from file. The argumentsllx, lly, urx, and ury give the bounding box
llxllyurxurywidth of the graphic in the default PostScript coordinate system; they should all be integers; llx and lly
[height] are the x and y coordinatesof the lower-left corner of the graphic; urx and ury are the x and y
coordinatesof the upper-right corner of the graphic; wi dt h and hei ght are integersthat give the
desired width and height in groff unitsof the graphic. The graphic will be scaled so that it hasthis
width and height and translated so that the lower-left corner of the graphic islocated at the
position associated with \X command. If the height argument isomitted, it will be scaled uniformly
in the x and y directionsso that it hasthe specified width. Note that the contentsof the \X
command are not interpreted by troff; so vertical space for the graphic isnot automatically added,
and the width and height argumentsare not allowed to have attached scaling indicators. If the
PostScript file complieswith the Adobe Document Structuring Conventionsand containsa
%%BoundingBox comment, then the bounding box can be automatically extracted from within groff
by using the sy request to run the psbb command.
The mps macros(which are automatically loaded when grops isrun by the groff command) include a PSPIC macro that
allowsa picture to be easily imported. Thishasthe format:
.PSPIC file [ L j -R j I n ][width [ height ]]
f i l e isthe name of the file containing the illustration; wi dt h and hei ght give the desired width and height of the graphic. The
wi dt h and hei ght argumentsmay have scaling indicatorsattached; the default scaling indicator isi. Thismacro will scale the
graphic uniformly in the x and y directionsso that it isno more than wi dt h wide and hei ght high. By default, the graphic will
be horizontally centered. The L and R cause the graphic to be left-aligned and right-aligned, respectively. The I option
causesthe graphic to be indented by n.
\Xps: invis, \Xps: endinvis No output will be generated for text and drawing commandsthat are bracketed with
these \X commands. These commandsare intended for use when output from troff will
be previewed before being processed with grops; if the previewer isunable to display
certain charactersor other constructs, then other substitute charactersor constructscan
be used for previewing by bracketing them with these \X commands.
For example, gxditview isnot able to display a proper \(em character because the standard X11 fontsdo not provide it; this
problem can be overcome by executing the following request:
.char \(em \Xps: invis\
\Z\v-.25m\h.05m\Dl .9m 0'\h.05m\
\Xps: endinvis\(em
In thiscase, gxditview will be unable to display the \(em character and will draw the line, whereasgrops will print the \(em
character and ignore the line.
The input to grops must be in the format output by gtroff(1). Thisisdescribed in groff_out(1). In addition, the device and
font description filesfor the device used must meet certain requirements. The device and font description filessupplied for
ps device meet all these requirements. afmtodit(1) can be used to create font filesfrom AFM files. The resolution must be an
integer multiple of 72 timesthe sizescale. The ps device usesa resolution of 72000 and a sizescale of 1000. The device
description file should contain a command:
paperlengthn
which saysthat output should be generated that issuitable for printing on a page whose length isn machine units. Each font
description file must contain a command:
internalnamepsname
which saysthat the PostScript name of the font ispsname. It may also contain a command:
encodingenc f i l e
grops
Part I: User Commands
234
which saysthat the PostScript font should be reencoded using the encoding described in enc_f i l e; thisfile should consist of a
sequence of linesof the form:
pschar code
where pschar isthe PostScript name of the character, and code isitsposition in the encoding expressed asa decimal integer.
The code for each character given in the font file must correspond to the code for the character in encoding file, or to the
code in the default encoding for the font if the PostScript font isnot to be reencoded. Thiscode can be used with the \N
escape sequence in troff to select the character, even if the character doesnot have a groff name. Every character in the font
file must exist in the PostScript font, and the widthsgiven in the font file must match the widthsused in the PostScript font.
grops will assume that a character with a groff name of space isblank (makesno markson the page); it can make use of such
a character to generate more efficient and compact PostScript output.
grops can automatically include the downloadable fontsnecessary to print the document. Any downloadable fontswhich
should, when required, be included by grops must be listed in the file /usr/lib/groff/font/devps/download; thisshould
consist of linesof the form:
f ont f i l ename
where f ont isthe PostScript name of the font, and f i l ename isthe name of the file containing the font; linesbeginning with #
and blank linesare ignored; fieldsmay be separated by tabsor spaces; f i l ename will be searched for using the same mecha-
nism that isused for groff font metric files. The download file itself will also be searched for using thismechanism.
If the file containing a downloadable font or imported document conformsto the Adobe Document Structuring Conven-
tions, then grops will interpret any commentsin the filessufficiently to ensure that itsown output isconforming. It will also
supply any needed font resourcesthat are listed in the download file aswell asany needed file resources. It isalso able to
handle interresource dependencies. For example, suppose that you have a downloadable font called Garamond, and also a
downloadable font called Garamond-Outline that dependson Garamond (typically, it would be defined to copy Garamonds
font dictionary, and change the PaintType), then it isnecessary for Garamond to appear before Garamond-Outline in the
PostScript document. grops will handle thisautomatically provided that the downloadable font file for Garamond-Outline
indicatesitsdependence on Garamond by meansof the Document Structuring Conventions, for example by beginning with
the following lines:
%!PS-Adobe-3.0 Resource-Font
%%DocumentNeededResources: font Garamond
%%EndComments
%%IncludeResource: font Garamond
In thiscase, both Garamond and Garamond-Outline would need to be listed in the download file. A downloadable font
should not include itsown name in a %%DocumentSuppliedResources comment.
grops will not interpret %%DocumentFonts comments.
The %%DocumentNeededResources, %%DocumentSuppliedResources, %%IncludeResource, %%BeginResource, and %%EndResource
comments(or possibly the old %%DocumentNeededFonts, %%DocumentSuppliedFonts, %%IncludeFont, %%BeginFont, and %%EndFont
comments) should be used.
FILES
/usr/lib/groff/font/devps/DESC Device description file
/usr/lib/groff/font/devps/F Font description file for font F
/usr/lib/groff/font/devps/download List of downloadable fonts.
/usr/lib/groff/font/devps/text.enc Encoding used for text fonts
/usr/lib/groff/tmac/tmac.ps Macrosfor use with grops; automatically loaded by troffrc
/usr/lib/groff/tmac/tmac.pspic Definition of PSPIC macro, automatically loaded by tmac.ps
/usr/lib/groff/tmac/tmac.psold Macrosto disable use of charactersnot present in older PostScript printers;
automatically loaded by tmac.ps
/usr/lib/groff/tmac/tmac.psnew Macrosto undo the effect of tmac.psold
/tmp/gropsXXXXXX Temporary file
235
SEE ALSO
afmtodit(1), groff(1), gtroff(1), psbb(1), groff_out(5), groff_font(5), groff_char(7)
Groff Version 1.09, 14 February1995
grotty
grottygroff driver for typewriter-like devices
SYNOPSIS
grotty [ hfbuodBUv ][Fdi r ][f i l es ... ]
DESCRIPTION
grotty translatesthe output of GNU troff into a form suitable for typewriter-like devices. Normally, grotty should invoked
by using the groff command with a Tascii or Tlatin1 option. If no filesare given, grotty will read the standard input. A
filename of will also cause grotty to read the standard input. Output iswritten to the standard output.
Normally, grotty printsa bold character cusing the sequence c BACKSPACE c and an italic character cby the sequence
_BACKSPACE c . These sequencescan be displayed on a terminal by piping through ul(1). Pagerssuch asmore(1) or less(1)
are also able to display these sequences. Use either B or U when piping into less(1); use b when piping into more(1). There
isno need to filter the output through col(1) since grotty never outputsreverse line feeds.
The font description file may contain a command:
internalnamen
where n isa decimal integer. If the 01 bit in n isset, then the font will be treated asan italic font; if the 02 bit isset, then it
will be treated asa bold font. The code field in the font description field givesthe code that will be used to output the
character. Thiscode can also be used in the \N escape sequence in troff.
OPTIONS
Fdi r Search the directory di r /devname for font and device description files; name isthe name of the device, usually ascii
or latin1.
h Use horizontal tabsin the output. Tabsare assumed to be set every 8 columns.
f Use form feedsin the output. A form feed will be output at the end of each page that hasno output on itslast
line.
b Suppressthe use of overstriking for bold characters.
u Suppressthe use of underlining for italic characters.
B Use only overstriking for bold-italic characters.
U Use only underlining for bold-italic characters.
o Suppressoverstriking (other than for bold or underlined characters).
d Ignore all \D commands. Without this, grotty will render \Dl ... commandsthat have at least one zero
argument (and so are either horizontal or vertical) using , |, and + characters.
v Print the version number.
FILES
/usr/lib/groff/font/devascii/DESC Device description file for ascii device.
/usr/lib/groff/font/devascii/F Font description file for font F of ascii device.
/usr/lib/groff/font/devlatin1/DESC Device description file for latin1 device.
/usr/lib/groff/font/devlatin1/F Font description file for font F of latin1 device.
/usr/lib/groff/tmac/tmac.tty Macrosfor use with grotty.
/usr/lib/groff/tmac/tmac.tty-char Additional kludgy character definitionsfor use with grotty.
grotty
Part I: User Commands
236
BUGS
grotty isintended only for simple documents.
There isno support for fractional horizontal or vertical motions.
There isno support for \D commandsother than horizontal and vertical lines.
Charactersabove the first line (that is, with a vertical position of 0) cannot be printed.
SEE ALSO
groff(1), gtroff(1), groff_out(5), groff_font(5), groff_char(7), ul(1), more(1), less(1)
Groff Version1.09, 14 February1995
gsoelim
gsoelimInterpret .so requestsin groff input
SYNOPSIS
gsoelim [ Cv ][f i l es ... ]
DESCRIPTION
gsoelim readsf i l es and replaceslinesof the form
.sofile
by the contentsof f i l e. It isuseful if filesincluded with so need to be preprocessed. Normally, gsoelim should be invoked
with the s option of groff.
OPTIONS
C Recognize .so even when followed by a character other than space or newline
v Print the version number
SEE ALSO
groff(1)
Groff Version1.09, 15 September 1992
gtbl
gtblFormat tablesfor troff
SYNOPSIS
gtbl [ Cv ][f i l es ... ]
DESCRIPTION
Thismanual page describesthe GNU version of tbl, which ispart of the groff document formatting system. tbl compiles
descriptionsof tablesembedded within troff input filesinto commandsthat are understood by troff. Normally, it should
be invoked using the t option of groff. It ishighly compatible with UNIX tbl. The output generated by GNU tbl cannot
be processed with UNIX troff; it must be processed with GNU troff. If no filesare given on the command line, the
standard input will be read. A filename of will cause the standard input to be read.
237
OPTIONS
C Recognize .TS and .TE even when followed by a character other than space or newline
v Print the version number
USAGE
Only the differencesbetween GNU tbl and UNIX tbl are described here.
Normally, tbl attemptsto prevent undesirable breaksin the table by using diversions. Thiscan sometimesinteract badly
with macro packages own use of diversions, when footnotes, for example, are used. The nokeep option tellstbl not to try to
prevent breaksin thisway.
The decimalpoint option specifiesthe character to be recognized asthe decimal point character in place of the default period.
It takesan argument in parentheses, which must be a single character, asfor the tab option.
The f format modifier can be followed by an arbitrary length font name in parentheses.
There isa d format modifier that meansthat a vertically spanning entry should be aligned at the bottom of itsrange.
There isno limit on the number of columnsin a table, nor any limit on the number of text blocks. All the linesof a table are
considered in deciding column widths, not just the first 200. Table continuation (.T&) linesare not restricted to the first 200
lines.
Numeric and alphabetic itemsmay appear in the same column.
Numeric and alphabetic itemsmay span horizontally.
tbl usesregister, string, macro and diversion namesbeginning with 3. When using tbl, you should avoid using any names
beginning with a 3.
BUGS
You should use .TSH/.TH in conjunction with a supporting macro package for all multipage boxed tables. If there isno header
that you want to appear at the top of each page of the table, place the .TH line immediately after the format section. Do not
enclose a multipage table within keep/release macros, or divert it in any other way.
A text block within a table must be able to fit on one page.
The bp request cannot be used to force a page-break in a multipage table. Instead, define BP asfollows:
.de BP
.ie \\n(.z .bp \\$1
.el \!.BP \\$1
..
and use BP instead of bp.
SEE ALSO
groff(1), gtroff(1)
Groff Version 1.09, 1 April 1993
gtroff
gtroffFormat documents
SYNOPSIS
gtroff [abivzCER] [w name] [W name] [d cs] [f f am] [m name] [n num] [o l i st ] [r cn] [T name] [F di r ] [M
di r ] [nf i l es. . . n]
gtroff
Part I: User Commands
238
DESCRIPTION
Thismanual page describesthe GNU version of troff, which ispart of the groff document formatting system. It ishighly
compatible with UNIX troff. Usually, it should be invoked using the groff command, which will also run preprocessorsand
postprocessorsin the appropriate order and with the appropriate options.
OPTIONS
a Generate an ASCII approximation of the typeset output.
b Print a backtrace with each warning or error message. Thisbacktrace should help track down the cause of
the error. The line numbersgiven in the backtrace may not alwayscorrect: troffsidea of line numbers
getsconfused by as or am requests.
i Read the standard input after all the named input fileshave been processed.
v Print the version number.
wname Enable warning name. Available warningsare described in the Warnings subsection asfollows. Multiple
w optionsare allowed.
Wname Inhibit warning name. Multiple W optionsare allowed.
E Inhibit all error messages.
z Suppressformatted output.
C Enable compatibility mode.
dcs, dname=s Define c or name to be a string s; c must be a one-letter name.
ff am Use f am asthe default font family.
mname Read in the file tmac.name. Normally, thiswill be searched for in /usr/lib/groff/tmac.
R Dont load troffrc.
nnum Number the first page num.
ol i st Output only pagesin l i st , which isa comma-separated list of page ranges; n meansprint page n, mn
meansprint every page between m and n, n meansprint every page up to n, n meansprint every page
from n. Troff will exit after printing the last page in the list.
rcn, rname=n Set number register c or name to n; c must be a one-character name; n can be any troff numeric expression.
Tname Prepare output for device name, rather than the default ps.
Fdi r Search di r for subdirectoriesdevname (name isthe name of the device) for the DESC file and font filesbefore
the normal /usr/lib/groff/font.
Mdi r Search directory di r for macro filesbefore the normal /usr/lib/groff/tmac.
USAGE
Only the featuresnot in UNIX troff are described here.
LONG NAMES
The namesof number registers, fonts, strings/macros/diversions, special characterscan be of any length. In escape
sequences, where you can use (xx for a two-character name, you can use [xxx] for a name of arbitrary length:
\[xxx] Print the special character called xxx.
\f[xxx] Set font xxx.
\*[xxx] Interpolate string xxx.
\n[xxx] Interpolate number register xxx .
FRACTIONAL POINT SIZES
A scaled point isequal to 1/sizescale points, where sizescale isspecified in the DESC file (1 by default.) There isa new scale
indicator z that hasthe effect of multiplying by sizescale. Requestsand escape sequencesin troff interpret argumentsthat
represent a point size asbeing in unitsof scaled points, but they evaluate each such argument using a default scale indicator
239
of z. Argumentstreated in thisway are the argument to the ps request, the third argument to the cs request, the second and
fourth argumentsto the tkf request, the argument to the \H escape sequence, and those variantsof the \s escape sequence
that take a numeric expression astheir argument.
For example, suppose sizescale is1,000; then a scaled point will be equivalent to a millipoint; the request .ps 10.25 is
equivalent to .ps 10.25z, and so setsthe point size to 10,250 scaled points, which isequal to 10.25 points.
The number register \n(.s returnsthe point size in pointsasdecimal fraction. There isalso a new number register \n[.ps]
that returnsthe point size in scaled points.
It would make no sense to use the z scale indicator in a numeric expression whose default scale indicator wasneither u nor z,
and so troff disallowsthis. Similarly, it would make no sense to use a scaling indicator other than z or u in a numeric
expression whose default scale indicator wasz, and so troff disallowsthisaswell.
There isalso new scale indicator s that multipliesby the number of unitsin a scaled point. So, for example, \n[.ps]s isequal
to 1m. Be sure not to confuse the s and z scale indicators.
NUMERIC EXPRESSIONS
Spacesare permitted in a number expression within parentheses.
M indicatesa scale of hundredthsof an em.
e1>?e2 The maximum of e1 and e2.
e1<?e2 The minimum of e1 and e2.
(c;e) Evaluate e using c asthe default scaling indicator. If c ismissing, ignore scaling indicatorsin the evaluation
of e.
NEW ESCAPE SEQUENCES
\Aanyt hi ng Thisexpandsto 1 or 0 according to whether anyt hi ng isor isnot acceptable asthe name of a string,
macro, diversion, number register, environment, or font. It will return 0 if anyt hi ng isempty. This
isuseful if you want to look up user input in some sort of associative table.
\Cxxx Typeset character named xxx. Normally it ismore convenient to use \[xxx]. But \C hasthe
advantage that it iscompatible with recent versionsof UNIX and isavailable in compatibility
mode.
\E Thisisequivalent to an escape character, but itsnot interpreted in copy mode. For example,
stringsto start and end superscripting could be defined like this:
.ds { \v.3m\s\En[.s]*6u/10u
.ds { \s0\v.3m
The use of \E ensuresthat these definitionswill work even if \*f getsinterpreted in copy-mode (for example, by being used
in a macro argument).
\Nn Typeset the character with code n in the current font. n can be any integer. Most devicesonly have
characterswith codesbetween 0 and 255. If the current font doesnot contain a character with that
code, special fontswill not be searched. The \N escape sequence can be conveniently used on
conjunction with the char request:
.char \[phone] \f(ZDnN37'
The code of each character isgiven in the fourth column in the font description file after the
charset command. It ispossible to include unnamed charactersin the font description file by using
a name of ; the \N escape sequence isthe only way to use these.
\Rnamen Thishasthe same effect as.nrnamen
\s(nn Set the point size to nn points; nn must be exactly two digits.
\s[n], \sn Set the point size to n scaled points; n isa numeric expression with a default scale indicator of z.
\Vx\ V(xx \ V[xxx] Interpolate the contentsof the environment variable xxx, asreturned by getenv(3). \V isinterpreted
in copy-mode.
gtroff
Part I: User Commands
240
\Yx\ Y(xx \ Y[xxx] Thisisapproximately equivalent to \X\*[xxx ]. However, the contentsof the string or macro xxx
are not interpreted; also, it ispermitted for xxx to have been defined asa macro and thuscontain
newlines(it isnot permitted for the argument to \X to contain newlines). The inclusion of newlines
requiresan extension to the UNIX troff output format and will confuse driversthat do not know
about thisextension.
\Zanyt hi ng Print anything and then restore the horizontal and vertical position; anyt hi ng may not contain tabs
or leaders.
\$0 The name by which the current macro wasinvoked. The als request can make a macro have more
than one name.
\$* In a macro, the concatenation of all the argumentsseparated by spaces.
\$@ In a macro, the concatenation of all the argumentswith each surrounded by double quotes, and
separated by spaces.
\$( nn, \$[ nnn ] In a macro, thisgivesthe nnth or nnnth argument. Macroscan have an unlimited number of
arguments.
\?anyt hi ng\ ? When used in a diversion, thiswill transparently embed anyt hi ng in the diversion. anyt hi ng isread
in copy mode. When the diversion isreread, anyt hi ng will be interpreted. anyt hi ng may not contain
newlines; use \! if you want to embed newlinesin a diversion. The escape sequence \? isalso
recognized in copy mode and turned into a single internal code; it isthiscode that terminates
anyt hi ng. Thus
.nr x 1
.nf
.di d
\?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
.di
.nr x 2
.di e
.d
.di
.nr x 3
.di f
.e
.di
.nr x 4
.f
will print 4.
\/ Thisincreasesthe width of the preceding character so that the spacing between that character and
the following character will be correct if the following character isa Roman character. For example,
if an italic f isimmediately followed by a Roman right parenthesis, then in many fontsthe top right
portion of the f will overlap the top left of the right parenthesis, producing f), which isugly.
Inserting \/ producesand avoidsthisproblem. It isa good idea to use thisescape sequence
whenever an italic character isimmediately followed by a Roman character without any intervening
space.
\, Thismodifiesthe spacing of the following character so that the spacing between that character and
the preceding character will correct if the preceding character isa Roman character. For example,
inserting \, between the parenthesisand the f changesto (f. It isa good idea to use thisescape
sequence whenever a Roman character isimmediately followed by an italic character without any
intervening space.
\) Like \& except that it behaveslike a character declared with the cflags request to be transparent for
the purposesof end-of-sentence recognition.
\ Thisproducesan unbreakable space that stretcheslike a normal interword space when a line is
adjusted.
\# Everything up to and including the next newline isignored. Thisisinterpreted in copy mode. This
islike \% except that \% doesnot ignore the terminating newline.
241
NEW REQUESTS
.alnxx yy Create an aliasxx for number register object named yy. The new name and the old name will be
exactly equivalent. If yy isundefined, a warning of type reg will be generated, and the request will
be ignored.
.alsxx yy Create an aliasxx for request, string, macro, or diversion object named yy. The new name and the
old name will be exactly equivalent (it issimilar to a hard rather than a soft link). If yy isunde-
fined, a warning of type mac will be generated, and the request will be ignored. The de, am, di, da,
ds, and as requestsonly create a new object if the name of the macro, diversion, or string diversion
iscurrently undefined or if it isdefined to be a request; normally, they modify the value of an
existing object.
.asciifyxx Thisrequest only existsin order to make it possible to make certain grosshackswork with GNU
troff. It unformatsthe diversion xx in such a way that ASCII charactersthat were formatted and
diverted into xx will be treated like ordinary input characterswhen xx isreread. For example, this:
.tr @.
.di x
@nr\n\1
.br
.di
.tr @@
.asciify x
.x
will set register n to 1.
.backtrace Print a backtrace of the input stack on stderr.
.break Break out of a while loop. See also the while and continue requests. Be sure not to confuse thiswith
the br request.
.cflagsnc1c2. . . Charactersc1, c2, ... have propertiesdetermined by n, which isORed from the following.
1 The character endssentences. (Initially, characters.?! have thisproperty.)
2 Linescan be broken before the character (initially, no charactershave thisproperty); a line will not
be broken at a character with thisproperty unlessthe characterson each side both have nonzero
hyphenation codes.
4 Linescan be broken after the character (initially, characters\(hy\(em have thisproperty); a line
will not be broken at a character with thisproperty unlessthe characterson each side both have
nonzero hyphenation codes.
8 The character overlapshorizontally (initially, characters\(ul\(rn\(ru have thisproperty).
16 The character overlapsvertically (initially, character \(br hasthisproperty).
32 An end-of-sentence character followed by any number of characterswith thisproperty will be
treated asthe end of a sentence if followed by a newline or two spaces; in other words, the character
istransparent for the purposesof end-of-sentence recognition; thisisthe same ashaving a zero
space factor in TeX (initially, characters)]*\(dg\(rq have thisproperty).
.charcst r i ng Define character c to be st r i ng. Every time character c needsto be printed, st r i ng will be processed
in a temporary environment and the result will be wrapped up into a single object. Compatibility
mode will be turned off and the escape character will be set to \ while st r i ng isbeing processed.
Any emboldening, constant spacing, or track kerning will be applied to thisobject rather than to
individual charactersin st r i ng. A character defined by thisrequest can be used just like a normal
character provided by the output device. In particular, other characterscan be translated to it with
the tr request; it can be made the leader character by the lc request; repeated patternscan be drawn
with the character by using the \l and \L escape sequences; wordscontaining the character can be
hyphenated correctly, if the hcode request isused to give the character a hyphenation code. There is
a special antirecursion feature: Use of character within the charactersdefinition will be handled
like normal charactersnot defined with char. A character definition can be removed with the rchar
request.
gtroff
Part I: User Commands
242
.chopxx Chop the last character off macro, string, or diversion xx. Thisisuseful for removing the newline
from the end of diversionsthat are to be interpolated asstrings.
.closest r eam Close the stream named st r eam; st r eam will no longer be an acceptable argument to the write
request. See the open request.
.continue Finish the current iteration of a while loop. See also the while and break requests.
.cpn If n isnonzero or missing, enable compatibility mode; otherwise, disable it. In compatibility mode,
long namesare not recognized, and the incompatibilitiescaused by long namesdo not arise.
.doxxx Interpret . xxx with compatibility mode disabled. For example, .do fam T would have the same
effect as.fam T except that it would work even if compatibility mode had been enabled. Note that
the previouscompatibility mode isrestored before any filessourced by xxx are interpreted.
.famxx Set the current font family to xx. The current font family ispart of the current environment. See
the description of the sty request for more information on font families.
.fspecialf s1s2 . . . When the current font isf , fontss1, s2, ... will be special; that is, they will searched for
charactersnot in the current font. Any fontsspecified in the special request will be searched after
fontsspecified in the fspecial request.
.ftrf g Translate font f to g. Whenever a font named f isreferred to in \f escape sequence, or in the ft,
ul, bd, cs, tkf, special, fspecial, fp, or sty requests, font g will be used. If g ismissing, or equal to
f , then font f will not be translated.
.hcodec1code1c2code2. . . Set the hyphenation code of character c1 to code1 and that of c2 to code2. A hyphenation code must
be a single input character (not a special character) other than a digit or a space. Initially, each
lowercase letter hasa hyphenation code, which isitself, and each uppercase letter hasa hyphenation
code which isthe lowercase version of itself. See also the hpf request.
.hlal ang Set the current hyphenation language to l ang. Hyphenation exceptionsspecified with the hw
request and hyphenation patternsspecified with the hpf request are both associated with the
current hyphenation language. The hla request isusually invoked by the troffrc file.
.hlmn Set the maximum number of consecutive hyphenated linesto n. If n isnegative, there isno
maximum. The default value is1. Thisvalue isassociated with the current environment. Only
linesoutput from an environment count towardsthe maximum associated with that environment.
Hyphensresulting from \% are counted; explicit hyphensare not.
.hpff i l e Read hyphenation patternsfrom f i l e; thiswill be searched for in the same way that tmac.name is
searched for when the mname option isspecified. It should have the same format asthe argument to
the \patternsprimitive in TeX; the lettersappearing in thisfile are interpreted ashyphenation
codes. A % character in the patternsfile introducesa comment that continuesto the end of the line.
The set of hyphenation patternsisassociated with the current language set by the hla request. The
hpf request isusually invoked by the troffrc file.
.hymn Set the hyphenat i on margin to n: when the current adjustment mode isnot b, the line will not be
hyphenated if the line isno more than n short. The default hyphenation margin is0. The default
scaling indicator for thisrequest ism. The hyphenation margin isassociated with the current
environment. The current hyphenation margin isavailable in the \n[.hym] register.
.hysn Set the hyphenat i on space to n: when the current adjustment mode isb, dont hyphenate the line if
the line can be justified by adding no more than n extra space to each word space. The default
hyphenation space is0. The default scaling indicator for thisrequest ism. The hyphenation space is
associated with the current environment. The current hyphenation space isavailable in the
\n[.hys] register.
.kernn If n isnonzero or missing, enable pairwise kerning; otherwise, disable it.
.msof i l e The same asthe so request except that f i l e issearched for in the same way that tmac.name is
searched for when the mname option isspecified.
.nroff Make the n built-in condition true and the t built-in condition false. Thiscan be reversed using
the troff request.
.openst r eamf i l ename Open f i l ename for writing and associate the stream named st r eam with it. See also the close and
write requests.
243
.openast r eamf i l ename Like open, but if f i l ename exists, append to it instead of truncating it.
.pnr Print the namesand contentsof all currently defined number registerson stderr.
.psocommand Thisbehaveslike the so request except that input comesfrom the standard output of command.
.ptr Print the namesand positionsof all traps(not including input line trapsand diversion traps) on
stderr. Empty slotsin the page trap list are printed aswell, because they can affect the priority of
subsequently planted traps.
.rcharc1c2... Remove the definitionsof charactersc1, c2, ... Thisundoesthe effect of a char request.
.rj, .rjn Right justify the next n input lines. Without an argument, right justify the next input line. The
number of linesto be right justified isavailable in the \n[.rj] register. Thisimplicitly does.ce0.
The ce request implicitly does.rj0.
.rnnxxyy Rename number register xx to yy.
.shcc Set the soft hyphen character to c. If c isomitted, the soft hyphen character will be set to the
default \(hy. The soft hyphen character isthe character that will be inserted when a word is
hyphenated at a line break. If the soft hyphen character doesnot exist in the font of the character
immediately preceding a potential break point, then the line will not be broken at that point.
Neither definitions(specified with the char request) nor translations(specified with the tr request)
are considered when finding the soft hyphen character.
.shiftn In a macro, shift the argumentsby n positions: argument i becomesargument i n; arguments1 to n
will no longer be available. If n ismissing, argumentswill be shifted by 1. Shifting by negative
amountsiscurrently undefined.
.specials1s2... Fontss1, s2 are special and will be searched for charactersnot in the current font.
.stynf Associate style f with font position n. A font position can be associated either with a font or with a
style. The current font isthe index of a font position and so isalso either a font or a style. When it
isa style, the font that isactually used isthe font the name of which isthe concatenation of the
name of the current family and the name of the current style. For example, if the current font is1
and font position 1 isassociated with style R and the current font family isT, then font TR will be
used. If the current font isnot a style, then the current family isignored. When the requestscs, bd,
tkf, uf, or fspecial are applied to a style, then they will instead be applied to the member of the
current family corresponding to that style. The default family can be set with the f option. The
styles command in the DESC file controlswhich font positions(if any) are initially associated with
stylesrather than fonts.
.tkff s1n1s2n2 Enable track kerning for font f . When the current font isf , the width of every character will be
increased by an amount between n1 and n2; when the current point size islessthan or equal to s1,
the width will be increased by n1; when it isgreater than or equal to s2, the width will be increased
by n2; when the point size isgreater than or equal to s1 and lessthan or equal to s2, the increase in
width isa linear function of the point size.
.trff i l ename Transparently output the contentsof file f i l ename. Each line isoutput asit would be were it
preceded by \!; however, the linesare not subject to copy-mode interpretation. If the file doesnot
end with a newline, then a newline will be added. For example, you can define a macro x
containing the contentsof file f , using
.dix
.trff
.di
Unlike with the cf request, the file cannot contain characterssuch asNUL that are not legal troff
input characters.
.trnt abcd Thisisthe same asthe tr request except that the translationsdo not apply to text that istranspar-
ently throughput into a diversion with \!. For example,
.tr ab
.di x
\!.tm a
gtroff
Part I: User Commands
244
.di
.x
will print b; if trnt isused instead of tr, it will print a.
.troff Make the n built-in condition false, and the t built-in condition true. Thisundoesthe effect of the
nroff request.
.vptn Enable vertical position trapsif n isnonzero, disable them otherwise. Vertical position trapsare
trapsset by the wh or dt requests. Trapsset by the it request are not vertical position traps. The
parameter that controlswhether vertical position trapsare enabled isglobal. Initially, vertical
position trapsare enabled.
.warnn Control warnings. n isthe sum of the numbersassociated with each warning that isto be enabled;
all other warningswill be disabled. The number associated with each warning islisted in the
Warnings subsection. For example, .warn 0 will disable all warnings, and .warn 1 will disable all
warningsexcept that about missing characters. If n isnot given, all warningswill be enabled.
.whilecanyt hi ng While condition c istrue, accept anyt hi ng asinput; c can be any condition acceptable to an if
request; anyt hi ng can comprise multiple linesif the first line startswith \{ and the last line ends
with \}. See also the break and continue requests.
.writest r eamanyt hi ng Write anyt hi ng to the stream named st r eam. st r eam must previously have been the subject of an
open request. anyt hi ng isread in copy mode; a leading will be stripped.
EXTENDED REQUESTS
.cff i l ename When used in a diversion, thiswill embed in the diversion an object which, when reread, will cause
the contentsof f i l ename to be transparently copied through to the output. In UNIX troff, the
contentsof f i l ename are immediately copied through to the output regardlessof whether there isa
current diversion; thisbehavior isso anomalousthat it must be considered a bug.
.evxx If xx isnot a number, thiswill switch to a named environment called xx. The environment should
be popped with a matching ev request without any arguments, just asfor numbered environments.
There isno limit on the number of named environments; they will be created the first time that
they are referenced.
.fpnf1f 2 The fp request hasan optional third argument. Thisargument givesthe external name of the font,
which isused for finding the font description file. The second argument givesthe internal name of
the font, which isused to refer to the font in troff after it hasbeen mounted. If there isno third
argument, then the internal name will be used asthe external name. Thisfeature allowsyou to use
fontswith long namesin compatibility mode.
.ssmn When two argumentsare given to the ss request, the second argument givesthe sentence space size.
If the second argument isnot given, the sentence space size will be the same asthe word space size.
Like the word space size, the sentence space isin unitsof one twelfth of the spacewidth parameter
for the current font. Initially, both the word space size and the sentence space size are 12. The
sentence space size isused in two circumstances: If the end of a sentence occursat the end of a line
in fill mode, then both an interword space and a sentence space will be added; if two spacesfollow
the end of a sentence in the middle of a line, then the second space will be a sentence space. Note
that the behavior of UNIX troff will be exactly that exhibited by GNU troff if a second argument
isnever given to the ss request. In GNU troff, asin UNIX troff, you should alwaysfollow a
sentence with either a newline or two spaces.
.tan1n2...nnTr 1r2...rn Set tabsat positionsn1, n2,...,nn and then set tabsat nn+r 1, nn+r 2,...., nn+r n and then at
nn+r n+r 1, nn+r n+r 2,..., nn+r n+r n, and so on. For example, .ta T .5i will set tabsevery half an
inch.
245
\n[.fam] The current font family. Thisisa string-valued register.
\n[.fp] The number of the next free font position.
\n[.g] Always1. Macrosshould use thisto determine whether they are running under GNU troff.
\n[.hla] The current hyphenation language asset by the hla request.
\n[.hlc] The number of immediately preceding consecutive hyphenated lines.
\n[.hlm] The maximum allowed number of consecutive hyphenated lines, asset by the hlm request.
\n[.hy] The current hyphenation flags(asset by the hy request.)
\n[.hym] The current hyphenation margin (asset by the hym request.)
\n[.hys] The current hyphenation space (asset by the hys request.)
\n[.in] The indent that appliesto the current output line.
\n[.kern] 1 if pairwise kerning isenabled, 0 otherwise.
\n[.lg] The current ligature mode (asset by the lg request.)
\n[.ll] The line length that appliesto the current output line.
\n[.lt] The title length asset by the lt request.
\n[.ne] The amount of space that wasneeded in the last ne request that caused a trap to be sprung. Useful in
conjunction with the \n[.trunc] register.
\n[.pn] The number of the next page: either the value set by a pn request, or the number of the current page
plus1.
\n[.ps] The current pointsize in scaled points.
\n[.psr] The last requested pointsize in scaled points.
\n[.rj] The number of linesto be right-justified asset by the rj request.
\n[.sr] The last requested pointsize in pointsasa decimal fraction. Thisisa string-valued register.
\n[.tabs] A string representation of the current tab settingssuitable for use asan argument to the ta request.
\n[.trunc] The amount of vertical space truncated by the most recently sprung vertical position trap, or, if the trap
wassprung by an ne request, minusthe amount of vertical motion produced by the ne request. In other
words, at the point a trap issprung, it representsthe difference of what the vertical position would have
been but for the trap, and what the vertical position actually is. Useful in conjunction with the \n[.ne]
register.
\n[.ss] These give the valuesof the parametersset by the first and second argumentsof the ss request.
\n[.sss]
\n[.vpt] 1 if vertical position trapsare enabled, 0 otherwise.
\n[.warn] The sum of the numbersassociated with each of the currently enabled warnings. The number associated
with each warning islisted in the Warnings subsection.
\n(.x The major version number. For example, if the version number is1.03 then \n(.x will contain 1.
\n(.y The minor version number. For example, if the version number is1.03 then \n(.y will contain 03.
gtroff
Part I: User Commands
246
The following registersare set by the \w escape sequence:
\n[rst]
\n[rsb] Like the st and sb registers, but takesaccount of the heightsand depthsof characters.
\n[ssc] The amount of horizontal space (possibly negative) that should be added to the last character before a
subscript.
\n[skw] How far to right of the center of the last character in the \w argument, the center of an accent from a
roman font should be placed over that character.
The following read/write number registersare available:
\n[systat] The return value of the system() function executed by the last sy request.
\n[slimit] If greater than 0, the maximum number of objectson the input stack. If lessthan or equal to 0, there isno
limit on the number of objectson the input stack. With no limit, recursion can continue until virtual
memory isexhausted.
MISCELLANEOUS
Fontsnot listed in the DESC file are automatically mounted on the next available font position when they are referenced.
If a font isto be mounted explicitly with the fp request on an unused font position, it should be mounted on the first unused
font position, which can be found in the \n[.fp] register; although troff doesnot enforce thisstrictly, it will not allow a font
to be mounted at a position whose number ismuch greater than that of any currently used position.
Interpolating a string doesnot hide existing macro arguments. Thusin a macro, a more efficient way of doing
.xx\\$@
is
\\*[xx]\\
If the font description file containspairwise kerning information, charactersfrom that font will be kerned. Kerning between
two characterscan be inhibited by placing a \& between them.
In a string comparison in a condition, charactersthat appear at different input levelsto the first delimiter character will not
be recognized asthe second or third delimiters. Thisappliesalso to the tl request. In a \w escape sequence, a character that
appearsat a different input level to the starting delimiter character will not be recognized asthe closing delimiter character.
When decoding a macro argument that isdelimited by double quotes, a character that appearsat a different input level to
the starting delimiter character will not be recognized asthe closing delimiter character. The implementation of \$@ ensures
that the double quotessurrounding an argument will appear the same input level, which will be different to the input level
of the argument itself. In a long escape name ] will not be recognized asa closing delimiter except when it occursat the same
input level asthe opening ]. In compatibility mode, no attention ispaid to the input level.
There are some new typesof condition:
.ifrxxx True if there isa number register named xxx.
.ifdxxx True if there isa string, macro, diversion, or request named xxx.
.ifcch True if there isa character ch available; ch iseither an ASCII character or a special character \(xx or \[xxx]; the
condition will also be true if ch hasbeen defined by the char request.
WARNINGS
The warningsthat can be given by troff are divided into the following categories. The name associated with each warning is
used by the w and W options; the number isused by the warn request, and by the .warn register.
char1 Nonexistent characters. Thisisenabled by default.
number2 Invalid numeric expressions. Thisisenabled by default.
break4 In fill mode, lineswhich could not be broken so that their length waslessthan the line length. Thisis
enabled by default.
delim8 Missing or mismatched closing delimiters.
247
el16 Use of the el request with no matching ie request.
scale32 Meaninglessscaling indicators.
range64 Out of range arguments.
syntax128 Dubioussyntax in numeric expressions.
di256 Use of di or da without an argument when there isno current diversion.
mac512 Use of undefined strings, macros, and diversions. When an undefined string, macro, or diversion isused,
that string isautomatically defined asempty. So, in most cases, at most one warning will be given for each
name.
reg1024 Use of undefined number registers. When an undefined number register isused, that register isautomati-
cally defined to have a value of 0. A definition isautomatically made with a value of 0. So, in most cases, at
most one warning will be given for use of a particular name.
tab2048 Inappropriate use of a tab character. Either use of a tab character where a number wasexpected, or use of
tab character in an unquoted macro argument.
right-brace4096 Use of \g where a number wasexpected.
missing8192 Requeststhat are missing nonoptional arguments.
input16384 Illegal input characters.
escape32768 Unrecognized escape sequences. When an unrecognized escape sequence isencountered, the escape
character isignored.
space65536 Missing space between a request or macro and itsargument. Thiswarning will be given when an
undefined name longer than two charactersisencountered, and the first two charactersof the name make
a defined name. The request or macro will not be invoked. When thiswarning isgiven, no macro is
automatically defined. Thisisenabled by default. Thiswarning will never occur in compatibility mode.
font131072 Nonexistent fonts. Thisisenabled by default.
ig262144 Illegal escapesin text ignored with the ig request. These are conditionsthat are errorswhen they do not
occur in ignored text.
There are also namesthat can be used to refer to groupsof warnings:
all All warningsexcept di, mac, and reg. It isintended that thiscoversall warningsthat are useful with
traditional macro packages.
w All warnings.
INCOMPATIBILITIES
Long namescause some incompatibilities. UNIX troff will interpret
.dsabcd
asdefining a string ab with contentscd. Normally, GNU troff will interpret thisasa call of a macro named dsabcd. Also
UNIX troff will interpret \*[ or \n[ asreferencesto a string or number register called [. In GNU troff, however, thiswill
normally be interpreted asthe start of a long name. In compatibility mode GNU troff will interpret these thingsin the
traditional way. In compatibility mode, however, long namesare not recognized. Compatibility mode can be turned on with
the C command-line option, and turned on or off with the cp request. The number register \n(.C is1 if compatibility mode
ison, 0 otherwise.
GNU troff doesnot allow the use of the escape sequencesin namesof strings, macros, diversions, number registers, fonts, or
environments; UNIX troff does. The \A escape sequence may be helpful in avoiding use of these escape sequencesin names.
Fractional point sizescause one noteworthy incompatibility. In UNIX troff the ps request ignoresscale indicatorsand so
.ps 10u
will set the pointsize to 10 points, whereasin GNU troff it will set the pointsize to 10 scaled points.
gtroff
Part I: User Commands
248
In GNU troff there isa fundamental difference between unformatted, input characters, and formatted, output characters.
Everything that affectshow an output character will be output isstored with the character; after an output character hasbeen
constructed, it isunaffected by any subsequent requeststhat are executed, including bd, cs, tkf, tr, or fp requests. Normally
output charactersare constructed from input charactersat the moment immediately before the character isadded to the
current output line. Macros, diversions, and stringsare all, in fact, the same type of object; they contain listsof input
charactersand output charactersin any combination. An output character doesnot behave like an input character for the
purposesof macro processing; it doesnot inherit any of the special propertiesthat the input character from which it was
constructed might have had. For example, this:
.di x
\\\\
.br
.di
.x
will print \\ in GNU troff; each pair of input \sisturned into one output \ and the resulting output \sare not interpreted
asescape characterswhen they are reread. UNIX troff would interpret them asescape characterswhen they were reread and
would end up printing one \. The correct way to obtain a printable \ isto use the \e escape sequence: thiswill alwaysprint a
single instance of the current escape character, regardlessof whether or not it isused in a diversion; it will also work in both
GNU troff and UNIX troff. If you wish for some reason to store in a diversion an escape sequence that will be interpreted
when the diversion isreread, you can either use the traditional \! transparent output facility, or, if thisisunsuitable, the new
\? escape sequence.
ENVIRONMENT
GROFF_TMAC_PATH A colon-separated list of directoriesin which to search for macro files.
GROFF_TYPESETTER Default device.
GROFF_FONT_PATH A colon-separated list of directoriesin which to search for the devname directory. troff will search
in directoriesgiven in the F option before these, and in standard directories(:/usr/lib/groff/font,
:/usr/lib/font, and :/usr/lib/font) after these.
FILES
/usr/lib/groff/font/devname/DESC
/usr/lib/groff/tmac/troffrc Initialization file
/usr/lib/groff/tmac/tmac.name Macro files
/usr/lib/groff/font/devname/DESC Device description file for device name
/usr/lib/groff/font/devname/F Font file for font F of device name
SEE ALSO
groff(1) gtbl(1), gpic(1), geqn(1), grops(1), grodvi(1), grotty(1), groff_font(5), groff_out(5), groff_char(7)
Groff Version 1.09, 14 February1994
gzip, gunzip, zcatgzip, gunzip, zcat
gzip, gunzip, zcatgzip, gunzip, zcatCompressor expand files
SYNOPSIS
gzip [ acdfhlLnNrtvV19 ][Ssuffix] [ name ... ]
gunzip [ acfhlLnNrtvV ][Ssuffix] [ name ... ]
zcat [ fhLV ][name ... ]
249
DESCRIPTION
gzip reducesthe size of the named filesusing Lempel-Ziv coding (LZ77). Whenever possible, each file isreplaced by one
with the extension .gz, while keeping the same ownership modes, access, and modification times. (The default extension is
gz for VMS, z for MS-DOS, OS/2 FAT, WindowsNT FAT and Atari.) If no filesare specified, or if a filename is-, the
standard input iscompressed to the standard output. gzip will only attempt to compressregular files. In particular, it will
ignore symbolic links.
If the compressed filename istoo long for itsfilesystem, gzip truncatesit. gzip attemptsto truncate only the partsof the
filename longer than three characters. (A part isdelimited by dots.) If the name consistsof small partsonly, the longest parts
are truncated. For example, if filenamesare limited to 14 characters, gzip.msdos.exe iscompressed to gzi.msd.exe.gz. Names
are not truncated on systemsthat do not have a limit on filename length.
By default, gzip keepsthe original filename and timestamp in the compressed file. These are used when decompressing the
file with the N option. Thisisuseful when the compressed filename wastruncated or when the time stamp wasnot preserved
after a file transfer.
Compressed filescan be restored to their original form using gzip -d or gunzip or zcat. If the original name saved in the
compressed file isnot suitable for itsfilesystem, a new name isconstructed from the original one to make it legal.
gunzip takesa list of fileson itscommand line and replaceseach file whose name endswith .gz, -gz, .z, -z, z, or .Z and which
beginswith the correct magic number with an uncompressed file without the original extension. gunzip also recognizesthe
special extensions.tgz and .taz asshorthandsfor .tar.gz and .tar.Z respectively. When compressing, gzip usesthe .tgz
extension if necessary instead of truncating a file with a .tar extension.
gunzip can currently decompressfilescreated by gzip, zip, compress, compress -H, or pack. The detection of the input format
isautomatic. When using the first two formats, gunzip checksa 32-bit CRC. For pack, gunzip checksthe uncompressed
length. The standard compress format wasnot designed to allow consistency checks. However, gunzip issometimesable to
detect a bad .Z file. If you get an error when uncompressing a .Z file, do not assume that the .Z file iscorrect simply because
the standard uncompress doesnot complain. Thisgenerally meansthat the standard uncompress doesnot check itsinput, and
happily generatesgarbage output. The SCO compress -H format (lzh compression method) doesnot include a CRC but also
allowssome consistency checks.
Filescreated by zip can be uncompressed by gzip only if they have a single member compressed with the deflation method.
Thisfeature isonly intended to help conversion of tar.zip filesto the tar.gz format. To extract zip fileswith several
members, use unzip instead of gunzip.
zcat isidentical to gunzip c. (On some systems, zcat may be installed asgzcat to preserve the original link to compress.)
zcat uncompresseseither a list of fileson the command line or itsstandard input and writesthe uncompressed data on
standard output. zcat will uncompressfilesthat have the correct magic number whether they have a .gz suffix or not.
gzip usesthe Lempel-Ziv algorithm used in zip and PKZIP. The amount of compression obtained dependson the size of the
input and the distribution of common substrings. Typically, text such assource code or English isreduced by 60 to 70
percent. Compression isgenerally much better than that achieved by LZW (asused in compress), Huffman coding (asused
in pack), or adaptive Huffman coding (compact).
Compression isalwaysperformed, even if the compressed file isslightly larger than the original. The worst case expansion isa
few bytesfor the gzip file header, plus5 bytesevery 32KB block, or an expansion ratio of 0.015 percent for large files. Note
that the actual number of used disk blocksalmost never increases. gzip preservesthe mode, ownership, and timestampsof
fileswhen compressing or decompressing.
OPTIONS
a ascii ASCII text mode: convert end-of-linesusing local conventions. Thisoption issupported
only on some non-UNIX systems. For MS-DOS, CR LF isconverted to LF when compress-
ing, and LF isconverted to CR LF when decompressing.
c stdout to-stdout Write output on standard output; keep original filesunchanged. If there are several input
files, the output consistsof a sequence of independently compressed members. To obtain
better compression, concatenate all input filesbefore compressing them.
gzip, gunzip, zcatgzip, gunzip, zcat
Part I: User Commands
250
d decompress uncompress Decompress.
f force Force compression or decompression even if the file hasmultiple linksor the corresponding
file already exists, or if the compressed data isread from or written to a terminal. If the
input data isnot in a format recognized by gzip, and if the option stdout isalso given,
copy the input data without change to the standard output; let zcat behave ascat. If f is
not given, and when not running in the background, gzip promptsto verify whether an
existing file should be overwritten.
h help Display a help screen and quit.
l list For each compressed file, list the following fields: compressed size (size of the compressed
file), uncompressed size (size of the uncompressed file), ratio (compression ratio0.0% if
unknown), uncompressed name (name of the uncompressed file). The uncompressed size is
given as-1 for filesnot in gzip format, such ascompressed .Z files. To get the uncompressed
size for such a file, you can use:
zcat file.Z | wc -c
In combination with the verbose option, the following fieldsare also displayed: method
(compression method), crc (the 32-bit CRC of the uncompressed data), date & time
(timestamp for the uncompressed file). The compression methodscurrently supported are
deflate, compress, lzh (SCO compress -H) and pack. The crc isgiven asffffffff for a file
not in gzip format.
With name, the uncompressed name, date and time are those stored within the compressed
file if present.
With verbose, the size totalsand compression ratio for all filesisalso displayed, unless
some sizesare unknown. With quiet, the title and totalslinesare not displayed.
L license Display the gzip license and quit.
n no-name When compressing, do not save the original filename and timestamp by default. (The
original name isalwayssaved if the name had to be truncated.) When decompressing, do
not restore the original filename if present (remove only the gzip suffix from the compressed
filename) and do not restore the original timestamp if present (copy it from the compressed
file). Thisoption isthe default when decompressing.
N name When compressing, alwayssave the original filename and timestamp; thisisthe default.
When decompressing, restore the original filename and timestamp if present. Thisoption is
useful on systemsthat have a limit on filename length or when the timestamp hasbeen lost
after a file transfer.
q quiet Suppressall warnings.
r recursive Travel the directory structure recursively. If any of the filenamesspecified on the command
line are directories, gzip will descend into the directory and compressall the filesit finds
there (or decompressthem in the case of gunzip).
S .suf suffix .suf Use suffix .suf instead of .gz. Any suffix can be given, but suffixesother than .z and .gz
should be avoided to avoid confusion when filesare transferred to other systems. A null
suffix forcesgunzip to try decompression on all given filesregardlessof suffix, asin the
following:
gunzip -S * (*.* for MS-DOS)
Previousversionsof gzip used the .z suffix. Thiswaschanged to avoid a conflict with
pack(1).
t test Test. Check the compressed file integrity.
v verbose Verbose. Display the name and percentage reduction for each file compressed or decom-
pressed.
V version Version. Display the version number and compilation options, then quit.
# fast best Regulate the speed of compression using the specified digit #, where 1 or --fast indicates
the fastest compression method (lesscompression) and 9 or --best indicatesthe slowest
compression method (best compression). The default compression level is6 (that is, biased
towardshigh compression at expense of speed).
251
ADVANCED USAGE
Multiple compressed filescan be concatenated. In thiscase, gunzip will extract all membersat once. For example,
gzip -c file1 >foo.gz gzip -c file2>>> foo.gz
Then
gunzip -c foo
isequivalent to
cat file1 file2
In case of damage to one member of a .gz file, other memberscan still be recovered (if the damaged member isremoved).
However, you can get better compression by compressing all membersat once.
cat file1 file2 | gzip > foo.gz
compressesbetter than
gzip -c file1 file2 >foo.gz
If you want to recompressconcatenated filesto get better compression, use
gzip -cd old.gz | gzip > new.gz
If a compressed file consistsof several members, the uncompressed size and CRC reported by the list option appliesto the
last member only. If you need the uncompressed size for all members, you can use
gzip -cd file.gz | wc -c
If you wish to create a single archive file with multiple membersso that memberscan later be extracted independently, use an
archiver such astar or zip. GNU tar supportsthe -z option to invoke gzip transparently. gzip isdesigned asa complement
to tar, not asa replacement.
ENVIRONMENT
The environment variable GZIP can hold a set of default optionsfor gzip. These optionsare interpreted first and can be
overwritten by explicit command-line parameters. For example,
For sh: GZIP=-8v name
Export GZIP for csh: setenv GZIP -8v name
For MS-DOS: set GZIP=-8v name
On Vax/VMS, the name of the environment variable isGZIP_OPT, to avoid a conflict with the symbol set for invocation of the
program.
SEE ALSO
znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), compress(1), pack(1), compact(1)
DIAGNOSTICS
Exit statusisnormally 0; if an error occurs, exit statusis1. If a warning occurs, exit statusis2.
Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
Invalid optionswere specified on the command line.
file: not in gzip format
The file specified to gunzip hasnot been compressed.
file: Corrupt input. Use zcat to recover some data.
The compressed file hasbeen damaged. The data up to the point of failure can be recovered using
zcat file > recover
gzip, gunzip, zcatgzip, gunzip, zcat
Part I: User Commands
252
file: compressed with xx bits, can only handle yy bits
file wascompressed (using LZW) by a program that could deal with more bitsthan the decompresscode on thismachine.
Recompressthe file with gzip, which compressesbetter and useslessmemory.
file: already has .gz suffix--no change
The file isassumed to be already compressed. Rename the file and try again.
file already exists; do you wish to overwrite (y or n)?
Respond y if you want the output file to be replaced; n if not.
gunzip: corrupt input
A SIGSEGV violation wasdetected, which usually meansthat the input file hasbeen corrupted.
xx.x%
Percentage of the input saved by compression. (Relevant only for v and l.)
not a regular file or directory: ignored
When the input file isnot a regular file or directory, (such asa symbolic link, socket, FIFO, device file), it isleft unaltered.
has xx other links: unchanged
The input file haslinks; it isleft unchanged. See ln(1) for more information.
Use the f flag to force compression of filesthat are multiply linked.
CAVEATS
When writing compressed data to a tape, it isgenerally necessary to pad the output with zeroesup to a block boundary.
When the data isread and the whole block ispassed to gunzip for decompression, gunzip detectsthat there isextra trailing
garbage after the compressed data and emitsa warning by default. You have to use the quiet option to suppressthe
warning. Thisoption can be set in the GZIP environment variable asin the following:
for sh: GZIP=-q tar -xfz block-compress /dev/rst0 for csh:
(setenv GZIP -q; tar -xfz block-compr /dev/rst0
In the preceding example, gzip isinvoked implicitly by the -z option of GNU tar. Make sure that the same block size (-b
option of tar) isused for reading and writing compressed data on tapes. (Thisexample assumesyou are using the GNU
version of tar.)
BUGS
The list option reportsincorrect sizesif they exceed two gigabytes. The list option reportssizesas-1 and crc asffffffff
if the compressed file ison a nonseekable media.
In some rare cases, the best option givesworse compression than the default compression level (-6). On some highly
redundant files, compress compressesbetter than gzip.
Local
gzexe
gzexeCompressexecutable filesin place
SYNOPSIS
gzexe [ name ... ]
253
DESCRIPTION
The gzexe utility enablesyou to compressexecutablesin place and have them automatically uncompressand execute when
you run them (at a penalty in performance). For example if you execute gzexe /bin/cat, it will create the following two files:
-r-xr-xr-x 1 root bin 9644 Feb 11 11:16 /bin/cat
-r-xr-xr-x 1 bin bin 24576 Nov 23 13:21 /bin/cat
/bin/cat isthe original file and /bin/cat isthe self-uncompressing executable file. You can remove /bin/cat when you are
sure that /bin/cat worksproperly.
Thisutility ismost useful on systemswith very small disks.
OPTIONS
d Decompressthe given executablesinstead of compressing them
SEE ALSO
gzip(1), znew(1), zmore(1), zcmp(1), zforce(1)
CAVEATS
The compressed executable isa shell script. Thismay create some security holes. In particular, the compressed executable
relieson the PATH environment variable to find gzip and some other utilities(tail, chmod, ln, sleep).
BUGS
gzexe attemptsto retain the original file attributeson the compressed executable, but you may have to fix them manually in
some cases, using chmod or chown.
head
headOutput the first part of files
SYNOPSIS
head [c N[bkm]] [n N] [qv] [--bytes=N[bkm]] [--lines=N] [--quiet] [--silent]
[--verbose] [--help] [--version] [file...]
head [Nbcklmqv] [file...]
DESCRIPTION
Thismanual page documentsthe GNU version of head. head printsthe first part (10 linesby default) of each given file; it
readsfrom standard input if no filesare given or when a filename of isencountered. If more than one file isgiven, it prints
a header consisting of the filesname enclosed in ==> and <== before the output for each file.
OPTIONS
head acceptstwo option formats: the new one, in which numbersare argumentsto the option letters; and the old one, in
which the number precedesany option letters.
c N, --bytes N Print first N bytes. N isa nonzero integer, optionally followed by one of the following charactersto
specify a different unit.
b 512-byte blocks.
k 1-kilobyte blocks.
m 1-megabyte blocks.
l, n N, --lines N Print first N lines.
q, --quiet, --silent Never print filename headers.
head
Part I: User Commands
254
v, --verbose Alwaysprint filename headers.
--help Print a usage message and exit with a nonzero status.
--version Print version information on standard output, then exit.
GNU Text Utilities
hexdump
hexdumpASCII, decimal, hexadecimal, octal dump
SYNOPSIS
hexdump [-bcdovx] [-e format_string] [-f format_file] [-n length] [-s skip] [file ...]
DESCRIPTION
The hexdump utility isa filter that displaysthe specified files, or the standard input, if no filesare specified, in a user-specified
format.
The optionsare asfollows:
-b One-byte octal display. Display the input offset in hexadecimal, followed by sixteen space-
separated, three-column, zero-filled bytesof input data, in octal, per line.
-c One-byte character display. Display the input offset in hexadecimal, followed by sixteen space-
separated, three-column, space-filled, charactersof input data per line.
-d Two-byte decimal display. Display the input offset in hexadecimal, followed by eight space-
separated, five-column, zero-filled, two-byte unitsof input data, in unsigned decimal, per line.
-e format_string Specify a format string to be used for displaying data.
-f format_file Specify a file that containsone or more newline separated format strings. Empty linesand lines
whose first nonblank character isa hash mark (#) are ignored.
-n length Interpret only length bytesof input.
-o Two-byte octal display. Display the input offset in hexadecimal, followed by eight space-separated,
six-column, zero-filled, two-byte quantitiesof input data, in octal, per line.
-s offset Skip offset bytesfrom the beginning of the input. By default, offset isinterpreted asa decimal
number. With a leading 0x or 0X, offset isinterpreted asa hexadecimal number; otherwise, with a
leading 0, offset isinterpreted asan octal number. Appending the character b, k, or m to offset
causesit to be interpreted asa multiple of 512, 1024, or 1048576, respectively.
-v The -v option causeshexdump to display all input data. Without the -v option, any number of
groupsof output lines, which would be identical to the immediately preceding group of output
lines(except for the input offsets), are replaced with a line comprised of a single asterisk.
-x Two-byte hexadecimal display. Display the input offset in hexadecimal, followed by eight, space-
separated, four-column, zero-filled, two-byte quantitiesof input data, in hexadecimal, per line.
For each input file, hexdump sequentially copiesthe input to standard output, transforming the data according to the format
stringsspecified by the -e and -f options, in the order that they were specified.
FORMATS
A format string containsany number of format units, separated by whitespace. A format unit containsup to three items: an
iteration count, a byte count, and a format.
The iteration count isan optional positive integer, which defaultsto one. Each format isapplied iteration count times.
The byte count isan optional positive integer. If specified, it definesthe number of bytesto be interpreted by each iteration
of the format.
255
If an iteration count and/or a byte count isspecified, a single slash must be placed after the iteration count and/or before the
byte count to disambiguate them. Any whitespace before or after the slash isignored.
The format isrequired and must be surrounded by double quote ( ) marks. It isinterpreted asan fprintf-style format
string (see fprintf(3)) with the following exceptions:
I An asterisk (*) may not be used asa field width or precision.
I A byte count or field precision isrequired for each s conversion character (unlike the fprintf(3) default, which prints
the entire string if the precision isunspecified).
I The conversion charactersh, l, n, p, and q are not supported.
I The single-character escape sequencesdescribed in the C standard are supported:
NUL \0
Alert character \a
Backspace \b
Form-feed \f
Newline \n
Carriage return \r
Tab \t
Vertical tab \v
hexdump also supportsthe following additional conversion strings:
a[dox] Display the input offset, cumulative acrossinput files, of the next byte to be displayed. The appended characters
d, o, and x specify the display base asdecimal, octal, or hexadecimal respectively.
A[dox] Identical to the a conversion string except that it isonly performed once, when all of the input data hasbeen
processed.
c Output charactersin the default character set. Nonprinting charactersare displayed in three-character, zero-
padded octal, except for those representable by standard escape notation (see preceding list), which are displayed
astwo-character strings.
p Output charactersin the default character set. Nonprinting charactersare displayed asa single period.
u Output U.S. ASCII characters, with the exception that control charactersare displayed using the lowercase names
in the following mini-table. Charactersgreater than 0xff, hexadecimal, are displayed ashexadecimal strings.
000 nul 001 soh 002 stx 003 etx 004 eot 005 enq
006 ack 007 bel 008 bs 009 ht 00A lf 00B vt
00C ff 00D cr 00E so 00F si 010 dle 011 dc1
012 dc2 013 dc3 014 dc4 015 nak 016 syn 017 etb
018 can 019 em 01A sub 01B esc 01C fs 01D gs
01E rs 01F us 0FF del
The default and supported byte countsfor the conversion charactersare asfollows:
%_c, %_p, %_u, %c One-byte countsonly.
%d, %i, %o, %u, %X, %x Four-byte default; one-, two-, and four-byte countssupported.
%E, %e, %f, %G, %g Eight-byte default, four-byte countssupported.
The amount of data interpreted by each format string isthe sum of the data required by each format unit, which isthe
iteration count timesthe byte count, or the iteration count timesthe number of bytesrequired by the format if the byte
count isnot specified.
The input ismanipulated in blocks; a block isdefined asthe largest amount of data specified by any format string. Format
stringsinterpreting lessthan an input blocksworth of data, whose last format unit both interpretssome number of bytes
and doesnot have a specified iteration count, have the iteration count incremented until the entire input block hasbeen
processed or there isnot enough data remaining in the block to satisfy the format string.
hexdump
Part I: User Commands
256
If, either asa result of user specification or hexdump modifying the iteration count asdescribed, an iteration count isgreater
than one, no trailing whitespace charactersare output during the last iteration.
It isan error to specify a byte count aswell asmultiple conversion charactersor stringsunlessall but one of the conversion
charactersor stringsisa or A. If, asa result of the specification of the -n option or end-of-file being reached, input data only
partially satisfiesa format string, the input block iszero-padded sufficiently to display all available data (that is, any format
unitsoverlapping the end of data will display some number of the zero bytes).
Further output by such format stringsisreplaced by an equivalent number of spaces. An equivalent number of spacesis
defined asthe number of spacesoutput by an s conversion character with the same field width and precision asthe original
conversion character or conversion string but with any +, , # conversion flag charactersremoved, and referencing a NULL
string.
If no format stringsare specified, the default display isequivalent to specifying the -x option.
hexdump exits0 on successand >0 if an error occurred.
EXAMPLES
Display the input in perusal format:
%06.6_ao 12/1 %3_u
\t\t %_p
\n
Implement the x option:
%07.7_Ax\n
%07.7_ax 8/2 %04x \n
SEE ALSO
adb(1)
18 April 1994
hipstopgm
hipstopgmConvert a HIPS file into a portable graymap
SYNOPSIS
hipstopgm [hipsfile]
DESCRIPTION
Hipstopgm readsa HIPS file asinput and producesa portable graymap asoutput.
If the HIPS file containsmore than one frame in sequence, hipstopgm will concatenate all the framesvertically.
HIPS isa format developed at the Human Information Processing Laboratory, NYU.
SEE ALSO
pgm(5)
AUTHOR
Copyright 1989 by Jef Poskanzer
24 August 1989
257
host
hostLook up hostnamesusing domain server
SYNOPSIS
host [-l] [-v] [-w] [-r] [-d] [-t querytype] [-a] host [ server ]
DESCRIPTION
host looksfor information about Internet hosts. It getsthisinformation from a set of interconnected serversthat are spread
acrossthe country. By default, it simply convertsbetween hostnamesand Internet addresses. However with the -t or -a
options, it can be used to find all of the information about thishost that ismaintained by the domain server.
The argumentscan be either hostnamesor host numbers. The program first attemptsto interpret them ashost numbers. If
thisfails, it will treat them ashostnames. A host number consistsof first decimal numbersseparated by dots, for example,
128.6.4.194. A hostname consistsof namesseparated by dots, for example, topaz.rutgers.edu. Unlessthe name endsin a
dot, the local domain isautomatically tacked on the end. Thus, a Rutgersuser can say host topaz, and it will actually look
up topaz.rutgers.edu. If thisfails, the name istried unchanged (in thiscase, topaz). Thissame convention isused for mail
and other network utilities. The actual suffix to tack on the end isobtained by looking at the resultsof a hostname call, and
using everything starting at the first dot. (Following isa description of how to customize the hostname lookup.)
The first argument isthe hostname you want to look up. If thisisa number, an inversequeryisdone; that is, the domain
system looksin a separate set of databasesused to convert numbersto names.
The second argument isoptional. It allowsyou to specify a particular server to query. If you dont specify thisargument, the
default server (normally the local machine) isused.
If a name isspecified, you may see output of three different kinds. Here isan example that showsall of them:
% host sun4
sun4.rutgers.edu is a nickname for ATHOS.RUTGERS.EDU
ATHOS.RUTGERS.EDU has address 128.6.5.46
ATHOS.RUTGERS.EDU has address 128.6.4.4
ATHOS.RUTGERS.EDU mail is handled by ARAMIS.RUTGERS.EDU
The user hastyped the command host sun4. The first line indicatesthat the name sun4.rutgers.edu isactually a nickname.
The official hostname isATHOS.RUTGERS.EDU. The next two linesshow the address. If a system hasmore than one network
interface, there will be a separate addressfor each. The last line indicatesthat ATHOS.RUTGERS.EDU doesnot receive itsown
mail. Mail for it istaken by ARAMIS.RUTGERS.EDU. There may be more than one such line, assome systemshave more than one
other system that will handle mail for them. Technically, every system that can receive mail issupposed to have an entry of
thiskind. If the system receivesitsown mail, there should be an entry the mentionsthe system itself, for example XXX mail
ishandled by XXX. However many systemsthat receive their own mail do not bother to mention that fact. If a system hasa
mail ishandled by entry, but no address, thisindicatesthat it isnot really part of the Internet, but a system that ison the
network will forward mail to it. Systemson Usenet, bitnet, and a number of other networkshave entriesof thiskind.
There are a number of optionsthat can be used before the hostname. Most of these optionsare meaningful only to the staff
who have to maintain the domain database.
The option -w causeshost to wait forever for a response. Normally it will time out after around a minute.
The option -v causesprintout to be in a verbose format. Thisisthe official domain master file format, which isdocumented
in the man page for named. Without thisoption, output still followsthisformat in general terms, but some attempt ismade
to make it more intelligible to normal users. Without -v, a, mx, and cname recordsare written out ashas address, mail is
handled by, and is a nickname for, and TTL and classfieldsare not shown.
The option -r causesrecursion to be turned off in the request. Thismeansthat the name server will return only data it hasin
itsown database. It will not ask other serversfor more information.
The option -d turnson debugging. Network transactionsare shown in detail.
host
Part I: User Commands
258
The option -t allowsyou to specify a particular type of information to be looked up. The argumentsare defined in the man
page for named. Currently supported typesare a, ns, md, mf, cname, soa, mb, mg, mr, null, wks, ptr, hinfo, minfo, mx, uinfo, uid,
gid, unspec, and the wildcard, which may be written aseither any or *. Typesmust be given in lowercase. Note that the
default isto look first for a, and then mx, except that if the verbose option isturned on, the default isonly a.
The option -a (for all) isequivalent to -v -t any.
The option -l causesa listing of a complete domain. For example,
host -l rutgers.edu
will give a listing of all hostsin the rutgers.edu domain. The -t option isused to filter what information ispresented, asyou
would expect. The default isaddressinformation, which also include PTR and NS records. The command host:
-l -v -t any rutgers.edu
will give a complete download of the zone data for rutgers.edu, in the official master file format. (However the SOA record
islisted twice, for arcane reasons.)
NOTE
-l isimplemented by doing a complete zone transfer and then filtering out the information you have asked for. This
command should be used only if it isabsolutely necessary.
CUSTOMIZING HOSTNAME LOOKUP
In general, if the name supplied by the user doesnot have any dotsin it, a default domain isappended to the end. This
domain can be defined in /etc/resolv.conf, but isnormally derived by taking the local hostname after itsfirst dot. The user
can override this, and specify a different default domain, using the environment variable LOCALDOMAIN. In addition, the user
can supply hisown abbreviationsfor hostnames. They should be in a file consisting of one line per abbreviation. Each line
containsan abbreviation, a space, and then the full hostname. Thisfile must be pointed to by an environment variable
HOSTALIASES, which isthe name of the file.
SEE ALSO
named(8)
BUGS
Unexpected effectscan happen when you type a name that isnot part of the local domain. Please alwayskeep in mind that
the local domain name istacked onto the end of every name, unlessit endsin a dot. Only if thisfailsisthe name used
unchanged.
The -l option only triesthe first name server listed for the domain that you have requested. If thisserver isdead, you may
need to specify a server manually. For example, to get a listing of foo.edu, you could try host -t ns foo.edu to get a list of all
the name serversfor foo.edu, and then try host -l foo.edu xxx for all xxx on the list of name servers, until you find one that
works.
hostid
hostidSet or print systemshost ID.
SYNTAX
hostid [v] [ deci mal - i d ]
259
DESCRIPTION
The hostid command printsthe current host ID number in hexadecimal and both decimal and hexadecimal in parenthesisif
the v option isgiven. Thisnumeric value isexpected to be unique acrossall hostsand isnormally set to resemble the hosts
Internet address.
Only the superuser can set the hostid by giving an argument. Thisvalue isstored in the file /etc/hostid and need only be
performed once.
AUTHOR
hostid iswritten by Mitch DSouza (m.dsouza@mrc-apu.cam.ac.uk).
SEE ALSO
gethostid(2), sethostid(2)
hostname
hostnameShow or set the systemshostname
dnsdomainname--Show the systemsdomain name
SYNOPSIS
hostname [d][--domain][Ff i l ename] [--filef i l ename] [f][--fqdn][h][--help]
[--long][s][--short][v][--version][name]
dnsdomainname
DESCRIPTION
hostname isthe program that isused to either set the hostname or display the current host or domain name of the system.
Thisname isused by many of the networking programsto identify the machine.
When called without any arguments, the program displaysthe current name asset by the hostname command. You can
change the output format to display alwaysthe short or the long hostname (FQDN). When called with arguments, the
program will set the value of the hostname to the value specified. Thisusually isdone only once, at system startup time, by
the /etc/rc.d/rc.inet1 configuration script.
Note that only the superuser can change the hostname.
If the program wascalled asdnsdomainname, it will show the domain name server (DNS) domain name. You cant change the
DNSdomain name with dnsdomainname. (See the following subsection.)
OPTIONS
d, --domain Display the name of the DNSdomain. Dont use the com-mand domainname to get the DNS
domain name because it will show the NIS domain name and not the DNS domain name.
F, --file filename Read the hostname from the specified file. Comments(linesstarting with a #) are ignored.
f, --fqdn, --long Display the FQDN (fully-qualified domain name). An FQDN consistsof a short hostname and
the DNSdomain name. Unlessyou are using bind or NIS for host lookups, you can change the
FQDN and the DNSdomain name (which ispart of the FQDN) in the /etc/hosts file.
h, --help Print a usage message on standard output and exit successfully.
s, --short Display the short hostname.
v, --version Print version information on standard output and exit successfully.
FILES
/etc/hosts
hostname
Part I: User Commands
260
AUTHOR
Peter Tobias, (tobias@server.et-inf.fho-emden.de)
Linux, 28 July1994
hpcdtoppm v0.3
hpcdtoppm v0.3Convert a Photo-CD file into a portable pixmap
SYNOPSIS
hpcdtoppm [options] pcd-file [ppm-file]
DESCRIPTION
hpcdtoppm readsa Photo-CD image file or overview file, and outputsa portable pixmap. Image filesyou can find on the
Photo-CD in photo_cd/images are named asimgnnnn.pcd, where nnnn isa 4-digit-number. The Overview file isat photo_cd/
overview.pcd. If there isno ppm-file given, output will be printed to stdout. hpcdtoppm standsfor Hadmutspcdtoppm to
make it distinguishable in case someone else isbuilding the same thing and calling it pcdtoppm.
OPTIONS
-i Give some information from the fileheader to stderr. It worksonly for image files. (It isnot
working correctly, just printing some strings.)
-s Apply simple sharpness-operator on the luma channel.
-d Do not show the complete image, but only the decompressed difference. It worksonly on
the 4Base and the 16Base resolution. It doesnot have any deeper sense, but it wassimple to
implement and it showswhat causesdifferent sizesof image files.
-r Rotate the picture clockwise for portraits.
-l Rotate the picture counter-clockwise for portraits.
-a Try to find out the image orientation. Thisdoesnt work for overview filesyet. It isvery
experimental and dependson one byte. Please tell me if it doesnt work.
-x Overskip mode. Workson Base/16, Base/4, Base, and 4Base. In Photo-CD images, the
luma channel isstored in full resolution, the two chroma channelsare stored in half
resolution only and have to be interpolated. In the Overskip mode, the chroma channelsof
the next higher resolution are taken instead of interpolating. To see the difference, generate
one ppm with and one ppm without thisflag. Use pnmarith to generate the difference image of
these two images. Call ppmhist for thisdifference or show it with xv (push the HistEq
button in the color editor).
-1 | -Base/16 | -128x192 Extract the Base/16 size picture (size 128192 pixels). Note that you can only give one size
option.
-2 | -Base/4 | -256x384 Extract the Base/4 size picture.
-3 | -Base | -512x768 Extract the Base size picture.
-4 | -4Base | -1024x1536 Extract the 4Base size picture.
-5 | -16Base | -2048x3072 Extract the 16Base size picture.
-0 | -Overview | -O Extract all picturesfrom an Overview file. A ppm filename must be given. If the given name
isfoo, the filesare named foonnnn, where nnnn isa 4-digit number. They are stored in
Base/16 format, so they are extracted in thisformat.
-ycc Suppressthe ycc to rgb conversion. Thisisexperimental only. You can use thisand apply
ppmtorgb3 on the file. Then you will get three pgm files, one luma and two chroma files.
261
BUGS
I still dont have enough information about the Photo-CD to take care of all data structures. The information I have isquite
vague and thisprogram wasdeveloped by staring at the hexdumpsand using the famoustrial-and-error-method. :-) If
anything doesnt work, please send me a report and perhapsyou could try to find out why it doesnt work.
SEE ALSO
ppm(5), ppmquant(1), ppmtopgm(1), ppmhist(1), pnmarith(1), ppmtorgb3(1), xv(1)
AUTHOR
Copyright
1992 by Hadmut Danisch (danisch@ira.uka.de). Permission to use and distribute thissoftware and its
documentation for noncommercial use and without fee ishereby granted, provided that the preceding copyright notice
appear in all copiesand that both that copyright notice and thispermission notice appear in supporting documentation.
Thissoftware may not be sold in any way. Thissoftware isnot public domain.
28 November 1992
httpd
httpdApache Hypertext Transfer Protocol server
SYNOPSIS
httpd [ vX? ][d ser ver r oot ][f conf i g ]
DESCRIPTION
httpd isthe Apache Hypertext Transfer Protocol (HTTP) server process. The server may be invoked by the Internet daemon
inetd(1M) each time a connection to the HTTP service ismade, or alternatively it may run asa daemon.
OPTIONS
d ser ver r oot Set the initial value for the ServerRoot variable to serverroot. Thiscan be overridden by the ServerRoot
command in the configuration file. The default is/usr/local/etc/httpd.
f conf i g Execute the commandsin the file conf i g on startup. If conf i g doesnot begin with a /, then it istaken to
be a path relative to the ServerRoot. The default isconf/httpd.conf.
X Run in single-processmode, for internal debugging purposesonly; the daemon doesnot detach from the
terminal or fork any children. Do not use thismode to provide ordinary Web service.
v Print the version of httpd, and then exit.
? Print a list of the httpd options, and then exit.
FILES
/usr/local/etc/httpd/conf/httpd.conf
/usr/local/etc/httpd/conf/srm.conf
/usr/local/etc/httpd/conf/access.conf
/usr/local/etc/httpd/conf/mime.types
/usr/local/etc/httpd/logs/error_log
/usr/local/etc/httpd/logs/access_log
/usr/local/etc/httpd/logs/httpd.pid
SEE ALSO
inetd(1m)
Documentation for the Apache HTTP server isavailable from http://www.apache.org.
October 1995
httpd
Part I: User Commands
262
icontopbm
icontopbmConvert a Sun icon into a portable bitmap
SYNOPSIS
icontopbm [iconfile]
DESCRIPTION
icontopbm readsa Sun icon asinput and producesa portable bitmap asoutput.
SEE ALSO
pbmtoicon(1), pbm(5)
AUTHOR
Copyright
1991 by ChristosZoulas.
14 July1991
pktopbm
pktopbmConvert packed (PK) format font into portable bitmap(s)
SYNOPSIS
pktopbm pkfile[.pk] [-c num] pbmf i l e ...
DESCRIPTION
pktopbm readsa packed (PK) font file asinput and producesportable bitmapsasoutput. If the filename - isused for any of
the filenames, the standard input stream (or standard output where appropriate) will be used.
OPTIONS
-c num Setsthe character number of the next bitmap written to num.
SEE ALSO
pbmtopk(1), pbm(5)
AUTHOR
Adapted from Tom Rokickispxtopk by AngusDuggan (ajcd@dcs.ed.ac.uk).
6 August 1990
pnmalias
pnmaliasAntialiasa portable anymap.
SYNOPSIS
pnmalias [-bgcolor col or ][-fgcolor col or ][-bonly][-fonly][-balias][-falias]
[-weight w][pnmf i l e]
pnmalias
Part I: User Commands
382
DESCRIPTION
pnmalias readsa portable anymap asinput and appliesantialiasing to background and foreground pixels. If the input file isa
portable bitmap, the output antialiased image ispromoted to a graymap, and a message isprinted informing the user of the
change in format.
OPTIONS
bgcolor col or b, Set the background color to col or b, and the foreground to color to col or f . Pixelswith these values
fgcolor col or f will be antialiased. By default, the background color istaken to be black, and foreground color is
assumed to be white. The colorscan be specified in five ways:
I A name, assuming that a pointer to an X11-style color namesfile wascompiled in.
I An X11-style hexadecimal specifier: rgb:r/g/b, where r, g, and b are each 1- to 4-digit
hexadecimal numbers.
I An X11-style decimal specifier: rgbi:r/g/b, where r, g, and b are floating-point numbers
between 0 and 1.
I For backwardscompatibility, an old-X11-style hexadecimal number: #rgb, #rrggbb,
#rrrgggbbb, or #rrrrggggbbbb.
I For backwardscompatibility, a triplet of numbersseparated by commas: r,g,b, where r, g,
and b are floating-point numbersbetween 0 and 1. (Thisstyle wasadded before MIT came
up with the similar rgbi style.)
Note that even when dealing with graymaps, background and foreground colorsneed to be specified in the fashion described
in the preceding list. In thiscase, background and foreground pixel valuesare taken to be the value of the red component for
the given color.
bonly, fonly Apply antialiasing only to background (bonly), or foreground (fonly) pixels.
balias, falias Apply antialiasing to all pixelssurrounding background (balias), or foreground (falias) pixels.
By default, antialiasing takesplace only among neighboring background and foreground pixels.
weight w Use w asthe central weight for the aliasing filter. w must be a real number in the range 0 < w < 1.
The lower the value of w is, the blurrier the output image is. The default isw = 1/3.
SEE ALSO
pbmtext(1), pnmsmooth(1), pnm(5)
AUTHOR
Copyright
1991 by ChristosZoulas.
14 July1991
ppmdither
Part I: User Commands
404
ppmflash
ppmflashBrighten a picture up to complete white-out
SYNOPSIS
ppmflash f l ashf act or [ppmf i l e]
DESCRIPTION
ppmflash readsa portable pixmap asinput and increasesitsbrightnessby the specified f l ashf act or up to a total white-out
image. The f l ashf act or may be in the range from 0.0 (original picturesbrightness) to 1.0 (full white-out, The Second
After).
Aspnmgamma doesnot do the brightnesscorrection in the way I wanted it, I wrote thissmall program.
Thisprogram issimilar to ppmbrighten, but not exactly the same.
SEE ALSO
ppm(5), ppmdim(1), pnmgamma(1), ppmbrighten(1)
AUTHOR
Copyright
1991, 1992 by Bill Davidsen, all rightsreserved. The program and documentation may be freely distributed by
anyone in source or binary format. Please clearly note any changes.
Local
ppmrelief
ppmreliefRun a Laplacian relief filter on a portable pixmap
SYNOPSIS
ppmrelief [ppmf i l e]
DESCRIPTION
ppmrelief readsa portable pixmap asinput, doesa Laplacian relief filter, and writesa portable pixmap asoutput.
The Laplacian relief filter isdescribed in Beyond Photographyby Holzmann, equation 3.19. Itsa sort of edge-detection.
SEE ALSO
pgmbentley(1), pgmoil(1), ppm(5)
AUTHOR
Copyright
1990 by Kanthan Pillay (svpillay@Princeton.EDU), Princeton University Computing and Information Technol-
ogy
30 July1990
ppmtoilbm
ppmtoilbmConvert a portable pixmap into an ILBM file
SYNOPSIS
ppmtoilbm [-maxplanes|-mp N][-fixplanes|-fp N][-ham6|-ham8][-dcbits-dcplanesrgb]
[-normal|-hamif|-hamforce|-24if|-24force| -dcif|-dcforce|-cmaponly] [-ecs|-aga]
[- compress|-nocompress][-cmethod t ype][-mapppmfile] [-savemem][ppmfile]
DESCRIPTION
ppmtoilbm readsa portable pixmap asinput and producesan ILBM file asoutput. Supported ILBM typesare the following:
Normal ILBMswith 116 planes
Amiga HAM with 316 planes
24-bit
Colormap (BMHD and CMAP chunk only, nPlanes = 0)
Unofficial direct color 116 planesfor each color component
Chunkswritten: BMHD, CMAP, CAMG (only for HAM), BODY (not for colormap files) unofficial DCOL chunk for direct color ILBM
OPTIONS
Optionsmarked with (*) can be prefixed with no, for example, -nohamif. All optionscan be abbreviated to their shortest
unique prefix.
-maxplanes | - mp n (default 5, minimum 1, maximum 16) Maximum planesto write in a normal ILBM. If the
pixmap doesnot fit into n planes, ppmtoilbm writesa HAM file (if -hamif isused), a 24-bit
file (if -24if isused), a direct color file (if -dcif isused). or abortswith an error.
-fixplanes | - f p n (min 1, max 16) If a normal ILBM iswritten, it will have exactly n planes.
-hambits | -hamplanes n (default 6, min 3, max 16) Select number of planesfor HAM picture. The current Amiga
hardware supports6 and 8 planes, so for now you should only use thisvalues.
419
-normal (default) Turnsoff -hamif/-24if/-dcif, -hamforce/-24force/-dcforce and -cmaponly. Also sets
compression type to byterun1.
-hamif (*), -24if (*), Write a HAM/24-bit/direct color file if the pixmap doesnot fit into maxplanes planes.
-dcif (*)
-hamforce (*), -24force (*), Write a HAM/24-bit/direct color file.
-dcforce (*)
-dcbits | -dcplanes r g b (default 5, min 1, max 16). Select number of bitsfor red, green, and blue in a direct color
ILBM.
-ecs (default) Shortcut for: -hamplanes 6 -maxplanes 5
-aga Shortcut for: -hamplanes 8 -maxplanes 8
-ham6 Shortcut for: -hamplanes 6 -hamforce
-ham8 Shortcut for: -hamplanes 8 -hamforce
-compress (*) (default), Compressthe BODY chunk. The default compression method isbyterun1. Compression
-cmethod none|byterun1 requiresbuilding the ILBM image in memory; turning compression off allowsstream-
writing of the image, but the resulting file will usually be 30 percent to 50 percent larger.
Another alternative isthe -savemem option; thiswill keep memory requirementsfor
compression at a minimum, but isvery slow.
-map ppmf i l e Write a normal ILBM using the colorsin ppmf i l e asthe colormap. The colormap file also
determinesthe number of planes; a -maxplanes or -fixplanes option isignored.
-cmaponly Write a colormap file: only BMHD and CMAP chunks, no BODY chunk, nPlanes = 0.
-savemem See the -compress option.
BUGS
HAM pictureswill alwaysget a grayscale colormap; a real color selection algorithm might give better results. On the other
hand, thisallowsrow-by-row operation on HAM images, and all HAM imagesof the same depth (number of planes) share a
common colormap, which isuseful for building HAM animations.
REFERENCES
Amiga ROM Kernel Reference ManualDevices(Third Edition), Addison Wesley, ISBN 0-201-56775-X
SEE ALSO
ppm(5), ilbmtoppm(1)
AUTHORS
Copyright
1991 by ChristosZoulas.
13 July1991
ppmtopj
Part I: User Commands
424
ppmtopjxl
ppmtopjxlConvert a portable pixmap into an HP PaintJet XL PCL file
SYNOPSIS
ppmtopjxl [-nopack] [-gamma <n> ] [-presentation] [-dark] [-diffuse]
[-cluster] [-dither] [-xshift <s> ] [-yshift <s> ] [-xshift <s> ] [-yshift <s> ]
[-xsize|-width|-xscale <s> ] [-ysize|-height|-yscale <s> ] [ppmf i l e]
DESCRIPTION
ppmtopjxl readsa portable pixmap asinput and producesa PCL file suitable for printing on an HP PaintJet XL printer as
output.
The generated file isnot suitable for printing on a normal PrintJet printer. The nopack option generatesa file that doesnot
use the normal TIFF 4.0 compression method. Thisfile might be printable on a normal PaintJet printer (not an XL).
The gamma option setsthe gamma correction for the image. The useful range for the PaintJet XL isapproximately 0.6
to 1.5.
The rendering algorithm used for imagescan be altered with the -dither, -cluster, and -diffuse options. These options
select ordered dithering, clustered ordered dithering, or error diffusion, respectively. The dark option can be used to
enhance imageswith a dark background when they are reduced in size. The presentation option turnson presentation
mode, in which two passesare made over the paper to increase ink density. Thisshould be used only for imageswhere
quality iscritical.
The image can be resized by setting the xsize and ysize options. The parameter to either of these optionsisinterpreted as
the number of dotsto set the width or height to, but an optional dimension of pt (points), dp (decipoints), in (inches), or cm
(centimeters) may be appended. If only one dimension isspecified, the other will be scaled appropriately.
The optionswidth and height are synonymsof xsize and ysize.
The xscale and yscale optionscan alternatively be used to scale the image by a simple factor.
The image can be shifted on the page by using the xshift and yshift options. These move the image the specified
dimensionsright and down.
SEE ALSO
ppm(5)
AUTHOR
AngusDuggan
14 March 1991
ppmtopuzz
ppmtopuzzConvert a portable pixmap into an X11 puzzle file
SYNOPSIS
ppmtopuzz [ppmf i l e]
DESCRIPTION
ppmtopuzz readsa portable pixmap asinput and producesan X11 puzzle file asoutput. A puzzle file isfor use with the puzzle
program included with the X11 distribution; puzzles-picture flag letsyou specify an image file.
425
SEE ALSO
ppm(5), puzzle(1)
AUTHOR
Copyright
1991 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim copiesof this
manual provided the copyright notice and thispermission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
Cygnussupport, 5 November 1991
rasttopnm
rasttopnmConvert a Sun raster file into a portable anymap
SYNOPSIS
rasttopnm [r ast f i l e]
DESCRIPTION
rasttopnm readsa Sun raster file asinput and producesa portable anymap asoutput. The type of the output file dependson
the input fileif itsblack and white, a pbm file iswritten; else if itsgrayscale, a pgm file; else a ppm file. The program tellsyou
which type it iswriting.
SEE ALSO
pnmtorast(1), pnm(5)
AUTHOR
Copyright 1989, 1991 byJef Poskanzer.
13 January1991
439
rawtopgm
rawtopgmConvert raw grayscale bytesinto a portable graymap
SYNOPSIS
rawtopgm [-headerskip N][-rowskip N][-tb|-topbottom][wi dt h hei ght ][i magedat a]
DESCRIPTION
rawtopgm readsraw grayscale bytesasinput and producesa portable graymap asoutput. The input file isjust grayscale bytes.
If you dont specify the width and height on the command line, the program will check the size of the image and try to make
a quadratic image of it. It isan error to supply a non-quadratic image without specifying width and height. The maxval is
assumed to be 255.
OPTIONS
-headerskip If the file hasa header, you can use thisflag to skip over it.
-rowskip If there ispadding at the endsof the rows, you can skip it with thisflag. Note that rowskip can be a real
number. Amazingly, I once had an image with 0.376 bytesof padding per row. Thisturned out to be due
to a file transfer problem, but I wasstill able to read the image.
-tb -topbottom Flipsthe image upside down. The first pixel in a pgm file isin the lower-left corner of the image. For
conversion from imageswith the first pixel in the upper-left corner (for example, the Molecular Dynamics
and Leica confocal formats), thisflipsthe image right. Thisisequivalent to rawtopgm [file] | pnmflip
-tb.
BUGS
If you dont specify the image width and height, the program will try to read the entire image to a memory buffer. If you get
a message that statesthat you are out of memory, try to specify the width and height on the command line. Also, the -tb
option consumesmuch memory.
SEE ALSO
pgm(5), rawtoppm(1), pnmflip(1)
AUTHORS
Copyright
1991 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim copiesof this
manual, provided the copyright notice and thispermission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
size
Part I: User Commands
490
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
CygnusSupport, 5 November 1991
sldtoppm
sldtoppmConvert an AutoCAD slide file into a portable pixmap
SYNOPSIS
sldtoppm [-adjust][-dir][-height|-ysize s][-info][-lib|-Lib name][-scale s]
[-verbose][-width|-xsize s][sl i def i l e]
DESCRIPTION
sldtoppm readsan AutoCAD slide file and outputsa portable pixmap. If no slidefile isspecified, input isread from
standard input. The ppmdraw library isused to convert the vector and polygon information in the slide file to a pixmap; see
the file ppmdraw.h for detailson thispackage.
OPTIONS
-adjust If the display on which the slide file wascreated had nonsquare pixels, when the slide isprocessed with
sldtoppm and the -adjust option isnot present, the following warning will appear: Warning - pixels on
source screen were non-square.
Specifying -adjust will correct image width to compensate. Specifying the -adjust option causes
sldtoppm to scale the width of the image so that pixelsin the resulting portable pixmap are square (and
hence circlesappear astrue circles, not ellipses). The scaling isperformed in the vector domain, before
scan-converting the objects. The resultsare, therefore, superior in appearance to what youd obtain were
you to perform the equivalent scaling with pnmscale after the bitmap had been created.
-dir The input isassumed to be an AutoCAD slide library file. A directory listing each slide in the library is
printed on standard error.
-height si ze Scalesthe image in the vector domain so it issi ze pixelsin height. If no -width or -xsize option is
specified, the width will be adjusted to preserve the pixel aspect ratio.
-info Dump the slide file header on standard error, displaying the original screen size and aspect ratio among
other information.
-lib name Extractsthe slide with the given name from the slide library given asinput. The specified name isconverted
to uppercase.
-Lib name Extractsthe slide with the given name from the slide library given asinput. The name isused exactly as
specified; it isnot converted to uppercase.
-scale s Scalesthe image by factor s, which may be any floating-point value greater than zero. Scaling isdone after
aspect ratio adjustment, if any. Because scaling isperformed in the vector domain, before rasterization, the
resultslook much better than running the output of sldtoppm through pnmscale.
-verbose Dumpsthe slide file header and listsevery vector and polygon in the file on standard error.
-width si ze Scalesthe image in the vector domain, so it issize pixelswide. If no -height or -ysize option is
specified, the height will be adjusted to preserve the pixel aspect ratio.
-xsize si ze Scalesthe image in the vector domain so it issi ze pixelswide. If no -height or -ysize option isspecified,
the height will be adjusted to preserve the pixel aspect ratio.
-ysize si ze Scalesthe image in the vector domain so it issi ze pixelsin height. If no -width or -xsize option is
specified, the width will be adjusted to preserve the pixel aspect ratio.
All flagscan be abbreviated to their shortest unique prefix.
491
BUGS
Only Level 2 slidesare converted. Level 1 format hasbeen obsolete since the advent of AutoCAD Release 9 in 1987 and was
not portable acrossmachine architectures.
Slide library itemswith namescontaining 8-bit (such asISO) or 16-bit (Kanji, for example) charactersmay not be found
when chosen with the -lib option unlesssldtoppm hasbeen built with character set conversion functionsappropriate to the
locale. You can alwaysretrieve slidesfrom librariesregardlessof the character set by using the -Lib option and specifying the
precise name of library member. Use the -dir option to list the slidesin a library if youre unsure of the exact name.
SEE ALSO
AutoCAD ReferenceManual: Slide File Format; pnmscale(1), ppm(5)
AUTHOR
John Walker
Autodesk SA
Avenue desChamps-Montants14b
CH-2074 MARIN
Suisse/Schweiz/Svizzera/Svizra/Switzerland
Usenet: kelvin@Autodesk.com
Fax: 038/33 88 15
Voice: 038/33 76 33
Permission to use, copy, modify, and distribute thissoftware and itsdocumentation for any purpose and without fee is
hereby granted, without any conditionsor restrictions. Thissoftware isprovided asis without expressor implied warranty.
AutoCAD and Autodesk are registered trademarksof Autodesk, Inc.
10 October 1991
smproxy
smproxySession Manager Proxy
SYNOPSIS
smproxy [-clientId i d] [-restore saveFi l e]
OPTIONS
-clientId i d Specifiesthe session ID used by smproxy in the previoussession.
-restore saveFile Specifiesthe file used by smproxy to save state in the previoussession.
DESCRIPTION
smproxy allowsX applicationsthat do not support X11R6 session management to participate in an X11R6 session.
In order for smproxy to act asa proxy for an X application, one of the following must be true:
I The application mapsa top-level window containing the WM_CLIENT_LEADER property. Thisproperty providesa pointer
to the client leader window that containsthe WM_CLASS, WM_NAME, WM_COMMAND, and WM_CLIENT_MACHINE properties.
or
I The application mapsa top-level window that doesnot contain the WM_CLIENT_LEADER property. However, thistop-level
window containsthe WM_CLASS, WM_NAME, WM_COMMAND, and WM_CLIENT_MACHINE properties.
smproxy
Part I: User Commands
492
An application that supportsthe WM_SAVE_YOURSELF protocol will receive a WM_SAVE_YOURSELF client message each time the
session manager issuesa checkpoint or shutdown. Thisallowsthe application to save state. If an application doesnot
support the WM_SAVE_YOURSELF protocol, then the proxy will provide enough information to the session manager to restart
the application (using WM_COMMAND), but no state will be restored.
SEE ALSO
xsm(1)
AUTHOR
Ralph Mor, X Consortium
X Version 11 Release6
sort
sortSort linesof text files
SYNOPSIS
sort [-cmus] [-t separ at or ] [-o out put - f i l e] [-T t empdi r ] [-bdfiMnr]
[+POS1 [-POS2]] [-k POS1[,POS2]] [f i l e...]
sort {--help,--version}
DESCRIPTION
Thismanual page documentsthe GNU version of sort. sort sorts, merges, or comparesall the linesfrom the given files, or
the standard input if no filesare given. A filename of - meansstandard input. By default, sort writesthe resultsto the
standard output.
sort hasthree modesof operation: sort (the default), merge, and check for sortedness. The following optionschange the
operation mode:
-c Check whether the given filesare already sorted; if they are not all sorted, print an error message and exit with a
statusof 1.
-m Merge the given filesby sorting them asa group. Each input file should already be individually sorted. It always
worksto sort instead of merge; merging isprovided because it isfaster, in the case where it works.
A pair of linesiscompared asfollows: if any key fieldshave been specified, sort compareseach pair of fields, in the order
specified on the command line, according to the associated ordering options, until a difference isfound or no fieldsare left.
If any of the global optionsMbdfinr are given but no key fieldsare specified, sort comparesthe entire linesaccording to the
global options.
Finally, asa last resort when all keyscompare equal (or if no ordering optionswere specified at all), sort comparesthe lines
byte by byte in machine collating sequence. The last resort comparison honorsthe -r global option. The -s (stable) option
disablesthislast-resort comparison so that linesin which all fieldscompare equal are left in their original relative order. If no
fieldsor global optionsare specified, -s hasno effect.
GNU sort hasno limitson input line length or restrictionson bytesallowed within lines. In addition, if the final byte of an
input file isnot a newline, GNU sort silently suppliesone.
If the environment variable TMPDIR isset, sort usesit asthe directory in which to put temporary filesinstead of the default,
/tmp. The -T tempdir option isanother way to select the directory for temporary files; it overridesthe environment
variable.
The following optionsaffect the ordering of output lines. They may be specified globally or aspart of a specific key field. If
no key fieldsare specified, global optionsapply to comparison of entire lines; otherwise, the global optionsare inherited by
key fieldsthat do not specify any special optionsof their own.
493
-b Ignore leading blankswhen finding sort keysin each line.
-d Sort in phone directory order; ignore all charactersexcept letters, digits, and blankswhen sorting.
-f Fold lowercase charactersinto the equivalent uppercase characterswhen sorting so that, for example, b issorted
the same way B is.
-i Ignore charactersoutside the ASCII range 0400176 octal (inclusive) when sorting.
-M An initial string, consisting of any amount of whitespace, followed by three lettersabbreviating a month name, is
folded to uppercase and compared in the order JAN < FEB < ... < DEC. Invalid namescompare low to
valid names.
-n Compare according to arithmetic value an initial numeric string consisting of optional whitespace, an optional -
sign, and zero or more digits, optionally followed by a decimal point and zero or more digits.
-r Reverse the result of comparison, so that lineswith greater key valuesappear earlier in the output instead of later.
Other optionsare
-o out put - f i l e Write output to out put - f i l e instead of to the standard output. If out put - f i l e isone of the input
files, sort copiesit to a temporary file before sorting and writing the output to out put - f i l e.
-t separ at or Use character separ at or asthe field separator when finding the sort keysin each line. By default,
fieldsare separated by the empty string between a nonwhitespace character and a whitespace
character. That isto say, given the input line foo bar, sort breaksit into fieldsfoo and bar. The
field separator isnot considered to be part of either the field preceding or the field following it.
-u For the default case or the -m option, only output the first of a sequence of linesthat compare
equal. For the -c option, check that no pair of consecutive linescomparesequal.
+POS1 [-POS2] Specify a field within each line to use asa sorting key. The field consistsof the portion of the line
starting at POS1 and up to (but not including) POS2 (or to the end of the line if POS2 isnot given).
The fieldsand character positionsare numbered starting with 0.
-k POS1[,POS2] An alternate syntax for specifying sorting keys. The fieldsand character positionsare numbered
starting with 1.
A position hasthe form f.c, where f isthe number of the field to use and c isthe number of the first character from the
beginning of the field (for +pos) or from the end of the previousfield (for -pos). The .c part of a position may be omitted,
in which case it istaken to be the first character in the field. If the -b option hasbeen given, the .c part of a field specifica-
tion iscounted from the first nonblank character of the field (for +pos) or from the first nonblank character following the
previousfield (for -pos).
A +pos or -pos argument may also have any of the option lettersMbdfinr appended to it, in which case the global ordering
optionsare not used for that particular field. The -b option may be independently attached to either or both of the +pos and
-pos partsof a field specification, and if it isinherited from the global options, it will be attached to both. If a -n or -M
option isused, thusimplying a -b option, the -b option istaken to apply to both the +pos and the -pos partsof a key
specification. Keysmay span multiple fields.
In addition, when GNU join isinvoked with exactly one argument, the following optionsare recognized:
--help Print a usage message on standard output and exit successfully
--version Print version information on standard output, then exit successfully
COMPATIBILITY
Historical (BSD and System V) implementationsof sort have differed in their interpretation of some options, particularly
-b, -f, and -n. GNU sort followsthe POSIX behavior, which isusually (but not always) like the System V behavior.
According to POSIX, -n no longer implies-b. For consistency, -M hasbeen changed in the same way. Thismay affect the
meaning of character positionsin field specificationsin obscure cases. If thisbitesyou, the fix isto add an explicit -b.
BUGS
The different meaning of field numbersdepending on whether -k isused isconfusing. Itsall POSIXsfault!
GNU Text Utilities
sort
Part I: User Commands
494
spctoppm
spctoppmConvert an Atari compressed Spectrum file into a portable pixmap
SYNOPSIS
spctoppm [spcf i l e]
DESCRIPTION
spctoppm readsan Atari compressed Spectrum file asinput and producesa portable pixmap asoutput.
SEE ALSO
sputoppm(1), ppm(5)
AUTHOR
Copyright
1993 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim copiesof this
manual provided the copyright notice and thispermission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
CygnusSupport, 25 June1993
499
strip
stripDiscard symbolsfrom object files.
SYNOPSIS
strip [ -Fbf dname|--target=bf dname ] [ -Ibf dname|
--input-target=bf dname ] [ -Obf dname|--output-target=bf dname ]
[-Rsect i onname|--remove-section=sect i onname ] [ -s|--strip-all ]
[-S|-g|--strip-debug ][-x|--discard-all ][-X|--discard-locals]
[-v|--verbose ][-V|--version ][-V|--help ] obj f i l e ...
DESCRIPTION
GNU strip discardsall symbolsfrom the object filesobj f i l e. The list of object filesmay include archives. At least one
object file must be given.
strip modifiesthe filesnamed in itsargument, rather than writing modified copiesunder different names.
OPTIONS
-F bf dname, --target=bf dname Treat the original obj f i l e asa file with the object code format
bf dname, and rewrite it in the same format.
--help Show a summary of the optionsto strip and exit.
-I bf dnamefdname, --input-target=bf dname Treat the original obj f i l e asa file with the object code format
bf dname.
-O bf dname, --output-target=bf dname Replace obj f i l e with a file in the output format bf dname.
-R sect i onname, --remove-section=sect i onname Remove the named section from the file. Thisoption may be given
more than once. Note that using thisoption inappropriately may
make the object file unusable.
-s, --strip-all Remove all symbols.
-S, -g, --strip-debug Remove debugging symbolsonly.
-x, --discard-all Remove nonglobal symbols.
-X, --discard-locals Remove compiler-generated local symbols. (These usually start with L
or a period.
-v, --verbose Verbose output: list all object filesmodified. In the case of archives,
strip -V listsall membersof the archive.
-V, --version Show the version number for strip and exit.
SEE ALSO
binutils entry in info; TheGNU BinaryUtilities, Roland H. Pesch (October 1991)
COPYING
Copyright
1991 Free Software Foundation, Inc. Permission isgranted to make and distribute verbatim copiesof this
manual provided the copyright notice and thispermission notice are preserved on all copies.
Permission isgranted to copy and distribute modified versionsof thismanual under the conditionsfor verbatim copying,
provided that the entire resulting derived work isdistributed under the termsof a permission notice identical to thisone.
Permission isgranted to copy and distribute translationsof thismanual into another language, under the above conditions
for modified versions, except that thispermission notice may be included in translationsapproved by the Free Software
Foundation instead of in the original English.
CygnusSupport, 5 November 1991
strip
Part I: User Commands
500
subst
substSubstitute definitionsinto file(s)
SYNOPSIS
subst [ -e edi t or ] -f subst i t ut i ons vi ct i m ...
DESCRIPTION
subst makessubstitutionsinto files, in a way that issuitable for customizing software to local conditions. Each vi ct i mfile is
altered according to the contentsof the subst i t ut i ons file.
The subst i t ut i ons file containsone line per substitution. A line consistsof two fieldsseparated by one or more tabs. The
first field isthe name of the substitution, the second isthe value. Neither should contain the character #, and use of text-
editor metacharacterslike & and \ isalso unwise; the name in particular isbest restricted to alphanumeric. A line starting with
# isa comment and isignored.
In the victim files, each line on which a substitution isto be made (a target line) must be preceded by a prototype line. The
prototype line should be delimited in such a way that it will be taken asa comment by whatever program processesthe file
later. The prototype line must contain a prototype of the target line bracketed by =()< and >()=; everything else on the
prototype line isignored. subst extractsthe prototype, changesall instancesof substitution namesbracketed by @< and >@ to
their values, and then replacesthe target line with the result.
Substitutionsare done using the sed(1) editor, which must be found in either the /bin or /usr/bin directories. To specify a
different executable, use the -e flag.
EXAMPLE
If the subst i t ut i ons file is
FIRST 111
SECOND 222
and the victim file is
x =2;
/* =()<y =@<FIRST>@+@<SECOND>@;>()= */
y =88 +99;
z =5;
then subst -f substitutions victim changesvictim to
x =2;
/* =()<y =@<FIRST>@+@<SECOND>@;>()= */
y = 111 + 222;
z =5;
FILES
vi ct i mdi r /substtmp.new New version being built
vi ct i mdi r /substtmp.old Old version during renaming
SEE ALSO
sed(1)
DIAGNOSTICS
Complainsand haltsif it isunable to create itstemporary filesor if they already exist.
501
HISTORY
Written at University of Toronto by Henry Spencer.
Rich $alz added the -e flag July, 1991.
BUGS
When creating a file to be substed, itseasy to forget to insert a dummy target line after a prototype line; if you forget, subst
endsup deleting whichever line did in fact follow the prototype line.
Local
sum
sumChecksum and count the blocksin a file
SYNOPSIS
sum [-rs] [--sysv] [--help] [--version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of sum. sum computesa 16-bit checksum for each named file, or the standard
input if none are given or when a file named - isgiven. It printsthe checksum for each file along with the number of blocks
in the file (rounded up). By default, each corresponding filename isalso printed if at least two argumentsare specified. With
the --sysv option, corresponding filenamesare printed when there isat least one file argument. By default, the GNU sum
computeschecksumsusing an algorithm that iscompatible with the BSD sum and printsfile sizesin unitsof 1K blocks.
OPTIONS
-r Use the default (BSD-compatible) algorithm. Thisoption isincluded for compatibility with the System V
sum. Unlessthe -s option wasalso given, it hasno effect.
-s, --sysv Compute checksumsusing an algorithm that iscompatible with the one the System V sum usesby default
and print file sizesin unitsof 512-byte blocksinstead of 1K.
--help Print a usage message and exit with a non-zero status.
--version Print version information on standard output, then exit.
GNU Text Utilities
SuperProbe
SuperProbeProbe for and identify installed video hardware
SYNOPSIS
SuperProbe [-verbose] [-no16] [-excl l i st ] [-mask10] [-order l i st ] [-noprobe l i st ] [-bios base]
[-no bios] [-no dac] [-no mem] [-info]
DESCRIPTION
SuperProbe isa program that will attempt to determine the type of video hardware installed in an EISA/ISA/VLB-bus
system by checking for known registersin variouscombinationsat variouslocations(MicroChannel and PCI machinesmay
not be fully supported; many work with the use of the -no_bios option.) Thisisan error-prone process, especially on UNIX
(which usually hasa lot more esoteric hardware installed than MS-DOSsystemsdo), so SuperProbe may likely need help
from the user.
SuperProbe
Part I: User Commands
502
SuperProbe runson SVR3, SVR4, Linux, 386BSD/FreeBSD/NetBSD, Minix-386, and Mach. It should be trivial to extend
it to work on any other UNIX-like operating system, and even non-UNIX operating systems. All of the operating system
(OS) dependenciesare isolated to a single file for each OS.
At thistime, SuperProbe can identify MDA, Hercules, CGA, MCGA, EGA, VGA, and an entire horde of SVGA chipsets.
(See the -info option under Options.) It can also identify several HiColor/True-color RAMDACsin use on SVGA
boards, and the amount of video memory installed (for many chipsets). It can identify 8514/A and some derivatives, but not
XGA, or PGC (although the author intendsto add those capabilities). Nor can it identify other esoteric video hardware (like
Targa, TIGA, or Microfield boards).
OPTIONS
-verbose SuperProbe will be verbose and provide lotsof information asit doesitswork.
-no16 SuperProbe will not attempt to use any portsthat require 16-bit I/O addressdecoding. The original ISA
busonly specified that I/O portsbe decoded to 10 bits. Therefore, some old cards(including many 8-bit
cards) will misdecode referencesto portsthat use the upper 6 bits, and may get into funny statesbecause
they think that they are being addressed when they are not. It isrecommended that thisoption be used
initially if any 8-bit cardsare present in the system.
-excl\l i st SuperProbe will not attempt to accessany I/O portson the specified exclusion list. Some video cardsuse
rather nonstandard I/O portsthat may conflict with other cardsinstalled in your system. By specifying to
SuperProbe, a list of portsalready in use, it will know that there cannot be any video cardsthat use those
ports, and hence will not probe them (which could otherwise confuse your hardware). The exclusion list is
specified asa comma-separated list of I/O portsor port ranges. A range isspecified asl ow-hi gh, and is
inclusive. The portscan be specified in decimal, in octal (numbersbegin with 0), or hexadecimal (numbers
begin with 0x).
- mask10 Thisoption isused in combination with -excl. It tellsSuperProbe that when comparing an I/O port
under test against the exclusion list, the port addressshould be masked to 10 bits. Thisisimportant with
older 8-bit cardsthat only do 10-bit decoding, and for some cheap 16-bit cardsaswell. Thisoption is
simply a lessdrastic form of the -no16 option.
-order\l i st Thisoption specifieswhich chipsetsSuperProbe should test, and in which order. The list parameter isa
comma-separated list of chipset names. Thislist overridesthe built-in default testing order. To find the list
of acceptable names, use the - info option described later in thislist. Note that itemsdisplayed as
Standard video hardware are not usable with the -order option.
-noprobe\l i st Thisoption specifieswhich chipsetsSuperProbe should not test. The order of testing will either be the
default order, or that specified with the -order option. The list parameter isa comma-separated list of
chipset names. To find the list of acceptable names, use the -info option. Note that itemsdisplayed as
Standard video hardware are not usable with the -noprobe option.
-bios\base Thisoption specifiesthe base addressfor the graphics-hardware BIOS. By default, SuperProbe will
attempt to locate the BIOS base on itsown (the normal addressis0xC0000). If it failsto correctly locate
the BIOS (an error message will be printed if thisoccurs), the -bios option can be used to specify the
base.
-no_bios Disallow reading of the video BIOS and assume that an EGA or later (VGA, SVGA) board ispresent as
the primary video hardware.
-no_dac Skip probing for the RAMDAC type when an (S)VGA isidentified.
-no_mem Skip probing for the amount of installed video memory.
-info SuperProbe will print out a listing of all the video hardware that it knowshow to identify.
EXAMPLES
To run SuperProbe in itsmost basic and automated form, simply enter the following:
SuperProbe
503
NOTE
You may want to redirect stdout to a file when you run SuperProbe (especially if your OS doesnot support Virtual
Terminalson the console).
However, if you have any 8-bit cardsinstalled, you should initially run SuperProbe as
SuperProbe -verbose -no16
(the -verbose option isincluded so you can see what SuperProbe isskipping).
Finer granularity can be obtained with an exclusion list, for example,
SuperProbe -verbose -excl 0x200,0x220-0x230,0x250
will not test for any device that usesport 0x200, ports0x220 through 0x230, inclusive, or port 0x250. If you have any 8-bit
cardsinstalled, you should add -mask10 to the list of options.
To restrict the search to Western Digital, Tseng, and Cirruschipset, run SuperProbe asfollows:
SuperProbe -order WD,Tseng,Cirrus
BUGS
Probably a lot at thispoint. Please report any bugsor incorrect identificationsto the author.
It ispossible that SuperProbe can lock up your machine. Be sure to narrow the search by using the -no16, -excl, and -
mask10 optionsprovided to keep SuperProbe from conflicting with other installed hardware.
SEE ALSO
The vgadoc3.zip documentation package by Finn Thoegersen, available in the MS-DOS archivesof many FTP repositories.
ProgrammersGuideto theEGA and VGA Cards, Second Edition, by Richard Ferraro.
AUTHOR
David E. Wexelblat (dwex@xfree86.org) with help from David Dawes(dawes@xfree86.org) and the XFree86 development
team.
Version 2.2
tac
tacConcatenate and print filesin reverse
SYNOPSIS
tac [-br] [-s separator] [--before] [--regex] [--separator=separ at or ]
[--help] [--version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of tac. tac copieseach given file, or the standard input if none are given or
when a filename of - isencountered, to the standard output with the order of the recordsreversed. The recordsare separated
by instancesof a string, or a newline if none isgiven. By default, the separator string isattached to the end of the record that
it followsin the file.
tac
Part I: User Commands
504
OPTIONS
-b, --before The separator isattached to the beginning of the record that it precedesin the file.
-r, --regex The separator isa regular expression.
-s st r i ng, --separator=st r i ng Use st r i ng asthe record separator.
--help Print a usage message and exit with a non-zero status.
--version Print version information on standard output, then exit.
GNU Text Utilities
tail
tailOutput the last part of files
SYNOPSIS
tail [-c [+]N[bkm]] [-n [+]N] [-fqv] [--bytes=[+]N[bkm]] [--lines=[+]N]
[--follow] [--quiet] [--silent] [--verbose] [--help] [--version] [f i l e...]
tail [{-,+}Nbcfklmqv] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of tail. tail printsthe last part (10 linesby default) of each given file; it
readsfrom standard input if no filesare given or when a filename of - isencountered. If more than one file isgiven, it prints
a header consisting of the filesname enclosed in ==> and <== before the output for each file.
The GNU tail can output any amount of data, unlike the UNIX version, which usesa fixed size buffer. It hasno -r option
(print in reverse). Reversing a file isreally a different job from printing the end of a file; the BSD tail can only reverse files
that are at most aslarge asitsbuffer, which istypically 32KB. A reliable and more versatile way to reverse filesisthe GNU
tac command.
OPTIONS
tail acceptstwo option formats: the new one, in which numbersare argumentsto the option letters, and the old one, in
which a + or - and optional number precede any option letters.
If a number (N) startswith a +, tail beginsprinting with the Nth item from the start of each file, instead of from the end.
-c N, --bytes N Tail by N bytes. N isa non-zero integer, optionally followed by one of the following charactersto
specify a different unit.
b 512-byte blocks
k 1-kilobyte blocks
m 1-megabyte blocks
-f, --follow Loop forever, trying to read more charactersat the end of the file, on the assumption that the file
isgrowing. Ignored if reading from a pipe. If more than one file isgiven, tail printsa header
whenever it getsoutput from a different file, to indicate which file that output isfrom.
-l, -n N, --lines N Tail by N lines. -l isonly recognized using the old option format.
-q, --quiet, --silent Never print filename headers.
-v, --verbose Alwaysprint filename headers.
--help Print a usage message and exit with a non-zero status.
--version Print version information on standard output then exit.
GNU Text Utilities
505
talk
talkTalk to another user
SYNOPSIS
talk per son [t t yname]
DESCRIPTION
talk isa visual communication program that copieslinesfrom your terminal to that of another user.
The following optionsare available:
per son If you wish to talk to someone on your own machine, then person isjust the personslogin name. If you
wish to talk to a user on another host, then person isof the form user @host .
t t yname If you wish to talk to a user who islogged in more than once, the t t yname argument may be used to
indicate the appropriate terminal name, where t t yname isof the form
t t yxx
When first called, talk sendsthe message Message from TalkDaemon@his_machine...:
talk: connection requested by your_name@your_machine
talk: respond with: talk your_name@your_machine
to the user you wish to talk to. At thispoint, the recipient of the message should reply by typing
t al k your _name@your _machi ne
It doesnt matter from which machine the recipient replies, aslong ashislogin name isthe same. Once communication is
established, the two partiesmay type simultaneously, with their output appearing in separate windows. Typing control-L
L will cause the screen to be reprinted, while your erase, kill, and word kill characterswill behave normally. To exit,
just type your interrupt character; talk then movesthe cursor to the bottom of the screen and restoresthe terminal to its
previousstate.
Permission to talk may be denied or granted by use of the mesg 1 command. At the outset, talking isallowed. Certain
commands, in particular nroff 1 and pr 1, disallow messagesin order to prevent messy output.
FILES
/etc/hosts To find the recipientsmachine
/var/run/utmp To find the recipientstty
SEE ALSO
mail(1), mesg(1), who(1), write(1)
BUGS
The version of talk 1 released with BSD 4.3 usesa protocol that isincompatible with the protocol used in the version
released with BSD 4.2.
HISTORY
The talk command appeared in BSD 4.2.
BSD 4.2, 22 April 1991
talk
Part I: User Commands
506
tcal
tcalRunsthe gcal program with the date of tomorrowsday
SYNOPSIS
tcal [ --help | --version ] | [ --shift=[+|-]number ][Argument... ]
DESCRIPTION
tcal isa program that runsgcal with a date set one day ahead (equivalent to the --shift=1 option). All given arguments
are passed unmodified to the gcal program. If the gcal program shall be called with a date other than tomorrowsdate, this
desired date can be selected by using the --shift=[+|-]number option, in which [+|-]number isthe number of daysthe
desired date isdistant from the actual date. The --shift option must be given before all other arguments, which are passed
to the gcal program. An exit statusof 0 meansall processing issuccessfully done; any other value meansan error has
occurred.
OPTIONS
--help Print a usage message listing all available options, then exit successfully.
--version Print the version number, then exit successfully.
--shift=[+|-]number Define the displacement in [+|-]number daysthe desired date isdistant from the actual date.
ENVIRONMENT
GCALPROG The GCALPROG environment variable containsthe filename of the executable gcal program, which
isused by tcal to call gcal. Takesprecedence over the filename gcal, which isburned-in during
the compilation step of tcal.
COPYRIGHT
Copyright
1995, 1996 by ThomasEsken. Thissoftware doesnt claim completeness, correctness, or usability. On principle,
I will not be liable for any damagesor losses(implicit or explicit), which result from using or handling my software. If you
use thissoftware, you agree without any exception to thisagreement, which bindsyou LEGALLY.
tcal isfree software and distributed under the termsof the GNU General Public License; published by the Free Software
Foundation; version 2 or (at your option) any later version.
Any suggestions, improvements, extensions, bug reports, donations, proposalsfor contract work, and so forth are welcome! If
you like thistool, Id appreciate a postcard from you!
Enjoy it =8)
AUTHOR
ThomasEsken (esken@uni-muenster.de)
m Hagenfeld 84
D-48147 Muenster; Germany
Phone : +49 251 232585
SEE ALSO
gcal(1)
16 July1996
507
telnet
telnetUser interface to the Telnet protocol
SYNOPSIS
telnet [-d] [-a] [-n tracefile] [-e escapechar] [[-l user] host [port]]
DESCRIPTION
The telnet command isused to communicate with another host using the Telnet protocol. If telnet isinvoked without the
host argument, it enterscommand mode, indicated by itsprompt telnet>. In thismode, it acceptsand executesthe
commandslisted below. If it isinvoked with arguments, it performsan open command with those arguments.
OPTIONS
-d Setsthe initial value of the debug toggle to True.
-a Attempt automatic login. Currently, thissendsthe username via the USER variable of the ENVIRON
option if supported by the remote system. The name used isthat of the current user asreturned
by getlogin 2 if it agreeswith the current user ID; otherwise, it isthe name associated with the
user ID.
-n tracefile Openstracefile for recording trace information. See the set tracefile command in the
Commands section.
-l user When connecting to the remote system, if the remote system understandsthe ENVIRON option, then
user will be sent to the remote system asthe value for the variable USER. Thisoption impliesthe -a
option. Thisoption may also be used with the open command.
-e escape char Setsthe initial telnet escape character to escape char. If escape char isomitted, then there will
be no escape character.
host Indicatesthe official name, an alias, or the Internet addressof a remote host.
port Indicatesa port number (addressof an application). If a number isnot specified, the default telnet
port isused.
Once a connection hasbeen opened, telnet will attempt to enable the TELNETLINEMODE option. If thisfails, then telnet will
revert to one of two input modeseither character-at-a-time or old line-by-line, depending on what the remote system
supports.
When LINEMODE isenabled, character processing isdone on the local system, under the control of the remote system. When
input editing or character echoing isto be disabled, the remote system will relay that information. The remote system will
also relay changesto any special charactersthat happen on the remote system, so that they can take effect on the local system.
In character-at-a-time mode, most text typed isimmediately sent to the remote host for processing.
In old line-by-line mode, all text isechoed locally, and (normally) only completed linesare sent to the remote host. The local
echo character (initially E) may be used to turn off and on the local echo. (Thiswould mostly be used to enter passwords
without the password being echoed.)
If the LINEMODE option isenabled, or if the localchars toggle isTrue (the default for old line-by-line), the usersquit, intr,
and flush charactersare trapped locally, and sent asTelnet protocol sequencesto the remote side. If LINEMODE hasever been
enabled, then the userssusp and eof are also sent asTelnet protocol sequences, and quit issent asa TELNET ABORT instead
of BREAK There are options(see toggle autoflush and toggle autosynch in the following list) that cause thisaction to
flush subsequent output terminal (until the remote host acknowledgesthe telnet sequence) and flush previousterminal
input (in the case of quit and intr).
telnet
Part I: User Commands
508
COMMANDS
While connected to a remote host, telnet command mode may be entered by typing the telnet escape character (initially
]). When in command mode, the normal terminal editing conventionsare available.
The following telnet commandsare available. Only enough of each command to uniquely identify it need be typed. (This
isalso true for argumentsto the mode, set, toggle, unset, slc, environ, and display commands.)
close Close a telnet session and return to command mode.
display argument... Displaysall, or some, of the set and toggle values.
mode t ype t ype isone of several options, depending on the state of the telnet session. The remote host is
asked for permission to go into the requested mode. If the remote host iscapable of entering that
mode, the requested mode will be entered. The t ype optionsare
character Disable the TELNET LINEMODE option, or, if the remote side doesnot
understand the LINEMODE option, then enter character at a time mode.
line Enable the TELNET LINEMODE option, or, if the remote side doesnot
understand the LINEMODE option, then attempt to enter old-line-by-line
mode.
isig -isig Attempt to enable (disable) the TRAPSIG mode of the LINEMODE option. This
requiresthat the LINEMODE option be enabled.
edit -edit Attempt to enable (disable) the EDIT mode of the LINEMODE option. This
requiresthat the LINEMODE option be enabled.
softtabs Attempt to enable (disable) the SOFT_TAB mode of the LINEMODE option. This
requiresthat -softtabsthe LINEMODE option be enabled.
litecho -litecho Attempt to enable (disable) the LIT_ECHO mode of the LINEMODE option. This
requiresthat the LINEMODE option be enabled.
? Printsout help information for the mode command.
open host Open a connection to the named host. If no port number isspecified, telnet will attempt to [-l
user ] [-por t ] contact a Telnet server at the default port. The host specification may be either a hostname (see
hosts(5)for more information) or an Internet addressspecified in the dot notation (see inet(3) for
more information). The -l option may be used to specify the username to be passed to the remote
system via the ENVIRON option. When connecting to a nonstandard port, telnet omitsany
automatic initiation of telnet options. When the port number ispreceded by a minussign, the
initial option negotiation isdone. After establishing a connection, the file in the usershome
directory isopened. Linesbeginning with a # are comment lines. Blank linesare ignored. Linesthat
begin without whitespace are the start of a machine entry. The first thing on the line isthe name of
the machine that isbeing connected to. The rest of the line, and successive linesthat begin with
whitespace, are assumed to be telnet commandsand are processed asif they had been typed in
manually to the telnet command prompt.
quit Close any open telnet session and exit telnet. An end-of-file (in command mode) will also close a
session and exit.
send arguments Sendsone or more special character sequencesto the remote host. The following are the arguments
that may be specified (more than one argument may be specified at a time):
abort Sendsthe TELNET ABORT (Abort Processes) sequence.
ao Sendsthe TELNET AO (Abort Output) sequence, which should cause the
remote system to flush all output from the remote system to the users
terminal.
ayt Sendsthe TELNET AYT (Are You There) sequence, to which the remote
system may or may not choose to respond.
brk Sendsthe TELNET BRK (Break) sequence, which may have significance to the
remote system.
509
ec Sendsthe TELNET EC (Erase Character) sequence, which should cause the
remote system to erase the last character entered.
el Sendsthe TELNET EL (Erase Line) sequence, which should cause the remote
system to erase the line currently being entered.
eof Sendsthe TELNET EOF (End-of-File) sequence.
eor Sendsthe TELNET EOR (End of Record) sequence.
escape Sendsthe current telnet escape character (initially ).
ga Sendsthe TELNET GA (Go Ahead) sequence, which likely hasno significance
to the remote system.
getstatus If the remote side supportsthe TELNET STATUS command, getstatus will
send the subnegotiation to request that the server send itscurrent option
status.
ip Sendsthe TELNET IP (Interrupt Process) sequence, which should cause the
remote system to abort the currently running process.
nop Sendsthe TELNET NOP (no operation) sequence.
susp Sendsthe TELNET SUSP (suspend process) sequence.
synch Sendsthe TELNET SYNCH sequence. Thissequence causesthe remote system
to discard all previously typed (but not yet read) input. Thissequence issent
asTCP urgent data (and may not work if the remote system isa BSD 4.2
systemif it doesnt work, a lowercase r may be echoed on the terminal).
? Printsout help information for the send command.
set argument value, The set command will set any one of a number of telnet variablesto a specific value or to True.
unset argument value The special value off turnsoff the function associated with the variable; thisisequivalent to using
the unset command. The unset command will disable or set to False any of the specified
functions. The valuesof variablesmay be interrogated with the display command. The variables
that may be set or unset, but not toggled, are listed here. In addition, any of the variablesfor the
toggle command may be explicitly set or unset using the set and unset commands.
echo Thisisthe value (initially E) which, when in line-by-line mode, toggles
between doing local echoing of entered characters(for normal processing),
and suppressing echoing of entered characters(for entering, say, a password).
eof If telnet isoperating in LINEMODE or old line-by-line mode, entering this
character asthe first character on a line will cause thischaracter to be sent to
the remote system. The initial value of the eof character istaken to be the
terminalseof character.
erase If telnet isin localchars mode (see toggle localchars, following), and if
telnet isoperating in character at a time mode, then when thischaracter is
typed, a TELNET EC sequence (see send ec, earlier in thisman page) issent to
the remote system. The initial value for the erase character istaken to be the
terminalserase character.
escape Thisisthe telnet escape character (initially [) which causesentry into
telnet command mode (when connected to a remote system).
flushoutput If telnet isin localchars mode (see toggle localchars) and the
flushoutput character istyped, a TELNET AO sequence issent to the remote
host. The initial value for the flush character istaken to be the terminals
flush character.
interrupt If telnet isin localchars mode (see toggle localchars) and the interrupt
character istyped, a TELNET IuP sequence issent to the remote host. The
initial value for the interrupt character istaken to be the terminalsintr
character.
telnet
Part I: User Commands
510
kill If telnet isin localchars mode (see toggle localchars), and if telnet is
operating in character at a time mode, then when thischaracter istyped, a
TELNET EL sequence issent to the remote system. The initial value for the
kill character istaken to be the terminalskill character.
lnext If telnet isoperating in LINEMODE or old line-by-line mode, then this
character istaken to be the terminalslnext character. The initial value for
the lnext character istaken to be the terminalslnext character.
quit If telnet isin localchars mode (see toggle localchars) and the quit
character istyped, a TELNET BRK sequence issent to the remote host. The
initial value for the quit character istaken to be the terminalsquit
character.
reprint If telnet isoperating in LINEMODE or old line-by-line mode, then this
character istaken to be the terminalsreprint character. The initial value for
the reprint character istaken to be the terminalsreprint character.
start If the TELNETTOGGLE-FLOW-CONTROL option hasbeen enabled, then this
character istaken to be the terminalsstart character. The initial value for
the start character istaken to be the terminalsstart character.
stop If the TELNETTOGGLE-FLOW-CONTROL option hasbeen enabled, then this
character istaken to be the terminalsstop character. The initial value for the
kill character istaken to be the terminalsstop character.
susp If telnet isin localchars mode, or LINEMODE isenabled, and the suspend
character istyped, a TELNET SUSP sequence issent to the remote host. The
initial value for the suspend character istaken to be the terminalssuspend
character.
tracefile Thisisthe file to which the output, caused by netdata or option tracing
being True, will be written. If it isset to -, then tracing information will be
written to standard output (the default).
worderase If telnet isoperating in LINEMODE or old line-by-line mode, then this
character istaken to be the terminalsworderase character. The initial value
for the worderase character istaken to be the terminalsworderase
character.
? Displaysthe set unset commands.
slc state The slc command (Set Local Characters) isused to set or change the state of the special characters
when the TELNETLINEMODE option hasbeen enabled. Special charactersare charactersthat get
mapped to telnet command sequences(like ip or quit) or line-editing characters(like erase and
kill). By default, the local special charactersare exported. The variablesare
export Switch to the local defaultsfor the special characters. The local default
charactersare those of the local terminal at the time telnet wasstarted.
import Switch to the remote defaultsfor the special characters. The remote default
charactersare those of the remote system at the time when the telnet
connection wasestablished.
check Verify the current settingsfor the current special characters. The remote side
isrequested to send all the current special character settings, and if there are
any discrepancieswith the local side, the local side will switch to the remote
value.
? Printsout help information for the slc command.
511
environ arguments... The environ command isused to manipulate the variablesthat may be sent through the TELNET
ENVIRON option. The initial set of variablesistaken from the usersenvironment, with only the
DISPLAY and PRINTER variablesbeing exported by default. The USER variable isalso exported if the
-a or -l optionsare used.
Valid argumentsfor the environ command are
define var i abl e val ue Define the variable var i abl e to have a value of val ue. Any variables
defined by thiscommand are automatically exported. The value may
be enclosed in single or double quotesso that tabsand spacesmay be
included.
undefine var i abl e Remove var i abl e from the list of environment variables.
export var i abl e Mark the variable var i abl e to be exported to the remote side.
unexport var i abl e Mark the variable var i abl e to not be exported unlessexplicitly asked
for by the remote side.
list List the current set of environment variables. Those marked with a *
will be sent automatically; other variableswill only be sent if explicitly
requested.
? Printsout help information for the environ command.
toggle arguments... Toggle (between True and False ) variousflagsthat control how telnet respondsto events. These
flagsmay be set explicitly to True or False using the set and unset commandslisted earlier. More
than one argument may be specified. The state of these flagsmay be interrogated with the display
command. Valid argumentsare
autoflush If autoflush and localchars are both True, then when the ao or
quit charactersare recognized (and transformed into telnet
sequences; see set for details), telnet refusesto display any data on
the usersterminal until the remote system acknowledges(via a
TELNET TIMING MARK option) that it hasprocessed those telnet
sequences. The initial value for thistoggle isTrue if the terminal user
had not done an stty noflsh; otherwise, False. (See stty(1) for
more details.)
autosynch If autosynch and localchars are both True, then when either the
intr or quit character istyped (see set for descriptionsof the intr
and quit characters), the resulting telnet sequence sent isfollowed by
the TELNET SYNCH sequence. Thisprocedure should cause the remote
system to begin throwing away all previously typed input until both
of the telnet sequenceshave been read and acted upon. The initial
value of thistoggle isFalse.
binary Enable or disable the TELNET BINARY option on both input and
output.
inbinary Enable or disable the TELNET BINARY option on input.
outbinary Enable or disable the TELNET BINARY option on output.
crlf If thisisTrue, then carriage returnswill be sent as<CR><LF>. If thisis
False, then carriage returnswill be sent as<CR><NUL>. The initial
value for thistoggle isFalse.
crmod Toggle carriage return mode. When thismode isenabled, most
carriage return charactersreceived from the remote host will be
mapped into a carriage return followed by a line feed. Thismode does
not affect those characterstyped by the user, only those received from
the remote host. Thismode isnot very useful unlessthe remote host
only sendscarriage return, but never line feed. The initial value for
thistoggle isFalse.
telnet
Part I: User Commands
512
debug Togglessocket level debugging (useful only to the super user). The
initial value for thistoggle isFalse.
localchars If thisisTrue, then the flush, interrupt, quit, erase, and kill
characters(see set) are recognized locally, and transformed into
(hopefully) appropriate telnet control sequences(respectively ao, ip,
brk, ec, and el ; see send). The initial value for thistoggle isTrue in
old line-by-line mode, and False in character at a time mode. When
the LINEMODE option isenabled, the value of localchars isignored,
and assumed to alwaysbe True. If LINEMODE hasever been enabled,
then quit issent asabort, and eof and suspend are sent aseof and
susp; see send.
netdata Togglesthe display of all network data (in hexadecimal format). The
initial value for thistoggle isFalse.
options Togglesthe display of some internal telnet protocol processing
(having to do with telnet options). The initial value for thistoggle is
False.
prettydump When the netdata toggle isenabled, if prettydump isenabled, the
output from the netdata command will be formatted in a more user-
readable format. Spacesare put between each character in the output,
and the beginning of any telnet escape sequence ispreceded by an *
to aid in locating them.
? Displaysthe legal toggle commands.
z Suspend telnet. Thiscommand only workswhen the user isusing the csh(1).
! command Execute a single command in a subshell on the local system. If command isomitted, then an
interactive subshell isinvoked.
status Show the current statusof telnet. Thisincludesthe peer one isconnected to, aswell asthe current
mode.
? command Get help. With no arguments, telnet printsa help summary. If a command isspecified, telnet
will print the help information for just that command.
ENVIRONMENT
telnet usesat least the HOME, SHELL, DISPLAY, and TERM environment variables. Other environment variablesmay be
propagated to the other side via the TELNET ENVIRON option.
FILES
~/.telnetrc User customized telnet startup values
HISTORY
The telnet command appeared in BSD 4.2.
NOTES
On some remote systems, echo hasto be turned off manually when in old line-by-line mode.
In old line-by-line mode or LINEMODE, the terminalseof character isonly recognized (and sent to the remote system) when it
isthe first character on a line.
BSD 4.2, 27 July1991
513
tfmtodit
tfmtoditCreate font filesfor use with groff -Tdvi
SYNOPSIS
tfmtodit [ -sv ][-ggf file ][-kskewchar ] tfm file map file font
DESCRIPTION
tfmtodit createsa font file for use with groff -Tdvi. tfm_file isthe name of the font metric file for the font. map_file isa
file giving the groff namesfor charactersin the font; thisfile should consist of a sequence of linesof the form:
n c1c2 ...
where n isa decimal integer giving the position of the character in the font, and c1, c2,... are the groff namesof the
character. If a character hasno groff namesbut existsin the tfm file, then it will be put in the groff font file asan unnamed
character. font isthe name of the groff font file. The groff font file iswritten to font.
The -s option should be given if the font isspecial (a font isspecial if troff should search it whenever a character isnot
found in the current font.) If the font isspecial, it should be listed in the fonts command in the DESC file; if it isnot special,
there isno need to list it because troff can automatically mount it when itsfirst used.
To do a good job of math typesetting, groff requiresfont metric information not present in the tfm file. The reason for this
isthat hasseparate math italic fontswhereasgroff usesnormal italic fontsfor math. The additional information required by
groff isgiven by the two argumentsto the math_fit macro in the Metafont programsfor the Computer Modern fonts. In a
text font (a font for which math_fitting isFalse), Metafont normally ignoresthese two arguments. Metafont can be made
to put thisinformation in the gf file by loading the following definition after cmbase when creating cm.base:
def ignore_math_fit(expr left_adjustment,right_adjustment) =
special adjustment;
numspecial left_adjustment*16/designsize;
numspecial right_adjustment*16/designsize;
enddef;
The gf file created using thismodified cm.base should be specified with the -g option. The -g option should not be given
for a font for which math_fitting istrue.
OPTIONS
-v Print the version number.
-s The font isspecial. The effect of thisoption isto add the special command to the font file.
-kn The skewchar of thisfont isat position n. n should be an integer; it may be given in decimal, or with a
leading 0 in octal, or with a leading 0x in hexadecimal. The effect of thisoption isto ignore any kerns
whose second component isthe specified character.
-ggf _f i l e gf _f i l e isa gf file produced by Metafont containing special and num special commandsgiving additional
font metric information.
FILES
/usr/lib/groff/font/devdvi/DESC Device description file.
/usr/lib/groff/font/devdvi/F Font description file for font F.
SEE ALSO
groff(1), grodvi(1), groff_font(5)
Groff Version 1.09, 14 February1994
tfmtodit
Part I: User Commands
514
tftp
tftpTrivial file transfer program
SYNOPSIS
tftp [host ]
DESCRIPTION
tftp isthe user interface to the Internet TFTP (Trivial File Transfer Protocol), which allowsusersto transfer filesto and from
a remote machine. The remote host may be specified on the command line, in which case tftp useshost asthe default host
for future transfers. (See the connect command in the following section.)
COMMANDS
Once tftp isrunning, it issuesthe prompt:
tftp>
and recognizesthe following commands:
? command- name ... Print help information.
ascii Shorthand for mode ascii
binary Shorthand for mode binary
connect host-name por t Set the host (and optionally por t ) for transfers. Note that the TFTP protocol, unlike the
FTP protocol, doesnot maintain connectionsbetween transfers; thus, the connect
command doesnot actually create a connection, but merely rememberswhat host isto be
used for transfers. You do not have to use the connect command; the remote host can be
specified aspart of the get or put commands.
get filename, Get a file or set of filesfrom the specified sources. Source can be in one of two forms: a
get remotename localname, filename on the remote host, if the host hasalready been specified; or a string of the form
get file1 file2 ... f i l eN hosts:filename to specify both a host and filename at the same time. If the latter form is
used, the last hostname specified becomesthe default for future transfers.
mode t r ansf er - mode Set the mode for transfers; t r ansf er - mode may be ascii or binary. The default isascii.
put f i l e Put a file or set of filesto the specified remote file or directory. The destination can be
put l ocal f i l e r emot ef i l e in one of two forms: a filename on the remote host, if the host hasalready been specified;
put f i l e1 f i l e2 . . . or a string of the form hosts:filename to specify both a host and filename at the same
f i l eN r emot e- di r ect or y time. If the latterform isused, the hostname specified becomesthe default for future
transfers. If the remote-directory form isused, the remote host isassumed to be a
UNIX machine.
quit Exit tftp . An end-of-file also exits.
rexmt Set the per-packet retransmission time-out, in seconds.
r et r ansmi ssi on- t i meout
status Show current status.
timeout Set the total transmission time-out, in seconds.
t ot al - t r ansmi ssi on- t i meout
trace Toggle packet tracing.
verbose Toggle verbose mode.
BUGS
Because there isno user-login or validation within the TFTP protocol, the remote site will probably have some sort of file-
accessrestrictionsin place. The exact methodsare specific to each site and therefore difficult to document here.
515
HISTORY
The tftp command appeared in BSD 4.3.
BSD 4.3, 22 April 1991
tgatoppm
tgatoppmConvert TrueVision Targa file into a portable pixmap
SYNOPSIS
tgatoppm [-debug][t gaf i l e]
DESCRIPTION
Readsa TrueVision Targa file asinput. Producesa portable pixmap asoutput.
OPTIONS
-debug Causesthe header information to be dumped to stderr
All flagscan be abbreviated to their shortest unique prefix.
BUGS
Should really be in pnm, not ppm.
SEE ALSO
ppmtotga(1), ppm(5)
AUTHOR
Partially based on tga2rast, version 1.0, by Ian J. MacPhedran
Copyright
1996 ThomasEsken. Thissoftware doesnt claim completeness, correctness, or usability. On principle, I will not
be liable for any damagesor losses(implicit or explicit), which result from using or handling my software. If you use this
software, you agree without any exception to thisagreement, which bindsyou legally.
txt2cal isfree software and distributed under the termsof the GNU General Public License; published by the Free Software
Foundation; version 2 or (at your option) any later version.
Any suggestions, improvements, extensions, bug reports, donations, proposalsfor contract work, and so forth are welcome. If
you like thistool, Id appreciate a postcard from you!
Enjoy it =8)
AUTHOR
ThomasEsken (esken@uni-muenster.de)
m Hagenfeld 84
D-48147 Muenster; Germany
Phone : +49 251 232585
SEE ALSO
gcal(1), tcal(1)
16 July1996
ul
ulDo underlining
SYNOPSIS
ul [-i] [-t terminal] [name ...]
DESCRIPTION
Ul readsthe named files(or standard input if none are given) and translatesoccurrencesof underscoresto the sequence that
indicatesunderlining for the terminal in use, asspecified by the environment variable TERM . The file /etc/termcap isread to
determine the appropriate sequencesfor underlining. If the terminal isincapable of underlining but iscapable of a standout
559
mode, then that isused instead. If the terminal can overstrike, or handlesunderlining automatically, ul degeneratesto
cat(1). If the terminal cannot underline, underlining isignored.
The following optionsare available:
-i Underlining isindicated by a separate line containing appropriate dashes-; thisisuseful when you want to
look at the underlining which ispresent in an nroff output stream on a CRT terminal.
-t terminal Overridesthe terminal type specified in the environment with terminal.
ENVIRONMENT
The following environment variable isused
TERM Relatesa tty device with itsdevice capability description; see termcap(5). TERM isset at login time, either
by the default terminal type specified in /etc/ttys or asset during the login processby the user in the
login file; see setenv(1).
SEE ALSO
man(1), nroff(1), colcrt(1)
BUGS
nroff usually outputsa seriesof backspacesand underlinesintermixed with the text to indicate underlining. No attempt is
made to optimize the backward motion.
HISTORY
The ul command appeared in BSD 3.0.
BSD 4, 6 June1993
unexpand
unexpandConvert spacesto tabs
SYNOPSIS
unexpand [-t ab1[,t ab2[,...]]] [-t t ab1[,t ab2[,...]]] [-a][--tabs=t ab1[,t ab2[,...]]]
[--all] [--help] [--version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of unexpand. unexpand writesthe contentsof each given file, or the standard
input if none are given or when a file named - isgiven, to the standard output, with stringsof two or more space or tab
charactersconverted to asmany tabsaspossible followed by asmany spacesasare needed. By default, unexpand converts
only initial spacesand tabs(those that precede all charactersthat arent spacesor tabs) on each line. It preservesbackspace
charactersin the output; they decrement the column count for tab calculations. By default, tabsare set at every 8th column.
OPTIONS
-, -t, --tabs t ab1[,t ab2[,...]] If only one tab stop isgiven, set the tabst ab1 spacesapart instead of the default 8.
Otherwise, set the tabsat columnst ab1, t ab2, and so on (numbered from 0) and
leave spacesand tabsbeyond the tab stopsgiven unchanged. If the tab stopsare
specified with the -t or --tabs option, they can be separated by blanksaswell asby
commas. Thisoption impliesthe -a option.
-a, --all Convert all stringsof two or more spacesor tabs, not just initial ones, to tabs.
--help Print a usage message and exit with a non-zero status.
--version Print version information on standard output, then exit.
GNU Text Utilities
unexpand
Part I: User Commands
560
uniq
uniqRemove duplicate linesfrom a sorted file
SYNOPSIS
uniq [-cdu] [-f skip-fields] [-s skip-chars] [-w check-chars] [-#skip-fields]
[+#skip-chars] [--count] [--repeated] [--unique] [--skip-fields=skip-fields]
[--skip-chars=skip-chars] [--check-chars=check-chars] [--help] [--version]
[infile] [outfile]
DESCRIPTION
Thismanual page documentsthe GNU version of uniq. uniq printsthe unique linesin a sorted file, discarding all but one of
a run of matching lines. It can optionally show only linesthat appear exactly once, or linesthat appear more than once. uniq
requiressorted input because it comparesonly consecutive lines.
If the output file isnot specified, uniq writesto the standard output. If the input file isnot specified, it readsfrom the
standard input.
OPTIONS
-u, --unique Only print unique lines
-d, --repeated Only print duplicate lines
-c, --count Print the number of timeseach line occurred along with the line
-number , -f, In thisoption, number isan integer representing the number of fieldsto skip over
--skip-fields=number before checking for uniqueness. The first number fields, along with any blanks
found before number fieldsisreached, are skipped over and not counted. Fieldsare
defined asa stringsof nonspace, nontab charactersthat are separated from each
other by spacesand tabs.
+number , -s, In thisoption, number isan integer representing the number of charactersto skip
--skip-chars=number over before checking for uniqueness. The first number characters, along with any
blanksfound before number charactersisreached, are skipped over and not counted.
If you use both the field and character skipping options, fieldsare skipped over first.
-w, Specify the number of charactersto compare in the lines, after skipping any specified fields
--check-chars=number and characters. Normally, the entire remainder of the linesare compared.
--help Print a usage message and exit with a non-zero status.
--version Print version information on standard output, then exit.
GNU Text Utilities
unshar
unsharUnpack a shar file
SYNOPSIS
unshar [ -d di r ect or y ] [ -c ][-e | -E exit_line ] [ f i l e ... ]
DESCRIPTION
unshar scansmail messageslooking for the start of a shell archive. It then passesthe archive through a copy of the shell
to unpack it. It will accept multiple files. If no filesare given, standard input isused. Thismanual page reflectsunshar
version 4.0.
561
OPTIONS
Optionshave a one-letter version starting with - or a long version starting with --. The exceptionsare --help and --
version, which dont have a short version.
--version Print the version number of the program on standard output, then immediately exit.
--help Print a help summary on standard output, then immediately exit.
-d DI RECTORY Change directory to DI RECTORY
--directory=DI RECTORY before unpacking any files.
-c --overwrite Passed asan option to the shar file. Many shell archive scripts(including those produced by
shar 3.40 and newer) accept a -c argument to indicate that existing filesshould be
overwritten.
-e --exit-0 Thisoption existsmainly for people who collect many shell archivesinto a single mail
folder. With thisoption, unshar isolateseach different shell archive from the othersthat
have been put in the same file, unpacking each in turn, from the beginning of the file
towardsitsend. Itsproper operation relieson the fact that many shar filesare terminated
by an exit 0 at the beginning of a line.
Option -e isinternally equivalent to -E exit 0.
-E STRI NG Thisoption workslike -e, but it allowsyou to specify the string that separatesarchives
--split-at=STRI NG if exit 0 isnt appropriate. For example, noticing that most .signatures have a --
on a line right before them, one can sometimesuse -- split-at=-- for splitting shell
archivesthat lack the exit 0 line at end. The signature will then be skipped altogether with
the headersof the following message.
SEE ALSO
shar(1)
DIAGNOSTICS
Any message from the shell may be displayed.
AUTHORS
Michael Mauldin at Carnegie-Mellon University, Guido van Rossum at CWI, Amsterdam (guido@mcvax), Bill Davidsen
(davidsen@sixhub.uuxp), Warren Tucker (wht%n4hgf@gatech.edu)
Richard H. Gumpertz (rhg@CPS.COM), and ColasNahaboo (colas@avahi.inria.fr). Man pagesby Jan Djfrv
(jhd@irfu.se).
12 August 1990
updatedb
updatedbUpdate a filename database
SYNOPSIS
updatedb [opt i ons]
DESCRIPTION
Thismanual page documentsthe GNU version of updatedb, which updatesfilename databasesused by GNU locate. The
filename databasescontain listsof filesthat were in particular directory treeswhen the databaseswere last updated. The
filename of the default database isdetermined when locate and updatedb are configured and installed. The frequency with
which the databasesand the directoriesfor which they contain entriesare updated dependson how often updatedb isrun,
updatedb
Part I: User Commands
562
and with which arguments. In networked environments, it often makessense to build a database at the root of each
filesystem, containing the entriesfor that filesystem. To prevent thrashing the network, updatedb isthen run for each
filesystem on the fileserver where that filesystem ison a local disk. Userscan select which databaseslocate searchesusing an
environment variable or command-line option; see locate(1L). Databasescan not be concatenated together. The filename
database format changed starting with GNU find and locate version 4.0 to allow machineswith different byte orderingsto
share the databases. The new GNU locate can read both the old and new database formats. However, old versionsof
locate and find produce incorrect resultsif given a new-format database.
OPTIONS
--localpaths=pat h1 pat h2... Nonnetwork directoriesto put in the database. Default is/.
--netpaths=pat h1 pat h2... Network (NFS, AFS, RFS, and so on) directoriesto put in the database. Default is
none.
--prunepaths=pat h1 pat h2... Directoriesto not put in the database, which would otherwise be put there. Default
is/tmp /usr/tmp /var/tmp /afs.
--output=dbf i l e The database file to build. Default issystem-dependent, but typically /usr/local/
var/locatedb.
--netuser=user The user to search network directoriesas, using su(1). Default isdaemon.
--old-format Create the database in the old format instead of the new one.
--version Print the version number of updatedb and exit.
--help Print a summary of the optionsto updatedb and exit.
SEE ALSO
find(1L), locate(1L), locatedb(5L), xargs(1L) FindingFiles(online in info, or printed)
uptime
uptimeTell how long the system hasbeen running
SYNOPSIS
uptime
DESCRIPTION
uptime givesa one-line display of the information that followsit: the current time, how long the system hasbeen running,
how many usersare currently logged on, and the system load averagesfor the past 1, 5, and 15 minutes.
Thisisthe same information contained in the header line displayed by w(1).
FILES
/var/run/utmp Information about who iscurrently logged on
/proc Processinformation
AUTHORS
uptime waswritten by Larry Greenfield (greenfie@gauss.rutgers.edu) and Michael K. Johnson
(johnsonm@sunsite.unc.edu).
SEE ALSO
ps(1), top(1), utmp(5), w(1)
CohesiveSystems, 26 January 1993
563
userlist
userlistUser listing of whoson your system
SYNOPSIS
userlist
DESCRIPTION
Thisprogram simply givesyou a listing of who isconnected to your system. It isused primarily in the sorted listing that
utilitizesthe same method of display for a more uniform output between systems. It also made more sense to do it thisway
instead of having jumbled up display listingsin sorted finger displays. Besides, it made more sense to do thisthan use
finger. :)
Thisprogram functionswith the same typesof thingsin mind that cfingerd does. If the user hasa .nofinger file, hisor her
username will not be displayed in the user listing.
Example output isshown as
Username Real Name Idletime TTY Remote console username Im real ... 9d 23:59 0
(remote.site.com)
where it would display the userslogin name, the usersreal name, the usersidle time given in the format dd hh: mm, the
TTY, and the remote location (or where the user istelnetting from).
If the username ismore than a certain number of characters, the program will not search for their information in the passwd
file because it may be too long. Besides, it checksgetpwnam, anyway.
CONTACTING
If you like thisprogram, have any suggestionson how it could be modified, or have bug reports, please write to
khollis@bitgate.com.
Your continued public domain support isappreciated! Thanks.
SEE ALSO
cfingerd.conf(5), cfingerd(8), finger(1)
Userlist 0.0.1, 26 August 1995
uucp
uucpUNIX-to-UNIX copy
SYNOPSIS
uucp [ options ] sour ce- f i l e dest i nat i on- f i l e
uucp [ options ] sour ce- f i l e. . . dest i nat i on- di r ect or y
DESCRIPTION
The uucp command copiesfilesbetween systems. Each file argument iseither a pathname on the local machine or isof the
form
syst em! pat h
which isinterpreted asbeing on a remote system. In the first form, the contentsof the first file are copied to the second. In
the second form, each source file iscopied into the destination directory.
uucp
Part I: User Commands
564
A file be transferred to or from syst em2 via syst em1 by using
syst em1!syst em2!pat h
Any pathname that doesnot begin with / or will be appended to the current directory (unlessthe -W or --noexpand option
isused); thisresulting path will not necessarily exist on a remote system. A pathname beginning with a simple startsat the
uucp public directory; a pathname beginning with name startsat the home directory of the named user. The isinterpreted
on the appropriate system. Note that some shellswill interpret a simple to the local home directory before uucp seesit; to
avoid this, the must be quoted.
Shell metacharacters? * [ ] are interpreted on the appropriate system, assuming they are quoted to prevent the shell from
interpreting them first.
The copy doesnot take place immediately, but isqueued up for the uucico(8) daemon; the daemon isstarted immediately
unlessthe -r or --nouucico switch isgiven. In any case, the next time the remote system iscalled, the file(s) will be copied.
OPTIONS
The following optionsmay be given to uucp.
-c, --nocopy Do not copy local source filesto the spool directory. If they are removed before being
processed by the uucico(8) daemon, the copy will fail. The filesmust be readable by the
uucico(8) daemon, and by the invoking user.
-C, --copy Copy local source filesto the spool directory. Thisisthe default.
-d, --directories Create all necessary directorieswhen doing the copy. Thisisthe default.
-f, --nodirectories If any necessary directoriesdo not exist for the destination path, abort the copy.
-g gr ade, --grade gr ade Set the grade of the file transfer command. Jobsof a higher grade are executed first. Grades
run 0 ... 9 A ... Z a ... z from high to low.
-m, --mail Report completion or failure of the file transfer by mail(1).
-n user , --notify user Report completion or failure of the file transfer by mail(1) to the named user on the remote
system.
-r, --nouucico Do not start uucico(8) daemon immediately; merely queue up the file transfer for later
execution.
-j, -- j obi d Print j obi d on standard output. The job may be later canceled by passing the j obi d to the
-k switch of uustat(1). It ispossible for some complex operationsto produce more than
one j obi d, in which case, each will be printed on a separate line. For example,
uucp sys1!user 1/f i l e1 sys2!user 2/f i l e2 user 3
will generate two separate jobs, one for the system sys1 and one for the system sys2.
-W, --noexpand Do not prepend remote relative pathnameswith the current directory.
-x t ype, --debug t ype Turn on particular debugging types. The following typesare recognized: abnormal, chat,
handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing.
Only abnormal, config, spooldir, and execute are meaningful for uucp. Multiple types
may be given, separated by commas, and the --debug option may appear multiple times. A
number may also be given, which will turn on that many typesfrom the foregoing list; for
example, --debug 2 isequivalent to --debug abnormal,chat.
-I f i l e, --config f i l e Set configuration file to use. Thisoption may not be available, depending upon how uucp
wascompiled.
-v, --version Report version information and exit.
--help Print a help message and exit.
FILES
The filenamesmay be changed at compilation time or by the configuration file, so these are only approximations.
565
/usr/lib/uucp/config Configuration file
/usr/spool/uucpuucp Spool directory
/usr/spool/uucp/Log uucp log file
/usr/spool/uucppublic Default uucp public directory
SEE ALSO
mail(1), uux(1), uustat(1), uucico(8)
BUGS
Some of the optionsare dependent on the capabilitiesof the uucico(8) daemon on the remote system.
The -n and -m switchesdo not work when transferring a file from one remote system to another.
File modesare not preserved, except for the execute bit. The resulting file isowned by the uucp user.
AUTHOR
Ian Lance Taylor (ian@airs.com)
Taylor UUCP 1.05
uuencode
uuencodeEncode a binary file
uudecodeDecode a file created by uuencode
SYNOPSIS
uuencode [-m] [ f i l e ] name
uudecode [-o outfile] [ f i l e ]...
DESCRIPTION
uuencode and uudecode are used to transmit binary filesover transmission mediumsthat do not support other than simple
ASCII data.
uuencode readsf i l e (or by default the standard input) and writesan encoded version to the standard output. The encoding
usesonly printing ASCII charactersand includesthe mode of the file and the operand name for use by uudecode. If name is/
dev/stdout, the result will be written to standard output. By default, the standard UU encoding format will be used. If the
option -m isgiven on the command line, base64 encoding isused instead.
uudecode transformsuuencoded files(or by default, the standard input) into the original form. The resulting file isnamed
name (or outfile if the -o option isgiven) and will have the mode of the original file except that setuid and execute bits
are not retained. If outfile or name is/dev/stdout, the result will be written to standard output. uudecode ignoresany
leading and trailing lines. The program can automatically decide which of the supported encoding schemesare used.
EXAMPLES
The following example packagesup a source tree, compressesit, uuencodes it, and mailsit to a user on another system.
When uudecode isrun on the target system, the file src_tree.tar.Z will be created, which may then be uncompressed and
extracted into the original tree.
tar cf - src_tree | compress | uuencode src_tree.tar.Z | mail sys1!sys2!user
uuencode
Part I: User Commands
566
SEE ALSO
compress(1), mail(1), uucp(1), uuencode(5)
STANDARDS
Thisimplementation iscompliant with P1003.2b/D11.
BUGS
If more than one file isgiven to uudecode and the -o option isgiven or more than one name in the encoded filesisthe same,
the result isprobably not what isexpected.
The encoded form of the file isexpanded by 37 percent for UU encoding and by 35 percent for base64 encoding (3 bytes
become 4 pluscontrol information).
HISTORY
The uuencode command appeared in BSD 4.0.
uustat
uustatuucp statusinquiry and control
SYNOPSIS
uustat -a
uustat --all
uustat [ -eKRiMNQ ][-sS syst em ] [ -uU user ] [ -cC command ] [ -oy hour s ]
[ -B l i nes ] [ --executions ][--kill-all ][--rejuvenate-all ][--prompt ][--mail ]
[--notify ][--no-list ][--system syst em ] [ --not-system syst em ] [ --user user ]
[--not-user user ] [ --command command ] [ --not-command command ]
[ --older-than hour s ] [ --younger-than hour s ] [ --mail-lines l i nes ]
uustat [ -kr jobid ] [ --kill jobid ] [ --rejuvenate jobid ]
uustat -q [ -sS syst em ] [ -oy hour s ] [ --system syst em ] [ --not-system syst em ]
[--older-than hour s ] [ --younger-than hour s ]
uustat --list [ -sS syst em ] [ -oy hour s ] [ --system syst em ]
[ --not-system syst em ] [ --older-than hour s ] [ --younger-than hour s ]
uustat -m
uustat --status
uustat -p
uustat --ps
DESCRIPTION
The uustat command can display varioustypesof statusinformation about the UUCP system. It can also be used to cancel
or rejuvenate requestsmade by uucp(1) or uux(1).
By default uustat displaysall jobsqueued up for the invoking user, asif given the --user option with the appropriate
argument.
567
If any of the -a, --all, -e, --executions, -s, --system, -S, --not-system, -u, --user, -U, --not-user, -c, --command, -C,
--not-command, -o, --older-than, -y, --younger-than optionsare given, then all jobsthat match the combined specifica-
tionsare displayed.
The -K or --kill-all option may be used to kill off a selected group of jobs, such asall jobsmore than seven daysold.
OPTIONS
The following optionsmay be given to uustat.
-a, --all List all queued file transfer requests.
-e, --executions List queued execution requestsrather than queued file transfer requests. Queued execution
requestsare processed by uuxqt(8) rather than uucico(8). Queued execution requestsmay
be waiting for some file to be transferred from a remote system. They are created by an
invocation of uux(1).
-s syst em, --system syst em List all jobsqueued up for the named system. These optionsmay be specified multiple
times, in which case all jobsfor all the systemswill be listed. If used with --list, only the
systemsnamed will be listed.
-S syst em, List all jobsqueued for systemsother than the one named. These options
--not-system syst em may be specified multiple times, in which case no jobsfrom any of the specified systemswill
be listed. If used with -- list, only the systemsnot named will be listed. These options
may not be used with -s or --system.
-u user , --user user List all jobsqueued up for the named user. These optionsmay be specified multiple times,
in which case all jobsfor all the userswill be listed.
-U user , --not-user user List all jobsqueued up for usersother than the one named. These optionsmay be specified
multiple times, in which case no jobsfrom any of the specified userswill be listed. These
optionsmay not be used with -u or --user.
-c command, List all jobsrequesting the execution of the named command. If command isALL thiswill
--command command list all jobsrequesting the execution of some command (asopposed to simply requesting a
file transfer). These optionsmay be specified multiple times, in which case all jobs
requesting any of the commandswill be listed.
-C command, List all jobsrequesting execution of some command other than the named
--not-command command command, or, if command isALL, list all jobsthat simply request a file transfer (asopposed
to requesting the execution of some command). These optionsmay be specified multiple
times, in which case, no job requesting one of the specified commandswill be listed. These
optionsmay not be used with -c or --command.
-o hours, List all queued jobsolder than the given number of hours. If used with --list, only
--older-than hours systemswhose oldest job isolder than the given number of hourswill be listed.
-y hour s, List all queued jobsyounger than the given number of hours. If used with --list,
--younger-than hour s only systemswhose oldest job isyounger than the given number of hourswill be
listed.
-k j obi d, --kill j obi d Kill the named job. The job ID isshown by the default output format, aswell asby the -j
or --jobid option to uucp(1) or uux(1). A job may only be killed by the user who created
the job, or by the UUCP administrator or the superuser. The -k or --kill optionsmay be
used multiple timeson the command line to kill several jobs.
-r j obi d, Rejuvenate the named job. Thiswill mark it ashaving been invoked at the current
--rejuvenate j obi d time, affecting the output of the -o, -- older-than, -y, or -- younger-than optionsand
preserving it from any automated cleanup daemon. The job ID isshown by the default
output format, aswell asby the -j or --jobid optionsto uucp(1) or uu(1). A job may only
be rejuvenated by the user who created the job, or by the UUCP administrator or the
superuser. The -r or --rejuvenate optionsmay be used multiple timeson the command
line to rejuvenate several jobs.
uustat
Part I: User Commands
568
-q, --list Display the statusof commands, executions, and conversationsfor all remote systemsfor
which commandsor executionsare queued. The -s, --system, -S, --not-system, -o, --
older-than, -y, and --younger-than optionsmay be used to restrict the systemsthat are
listed. Systemsfor which no commandsor executionsare queued will never be listed.
-m, --status Display the statusof conversationsfor all remote systems.
-p, --ps Display the statusof all processesholding uucp lockson systemsor ports.
-i, --prompt For each listed job, prompt whether to kill the job or not. If the first character of the input
line isy or Y, the job will be killed.
-K, --kill-all Automatically kill each listed job. Thiscan be useful for automatic cleanup scripts, in
conjunction with the --mail and --notify options.
-R, --rejuvenate-all Automatically rejuvenate each listed job. Thismay not be used with --kill-all.
-M, --mail For each listed job, send mail to the UUCP administrator. If the job iskilled (due to --
kill-all or --prompt with an affirmative response), the mail will indicate that. A comment
specified by the --comment option may be included. If the job isan execution, the initial
portion of itsstandard input will be included in the mail message; the number of linesto
include may be set with the --mail-lines option (the default is100). If the standard input
containsnull characters, it isassumed to be a binary file and isnot included.
-N, --notify For each listed job, send mail to the user who requested the job. The mail isidentical to that
sent by the -M or --mail options.
-W, --comment Specify a comment to be included in mail sent with the -M, --mail, -N, or --notify
options.
-Q, --no-list Do not actually list the job, but only take any actionsindicated by the -i, --prompt, -K, --
kill-all, -M, --mail, -N, or --notify options.
-x t ype, --debug t ype Turn on particular debugging types. The following typesare recognized: abnormal, chat,
handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing.
Only abnormal, config, spooldir, and execute are meaningful for uustat.
Multiple typesmay be given, separated by commas, and the --debug option may appear
multiple times. A number may also be given, which will turn on that many typesfrom the
foregoing list; for example, --debug 2 isequivalent to --debug abnormal,chat.
-I f i l e, --config f i l e Set configuration file to use. Thisoption may not be available, depending upon how uustat
wascompiled.
-v, --version Report version information and exit.
--help Print a help message and exit.
EXAMPLES
uustat -all Display statusof all jobs. A sample output line isasfollows:
bugsA027h bugs ian 04-01 13:50 Executing rmail ian@airs.com (sending 1283
bytes)
The format is
j obi d syst em user queue- dat e command ( si ze)
The jobid may be passed to the --kill or --rejuvenate options. The size indicateshow
much data isto be transferred to the remote system, and isabsent for a file receive request.
The --system, --not-system, --user, --not-user, --command, --not-command, --older-
than, and --younger-than optionsmay be used to control which jobsare listed.
uustat -executions Display statusof queued up execution requests. A sample output line isasfollows:
bugs bugs!ian 05-20 12:51 rmail ian
The format is
syst em r equest or queue- dat e command
The --system, --not-system, --user, --not-user, --command, --not-command, --older-
than, and --younger-than optionsmay be used to control which requestsare listed.
569
uustat -list Display statusfor all systemswith queued-up commands. A sample output line isasfollows:
bugs 4C (1 hour) 0X (0 secs) 04-01 14:45 Dial failed
Thisindicatesthe system, the number of queued commands, the age of the oldest queued
command, the number of queued local executions, the age of the oldest queued execution,
the date of the last conversation, and the statusof that conversation.
uustat -status Display conversation statusfor all remote systems. A sample output line isasfollows:
bugs 04-01 15:51 Conversation complete
Thisindicatesthe system, the date of the last conversation, and the statusof that conversa-
tion. If the last conversation failed, uustat will indicate how many attemptshave been
made to call the system. If the retry period iscurrently preventing callsto that system,
uustat also displaysthe time when the next call will be permitted.
uustat -ps Display the statusof all processesholding uucp locks. The output format issystem-
dependent, asuustat simply invokesps(1) on each processholding a lock. A sample output
line isasfollows:
uustat -command rmail -older-than 168 -kill-all -no-list -mail -notify -
comment Queued for over 1 week
Thiswill kill all rmail commandsthat have been queued up waiting for delivery for over
one week (168 hours). For each such command, mail will be sent both to the UUCP
administrator and to the user who requested the rmail execution. The mail message sent
will include the string given by the --comment option. The --no-list option preventsany
of the jobsfrom being listed on the terminal, so any output from the program will be error
messages.
FILES
The filenamesmay be changed at compilation time or by the configuration file, so these are only approximations.
/usr/lib/uucp/config Configuration file
/usr/spool/uucpuucp spool directory
SEE ALSO
ps(1), rmail(1), uucp(1), uux(1), uucico(8), uuxqt(8)
AUTHOR
Ian Lance Taylor (ian@airs.com)
Taylor UUCP 1.05
uux
uuxRemote command execution over uucp
SYNOPSIS
uux [ opt i ons ] command
DESCRIPTION
The uux command isused to execute a command on a remote system, or to execute a command on the local system using
filesfrom remote systems. The command isnot executed immediately; the request isqueued until the uucico(8) daemon
callsthe system and executesit. The daemon isstarted automatically unlessone of the -r or --nouucico optionsisgiven.
uux
Part I: User Commands
570
The actual command execution isdone by the uuxqt(8) daemon.
File argumentscan be gathered from remote systemsto the execution system, ascan standard input. Standard output may be
directed to a file on a remote system.
The command name may be preceded by a system name followed by an exclamation point if it isto be executed on a remote
system. An empty system name istaken asthe local system.
Each argument that containsan exclamation point istreated asnaming a file. The system that the file ison isbefore the
exclamation point, and the pathname on that system followsit. An empty system name istaken asthe local system; thismust
be used to transfer a file to a command being executed on a remote system. If the path isnot absolute, it will be appended to
the current working directory on the local system; the result may not be meaningful on the remote system. A pathname may
begin with /, in which case it isrelative to the uucp public directory (usually /usr/spool/uucppublic) on the appropriate
system. A pathname may begin with name/, in which case it isrelative to the home directory of the named user on the
appropriate system.
Standard input and output may be redirected asusual; the pathnamesused may contain exclamation pointsto indicate that
they are on remote systems. Note that the redirection charactersmust be quoted so that they are passed to uux rather than
interpreted by the shell. Append redirection (>>) doesnot work.
All specified filesare gathered together into a single directory before execution of the command begins. Thismeansthat each
file must have a distinct base name. For example,
uux sys1!diff sys2!user1/foo sys3!user2/foo >!foo.diff
will fail because both fileswill be copied to sys1 and stored under the name foo.
Argumentsmay be quoted by parenthesesto avoid interpretation of exclamation points. Thisisuseful when executing the
uucp command on a remote system.
OPTIONS
The following optionsmay be given to uux.
-, -p, --stdin Read standard input and use it asthe standard input for the command to be executed.
-c, --nocopy Do not copy local filesto the spool directory. Thisisthe default. If they are removed before
being processed by the uucico(8) daemon, the copy will fail. The filesmust be readable by
the uucico(8) daemon, aswell asby the invoker of uux.
-C, --copy Copy local filesto the spool directory.
-l, --link Link local filesinto the spool directory. If a file can not be linked because it ison a different
device, it will be copied unlessone of the -c or --nocopy optionsalso appears(in other
words, use of --link switchesthe default from --nocopy to --copy). If the filesare changed
before being processed by the uucico(8) daemon, the changed versionswill be used. The
filesmust be readable by the uucico(8) daemon, aswell asby the invoker of uux.
-g gr ade, --grade gr ade Set the grade of the file transfer command. Jobsof a higher grade are executed first. Grades
run 0 ... 9 A ... Z a ... z from high to low.
-n, --notification=no Do not send mail about the statusof the job, even if it fails.
-z, --notification=er r or Send mail about the statusof the job if an error occurs. For many uuxqt daemons,
including the Taylor uucp uuxqt, thisisthe default action; for those, --
notification=er r or will have no effect. However, some uuxqt daemonswill send mail if
the job succeedsunlessthe --notification=error option isused, and some other uuxqt
daemonswill not send mail if the job failsunlessthe --notification=error option isused.
-r, --nouucico Do not start the uucico(8) daemon immediately; merely queue up the execution request for
later processing.
571
-j, --jobid Print jobids on standard output. A jobid will be generated for each file copy operation
required to perform the operation. These file copiesmay be canceled by passing the jobid
to the --kill switch of uustat(1), which will make the execution impossible to complete.
-a addr ess, Report job statusto the specified e-mail address.
--requestor addr ess
-x type, --debug type Turn on particular debugging types. The following typesare recognized: abnormal, chat,
handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing.
Only abnormal, config, spooldir, and execute are meaningful for uux. Multiple types
may be given, separated by commas, and the --debug option may appear multiple times. A
number may also be given, which will turn on that many typesfrom the foregoing list; for
example, --debug 2 isequivalent to --debug abnormal,chat.
-I f i l e, --config f i l e Set configuration file to use. Thisoption may not be available, depending upon how uux
wascompiled.
-v, --version Report version information and exit.
--help Print a help message and exit.
EXAMPLES
uux -z - sys1!rmail user1Execute the command rmail user1 on the system sys1, giving it asstandard input
whatever isgiven to uux asstandard input. If a failure occurs, send a message using mail(1).
uux diff -c sys1!user1/file1 sys2!user2/file2 >!file.diffFetch the two named filesfrom system sys1 and
system sys2 and execute diff, putting the result in file.diff in the current directory. The current directory must be
writable by the uuxqt(8) daemon for thisto work.
uux sys1!uucp user1/file1 (sys2!user2/file2)Execute uucp on the system sys1 copying file1 (on system
sys1) to sys2. Thisillustratesthe use of parenthesesfor quoting.
RESTRICTIONS
The remote system may not permit you to execute certain commands. Many remote systemsonly permit the execution of
rmail and rnews.
Some of the optionsare dependent on the capabilitiesof the uuxqt(8) daemon on the remote system.
FILES
The filenamesmay be changed at compilation time or by the configuration file, so these are only approximations.
/usr/lib/uucp/config Configuration file
/usr/spool/uucpuucp spool directory
/usr/spool/uucp/Log uucp log file
/usr/spool/uucppublic Default uucp public directory
SEE ALSO
mail(1), uustat(1), uucp(1), uucico(8), uuxqt(8)
BUGS
Filescan not be referenced acrossmultiple systems.
Too many jobids are output by --jobid, and there isno good way to cancel a local execution requiring remote files.
AUTHOR
Ian Lance Taylor (ian@airs.com)
uux
Part I: User Commands
572
uuxqt
uuxqtuucp execution daemon
SYNOPSIS
uuxqt [ opt i ons ]
DESCRIPTION
The uuxqt daemon executescommandsrequested by uux(1) from either the local system or from remote systems. It isstarted
automatically by the uucico(8) daemon (unlessuucico(8) isgiven the -q or --nouuxqt option).
There isnormally no need to run thiscommand because it will be invoked by uucico(8). However, it can be used to provide
greater control over the processing of the work queue.
Multiple invocationsof uuxqt may be run at once, ascontrolled by the max-uuxqts configuration command.
OPTIONS
The following optionsmay be given to uuxqt:
-c command, --command command Only execute requestsfor the specified command. For example,
uuxqt -command rmail
-s syst em, --system syst em Only execute requestsoriginating from the specified system.
-x t ype, --debug t ype Turn on particular debugging types. The following typesare recognized: abnormal,
chat, handshake, uucp-proto, proto, port, config, spooldir, execute, incoming,
outgoing. Only abnormal, config, spooldir and execute are meaningful for
uuxqt. Multiple typesmay be given, separated by commas, and the --debug option
may appear multiple times. A number may also be given, which will turn on that
many typesfrom the foregoing list; for example, --debug 2 isequivalent to --debug
abnormal,chat.
The debugging output issent to the debugging file, usually /usr/spool/uucp/
Debug, /usr/spool/uucp/DEBUG, or /usr/spool/uucp/.Admin/audit.local.
-I f i l e, --config Set configuration file to use. Thisoption may not be available, depending upon how
uuxqt wascompiled.
-v, --version Report version information and exit.
--help Print a help message and exit.
FILES
The filenamesmay be changed at compilation time or by the configuration file, so these are only approximations.
/usr/lib/uucp/config Configuration file
/usr/spool/uucpuucp spool directory
/usr/spool/uucp/Log uucp log file
/usr/spool/uucppublic Default uucp public directory
/usr/spool/uucp/Debug Debugging file
SEE ALSO
uucp(1), uux(1), uucico(8)
AUTHOR
Ian Lance Taylor (ian@airs.com)
Taylor UUCP 1.05
573
w
wPresent who usersare and what they are doing
SYNOPSIS
w [-hin] [-user ]
DESCRIPTION
The w utility printsa summary of the current activity on the system, including what each user isdoing. The first line displays
the current time of day, how long the system hasbeen running, the number of userslogged into the system, and the load
averages. The load average numbersgive the number of jobsin the run queue averaged over 1, 5, and 15 minutes.
The fieldsoutput are the userslogin name, the name of the terminal the user ison, the host from which the user islogged
in, the time the user logged on, the time since the user last typed anything, and the name and argumentsof the current
process.
The optionsare asfollows:
-h Suppressthe heading
-i Output issorted by idle time
-n Show network addressesasnumbers
-w Interpret addressesand attempt to display them symbolically
If a username isspecified, the output isrestricted to that user.
FILES
/var/run/utmp List of userson the system
SEE ALSO
who(1), finger(1), ps(1), uptime(1),
BUGS
The notion of the current processismuddy. The current algorithm isthe highest numbered processon the terminal that is
not ignoring interrupts, or, if there isnone, the highest numbered processon the terminal. Thisfails, for example, in critical
sectionsof programslike the shell and editor, or when faulty programsrunning in the background fork and fail to ignore
interrupts. (In caseswhere no processcan be found, w printsa period.)
The CPU time isonly an estimate; in particular, if someone leavesa background processrunning after logging out, the
person currently on that terminal ischarged with the time.
Background processesare not shown, even though they account for much of the load on the system.
Sometimesprocesses, typically those in the background, are printed with null or garbaged arguments. In these cases, the
name of the command isprinted in parentheses.
The w utility doesnot know about the new conventionsfor detection of background jobs. It will sometimesfind a back-
ground job instead of the right one.
COMPATIBILITY
The -f, -l, -s, and -w flagsare no longer supported.
HISTORY
The w command appeared in BSD 3.0.
BSD 4, 6 June1993
w
Part I: User Commands
574
wall
wallWrite a message to users
SYNOPSIS
wall [f i l e]
DESCRIPTION
wall displaysthe contentsof file or, by default, itsstandard input, on the terminalsof all currently logged in users.
Only the superuser can write on the terminalsof userswho have chosen to deny messagesor are using a program that
automatically deniesmessages.
SEE ALSO
mesg(1), talk(1), write(1), shutdown(8)
HISTORY
A wall command appeared in AT&T v7.
Linux 0.99, 8 March 1993
wc
wcPrint the number of bytes, words, and linesin files
SYNOPSIS
wc [-clw] [--bytes] [--chars] [--lines] [--words] [--help] [--version] [f i l e...]
DESCRIPTION
Thismanual page documentsthe GNU version of wc. wc countsthe number of bytes, whitespace-separated words, and
newlinesin each given file, or the standard input if none are given or when a file named - isgiven. It printsone line of
countsfor each file, and if the file wasgiven asan argument, it printsthe filename following the counts. If more than one
filename isgiven, wc printsa final line containing the cumulative counts, with the filename total. The countsare printed in
the order lines, words, bytes.
By default, wc printsall three counts. Optionscan specify that only certain countsbe printed. Optionsdo not undo others
previously given, so wc --bytes --words printsboth the byte countsand the word counts.
OPTIONS
-c, --bytes, --chars Print only the byte counts.
-w, --words Print only the word counts.
-l, --lines Print only the newline counts.
--help Print a usage message and exit with a non-zero status.
--version Print version information on standard output, then exit.
GNU Text Utilities
575
whereis
whereisLocate the binary, source, and manual page filesfor a command
SYNOPSIS
whereis [ -bmsu ][-BMS di r ect or y... -f ] f i l ename ...
DESCRIPTION
whereis locatessource/binary and manualssectionsfor specified files. The supplied namesare first stripped of leading
pathname componentsand any (single) trailing extension of the form . ext, for example, .c. Prefixesof s. resulting from use
of source code control are also dealt with. whereis then attemptsto locate the desired program in a list of standard Linux
places:
/bin
/usr/bin
/etc
/usr/etc
/sbin
/usr/sbin
/usr/games
/usr/games/bin
/usr/emacs/etc
/usr/lib/emacs/19.22/etc
/usr/lib/emacs/19.23/etc
/usr/lib/emacs/19.24/etc
/usr/lib/emacs/19.25/etc
/usr/lib/emacs/19.26/etc
/usr/lib/emacs/19.27/etc
/usr/lib/emacs/19.28/etc
/usr/lib/emacs/19.29/etc
/usr/lib/emacs/19.30/etc
/usr/TeX/bin
/usr/tex/bin
/usr/interviews/bin/LINUX
/usr/bin/X11
/usr/X11/bin
/usr/X11R5/bin
/usr/X11R6/bin
/usr/X386/bin
/usr/local/bin
/usr/local/etc
/usr/local/sbin
/usr/local/games
/usr/local/games/bin
/usr/local/emacs/etc
/usr/local/TeX/bin
/usr/local/tex/bin
/usr/local/bin/X11
/usr/contrib
/usr/hosts
/usr/include
/usr/g++-include
whereis
Part I: User Commands
576
OPTIONS
-b Search only for binaries.
-m Search only for manual sections.
-s Search only for sources.
-u Search for unusual entries. A file issaid to be unusual if it doesnot have one entry of each requested type. Thus
whereisnn-mnn-unn* asksfor those filesin the current directory which have no documentation.
-B Change or otherwise limit the placeswhere whereis searchesfor binaries.
-M Change or otherwise limit the placeswhere whereis searchesfor manual sections.
-S Change or otherwise limit the placeswhere whereis searchesfor sources.
-f Terminate the last directory list and signalsthe start of filenames; must be used when any of the -B, -M, or -S
optionsare used.
EXAMPLE
Find all filesin /usr/bin that are not documented in /usr/man/man1 with source in /usr/src:
example% cd /usr/bin
example% whereis -u -M /usr/man/man1 -S /usr/src -f *
FILES
/{bin,sbin,etc}
/usr/{lib,bin,old,new,local,games,include,etc,src,man,sbin,
X386, TeX, g++-include}
/usr/local/{X386,TeX,X11,include,lib,man,etc,bin,games,emacs}
SEE ALSO
chdir(2V)
BUGS
Since whereis useschdir(2V) to run faster, pathnames given with the -M, -S, or -B must be full; that is, they must begin
with a /.
8 May1994
write
writeSend a message to another user
SYNOPSIS
write user [t t yname]
DESCRIPTION
write allowsyou to communicate with other usersby copying linesfrom your terminal to theirs.
When you run the write command, the user you are writing to getsa message of the form:
Message from yourname@yourhost on yourtty at hh:mm ...
Any further linesyou enter will be copied to the specified usersterminal. If the other user wantsto reply, he or she must run
write aswell.
When you are done, type an end-of-file or interrupt character. The other user will see the message EOF, indicating that the
conversation isover.
577
You can prevent people (other than the superuser) from writing to you with the mesg(1) command. Some commands, for
example, nroff(1) and pr(1), may disallow writing automatically, so that your output isnt overwritten.
If the user you want to write to islogged in on more than one terminal, you can specify which terminal to write to by
specifying the terminal name asthe second oper and to the write command. Alternatively, you can let write select one of
the terminalsit will pick the one with the shortest idle time. Thus, if the user islogged in at work and also dialed up from
home, the message will go to the right place.
The traditional protocol for writing to someone isthat the string -o, either at the end of a line or on a line by itself, means
that itsthe other personsturn to talk. The string oo meansthat the person believesthe conversation to be over.
SEE ALSO
mesg(1), talk(1), who(1)
HISTORY
A write command appeared in Version 6 AT&T UNIX.
12 March 1995
x11perf
x11perfX11 server performance test program
SYNTAX
x11perf [ -option ... ]
DESCRIPTION
The x11perf program runsone or more performance testsand reportshow fast an X server can execute the tests.
Many graphicsbenchmarksassume that the graphicsdevice isused to display the output of a single fancy graphicsapplica-
tion, and that the user getshiswork done on some other device, like a terminal. Such benchmarksusually measure drawing
speed for lines, polygons, text, and so on.
Because workstationsare not used asstandalone graphicsengines, but assuper-terminals, x11perf measureswindow
management performance aswell astraditional graphicsperformance. x11perf includesbenchmarksfor the time it takesto
create and map windows(aswhen you start up an application); to map a preexisting set of windowsonto the screen (aswhen
you deiconify an application or pop up a menu); and to rearrange windows(aswhen you slosh windowsto and fro trying to
find the one you want).
x11perf also measuresgraphicsperformance for operationsnot normally used in standalone graphicsdisplays, but are
nonethelessused frequently by X applications. Such operationsinclude CopyPlane (used to map bitmapsinto pixels),
scrolling (used in text windows), and variousstipplesand tiles(used for CAD and color halftoning, respectively).
x11perf should be used to analyze particular strengthsand weaknessesof servers, and ismost useful to a server writer who
wantsto analyze and improve a server. x11perf ismeant to comprehensively exercise just about every X11 operation you can
perform; it doesnot purport to be a representative sample of the operationsthat X11 applicationsactually use. Although it
can be used asa benchmark, it waswritten and isintended asa performance testing tool.
Assuch, x11perf doesnot whittle down measurementsto a single HeXStones or MeXops number. We consider such numbers
to be uninformative at best and misleading at worst. Some serversthat are very fast for certain applicationscan be very slow
for others. No single number or small set of numbersissufficient to characterize how an X implementation will perform on
all applications. However, by knowledge of your favorite application, you may be able to use the numbersx11perf reportsto
predict itsperformance on a given X implementation.
x11perf
Part I: User Commands
578
That said, you might also want to look at x11perfcomp(1), a program to compare the outputsof different x11perf runs. You
provide a list of filescontaining resultsfrom x11perf, and it laysthem out in a nice tabular format.
For repeatable results, x11perf should be run using a local connection on a freshly started server. The default configuration
runseach test five timesin order to see if each trial takesapproximately the same amount of time. Strange glitchesshould be
examined; if nonrepeatable, you might chalk them up to daemonsand network traffic. Each trial isrun for five seconds, in
order to reduce random time differences. The number of objectsprocessed per second isdisplayed to three significant digits,
but youll be lucky on most UNIX systemsif the numbersare actually consistent to two digits. x11perf movesthe cursor out
of the test window; you should be careful not to bump the mouse and move it back into the window. (A prize to people who
correctly explain why!)
Before running a test, x11perf determineswhat the round trip time to the server is, and factorsthisout of the final timing
reported. It ensuresthat the server hasactually performed the work requested by fetching a pixel back from the test window,
which meansthat serverstalking to graphicsacceleratorscant claim that they are done, while in the meantime the accelera-
tor ispainting madly.
By default, x11perf automatically calibratesthe number of repetitionsof each test, so that each should take approximately
the same length of time to run acrossserversof widely differing speeds. However, because each test must be run to comple-
tion at least once, some slow serversmay take a very long time, particularly on the window moving and resizing tests, and on
the arc drawing tests.
All timing reportsare for the smallest object involved. For example, the line testsuse a PolyLine request to paint several lines
at once, but report how many linesper second the server can paint, not how many PolyLine requestsper second. Text tests
paint a line of characters, but report on the number of charactersper second. Some window testsmap, unmap, or move a
single parent window, but report on how many children windowsper second the server can map, unmap, or move.
The current program ismostly the responsibility of Joel McCormack. It isbased upon the x11perf developed by Phil
Karlton, Susan Angebranndt, ChrisKent, Mary Walker, and Todd Newman, who wanted to assessperformance differences
between variousservers. Several testswere added in order to write and tune the PMAX (DECStation 3100) servers. For a
general release to the world, x11perf wasrewritten to ease making comparisonsbetween widely varying machines, to cover
most important (and unimportant) X functionality, and to exercise graphicsoperationsin asmany different orientationsand
alignmentsaspossible.
OPTIONS
x11perf issolely Xlib based, and acceptsthe following options:
-display host : dpy Specifieswhich display to use.
-sync Runsthe testsin synchronousmode. Normally only useful for debugging x11perf.
-pack Runsrectangle testsso that they pack rectanglesright next to each other. Thismakesit easy
to debug server code for stipplesand tiles; if the pattern looksugly, youve got alignment
problems.
-repeat <n> Repeatseach test n times(by default each test isrun fivetimes).
-time <s> Specifieshow long in secondseach test should be run (default 5 seconds).
-all Runsall tests. Thismay take a while.
-range Runsall the testsstarting from the specified name t est 1 until the name t est 2, tests. The
<t est 1>[,<t est 2>] testnamesshould be one of the optionsstarting from -dot. For example, -range line100
will perform the testsfrom the 100 pixel line test, and go on till the last test; -range
line100,dline10 will do the testsfrom line100 to dline10.
-labels Generatesjust the descriptive labelsfor each test specified. See x11perfcomp for more
details.
-fg col or - or - pi xel Specifiesthe foreground color or pixel value to use.
-bg col or - or - pi xel Specifiesthe background color or pixel value to use.
-clips def aul t Default number of clip windows.
579
-ddbg col or - or - pi xel Specifiesthe color or pixel value to use for drawing the odd segmentsof a DoubleDashed
line or arc. Thiswill default to the bg color.
-rop <rop0 rop1 ...> Use specified raster ops(default isGXcopy). Thisoption only affectsgraphicsbenchmarksin
which the graphicsfunction isactually used.
-pm <pm0 pm1 ...> Use specified planemasks(default is0). Thisoption only affectsgraphicsbenchmarksin
which the planemask isactually used.
-depth <dept h> Use a visual with <depth> planesper pixel. (Default isthe default visual.)
-vclass <vcl ass> Use a visual with of class<vcl ass>. <vcl ass> can be StaticGray, GrayScale,
StaticColor, PseudoColor, TrueColor, or DirectColor. (Default isthe default visual).
-reps <n> Specify the repetition count. (Default isnumber that takesapproximately five seconds.)
-subs <s0 s1 ...> Specify the number of sub windowsto use in the Window tests. Default is4, 16, 25, 50, 75,
100, and 200.
-v1.2 Perform only x11perf version 1.2 testsusing version 1.2 semantics.
-v1.3 Perform only x11perf version 1.3 testsusing version 1.3 semantics.
-su Set the save_under window attribute to True on all windowscreated by x11perf. Default is
False.
-bs Set the backing_store window attribute to the given value on all windowscreated by
<backing_store_hint> x11perf. <backing_store_hint> can be WhenMapped or Always. Default isNotUseful.
-dot Dot.
-rect1 11 solid-filled rectangle.
-rect10 1010 solid-filled rectangle.
-rect100 100100 solid-filled rectangle.
-rect500 500500 solid-filled rectangle.
-srect1 11 transparent stippled rectangle, 88 stipple pattern.
-srect10 1010 transparent stippled rectangle, 88 stipple pattern.
-srect100 100100 transparent stippled rectangle, 88 stipple pattern.
-srect500 500500 transparent stippled rectangle, 88 stipple pattern.
-osrect1 11 opaque stippled rectangle, 88 stipple pattern.
-osrect10 1010 opaque stippled rectangle, 88 stipple pattern.
-osrect100 100100 opaque stippled rectangle, 88 stipple pattern.
-osrect500 500500 opaque stippled rectangle, 88 stipple pattern.
-tilerect1 11 tiled rectangle, 44 tile pattern.
-tilerect10 1010 tiled rectangle, 44 tile pattern.
-tilerect100 100100 tiled rectangle, 44 tile pattern.
-tilerect500 500500 tiled rectangle, 44 tile pattern.
-oddsrect1 11 transparent stippled rectangle, 1715 stipple pattern.
-oddsrect10 1010 transparent stippled rectangle, 1715 stipple pattern.
-oddsrect100 100100 transparent stippled rectangle, 1715 stipple pattern.
-oddsrect500 500500 transparent stippled rectangle, 1715 stipple pattern.
-oddosrect1 11 opaque stippled rectangle, 1715 stipple pattern.
-oddosrect10 1010 opaque stippled rectangle, 1715 stipple pattern.
-oddosrect100 100100 opaque stippled rectangle, 1715 stipple pattern.
-oddosrect500 500500 opaque stippled rectangle, 1715 stipple pattern.
-oddtilerect1 11 tiled rectangle, 1715 tile pattern.
-oddtilerect10 1010 tiled rectangle, 1715 tile pattern.
x11perf
Part I: User Commands
580
-oddtilerect100 100100 tiled rectangle, 1715 tile pattern.
-oddtilerect500 500500 tiled rectangle, 1715 tile pattern.
-bigsrect1 11 stippled rectangle, 161145 stipple pattern.
-bigsrect10 1010 stippled rectangle, 161145 stipple pattern.
-bigsrect100 100100 stippled rectangle, 161145 stipple pattern.
-bigsrect500 500500 stippled rectangle, 161145 stipple pattern.
-bigosrect1 11 opaque stippled rectangle, 161145 stipple pattern.
-bigosrect10 1010 opaque stippled rectangle, 161145 stipple pattern.
-bigosrect100 100100 opaque stippled rectangle, 161145 stipple pattern.
-bigosrect500 500500 opaque stippled rectangle, 161145 stipple pattern.
-bigtilerect1 11 tiled rectangle, 161145 tile pattern.
-bigtilerect10 1010 tiled rectangle, 161145 tile pattern.
-bigtilerect100 100100 tiled rectangle, 161145 tile pattern.
-bigtilerect500 500500 tiled rectangle, 161145 tile pattern.
-eschertilerect1 11 tiled rectangle, 215208 tile pattern.
-eschertilerect10 1010 tiled rectangle, 215208 tile pattern.
-eschertilerect100 100100 tiled rectangle, 215208 tile pattern.
-eschertilerect500 500500 tiled rectangle, 215208 tile pattern.
-seg1 1-pixel thin line segment.
-seg10 10-pixel thin line segment.
-seg100 100-pixel thin line segment.
-seg500 500-pixel thin line segment.
-seg100c1 100-pixel thin line segment (1 obscuring rectangle).
-seg100c2 100-pixel thin line segment (2 obscuring rectangles).
-seg100c3 100-pixel thin line segment (3 obscuring rectangles).
-dseg10 10-pixel thin dashed segment (3 on, 2 off).
-dseg100 100-pixel thin dashed segment (3 on, 2 off).
-ddseg100 100-pixel thin double-dashed segment (3 fg, 2 bg).
-hseg10 10-pixel thin horizontal line segment.
-hseg100 100-pixel thin horizontal line segment.
-hseg500 500-pixel thin horizontal line segment.
-vseg10 10-pixel thin vertical line segment.
-vseg100 100-pixel thin vertical line segment.
-vseg500 500-pixel thin vertical line segment.
-whseg10 10-pixel wide horizontal line segment.
-whseg100 100-pixel wide horizontal line segment.
-whseg500 500-pixel wide horizontal line segment.
-wvseg10 10-pixel wide vertical line segment.
-wvseg100 100-pixel wide vertical line segment.
-wvseg500 500-pixel wide vertical line segment.
-line1 1-pixel thin (width 0) line.
-line10 10-pixel thin line.
-line100 100-pixel thin line.
-line500 500-pixel thin line.
581
-dline10 10-pixel thin dashed line (3 on, 2 off).
-dline100 100-pixel thin dashed line (3 on, 2 off).
-ddline100 100-pixel thin double-dashed line (3 fg, 2 bg).
-wline10 10-pixel line, line width 1.
-wline100 100-pixel line, line width 10.
-wline500 500-pixel line, line width 50.
-wdline100 100-pixel dashed line, line width 10 (30 on, 20 off).
-wddline100 100-pixel double-dashed line, line width 10 (30 fg, 20 bg).
-orect10 10x10 thin rectangle outline.
-orect100 100-pixel thin vertical line segment.
-orect500 500-pixel thin vertical line segment.
-worect10 1010 wide rectangle outline.
-worect100 100-pixel wide vertical line segment.
-worect500 500-pixel wide vertical line segment.
-circle1 1-pixel diameter thin (line-width 0) circle.
-circle10 10-pixel diameter thin circle.
-circle100 100-pixel diameter thin circle.
-circle500 500-pixel diameter thin circle.
-dcircle100 100-pixel diameter thin dashed circle (3 on, 2 off).
-ddcircle100 100-pixel diameter thin double-dashed circle (3 fg, 2 bg).
-wcircle10 10-pixel diameter circle, line width 1.
-wcircle100 100-pixel diameter circle, line width 10.
-wcircle500 500-pixel diameter circle, line width 50.
-wdcircle100 100-pixel diameter dashed circle, line width 10 (30 on, 20 off).
-wddcircle100 100-pixel diameter double-dashed circle, line width 10 (30 fg, 20 bg).
-pcircle10 10-pixel diameter thin partial circle, orientation and arc angle evenly distributed.
-pcircle100 100-pixel diameter thin partial circle.
-wpcircle10 10-pixel diameter wide partial circle.
-wpcircle100 100-pixel diameter wide partial circle.
-fcircle1 1-pixel diameter filled circle.
- fcircle10 10-pixel diameter filled circle.
-fcircle100 100-pixel diameter filled circle.
-fcircle500 500-pixel diameter filled circle.
-fcpcircle10 10-pixel diameter partial-filled circle, chord fill, orientation and arc angle evenly distributed.
-fcpcircle100 100-pixel diameter partial-filled circle, chord fill.
-fspcircle10 10-pixel diameter partial-filled circle, pie slice fill, orientation and arc angle evenly
distributed.
-fspcircle100 100-pixel diameter partial-filled circle, pie slice fill.
-ellipse10 10-pixel diameter thin (line width 0) ellipse, major and minor axissizesevenly distributed.
-ellipse100 100-pixel diameter thin ellipse.
-ellipse500 500-pixel diameter thin ellipse.
-dellipse100 100-pixel diameter thin dashed ellipse (3 on, 2 off).
-ddellipse100 100-pixel diameter thin double-dashed ellipse (3 fg, 2 bg).
-wellipse10 10-pixel diameter ellipse, line width 1.
x11perf
Part I: User Commands
582
-wellipse100 100-pixel diameter ellipse, line width 10.
-wellipse500 500-pixel diameter ellipse, line width 50.
-wdellipse100 100-pixel diameter dashed ellipse, line width 10 (30 on, 20 off).
-wddellipse100 100-pixel diameter double-dashed ellipse, line width 10 (30 fg, 20 bg).
-pellipse10 10-pixel diameter thin partial ellipse.
-pellipse100 100-pixel diameter thin partial ellipse.
-wpellipse10 10-pixel diameter wide partial ellipse.
-wpellipse100 100-pixel diameter wide partial ellipse.
-fellipse10 10-pixel diameter filled ellipse.
-fellipse100 100-pixel diameter filled ellipse.
-fellipse500 500-pixel diameter filled ellipse.
-fcpellipse10 10-pixel diameter partial-filled ellipse, chord fill.
-fcpellipse100 100-pixel diameter partial-filled ellipse, chord fill.
-fspellipse10 10-pixel diameter partial-filled ellipse, pie slice fill.
-fspellipse100 100-pixel diameter partial-filled ellipse, pie slice fill.
-triangle1 Fill 1-pixel/side triangle.
-triangle10 Fill 10-pixel/side triangle.
- triangle100 Fill 100-pixel/side triangle.
-trap1 Fill 11 trapezoid.
-trap10 Fill 1010 trapezoid.
-trap100 Fill 100100 trapezoid.
-trap300 Fill 300300 trapezoid.
-strap1 Fill 11 transparent stippled trapezoid, 88 stipple pattern.
-strap10 Fill 1010 transparent stippled trapezoid, 88 stipple pattern.
-strap100 Fill 100100 transparent stippled trapezoid, 88 stipple pattern.
-strap300 Fill 300300 transparent stippled trapezoid, 88 stipple pattern.
-ostrap1 Fill 1010 opaque stippled trapezoid, 88 stipple pattern.
-ostrap10 Fill 1010 opaque stippled trapezoid, 88 stipple pattern.
-ostrap100 Fill 100100 opaque stippled trapezoid, 88 stipple pattern.
-ostrap300 Fill 300300 opaque stippled trapezoid, 88 stipple pattern.
-tiletrap1 Fill 1010 tiled trapezoid, 44 tile pattern.
-tiletrap10 Fill 1010 tiled trapezoid, 44 tile pattern.
-tiletrap100 Fill 100100 tiled trapezoid, 44 tile pattern.
-tiletrap300 Fill 300300 tiled trapezoid, 44 tile pattern.
-oddstrap1 Fill 11 transparent stippled trapezoid, 1715 stipple pattern.
-oddstrap10 Fill 1010 transparent stippled trapezoid, 1715 stipple pattern.
-oddstrap100 Fill 100100 transparent stippled trapezoid, 1715 stipple pattern.
-oddstrap300 Fill 300300 transparent stippled trapezoid, 1715 stipple pattern.
-oddostrap1 Fill 1010 opaque stippled trapezoid, 1715 stipple pattern.
-oddostrap10 Fill 1010 opaque stippled trapezoid, 1715 stipple pattern.
-oddostrap100 Fill 100100 opaque stippled trapezoid, 1715 stipple pattern.
-oddostrap300 Fill 300300 opaque stippled trapezoid, 1715 stipple pat-tern.
-oddtiletrap1 Fill 1010 tiled trapezoid, 1715 tile pattern.
-oddtiletrap10 Fill 1010 tiled trapezoid, 1715 tile pattern.
583
-oddtiletrap100 Fill 100100 tiled trapezoid, 1715 tile pattern.
-oddtiletrap300 Fill 300300 tiled trapezoid, 1715 tile pattern.
-bigstrap1 Fill 11 transparent stippled trapezoid, 161145 stipple pattern.
-bigstrap10 Fill 1010 transparent stippled trapezoid, 161145 stipple pattern.
-bigstrap100 Fill 100100 transparent stippled trapezoid, 161145 stipple pattern.
-bigstrap300 Fill 300300 transparent stippled trapezoid, 161145 stipple pattern.
-bigostrap1 Fill 1010 opaque stippled trapezoid, 161145 stipple pattern.
-bigostrap10 Fill 1010 opaque stippled trapezoid, 161145 stipple pattern.
-bigostrap100 Fill 100100 opaque stippled trapezoid, 161145 stipple pattern.
-bigostrap300 Fill 300300 opaque stippled trapezoid, 161145 stipple pattern.
-bigtiletrap1 Fill 1010 tiled trapezoid, 161145 tile pattern.
-bigtiletrap10 Fill 1010 tiled trapezoid, 161145 tile pattern.
-bigtiletrap100 Fill 100100 tiled trapezoid, 161145 tile pattern.
-bigtiletrap300 Fill 300300 tiled trapezoid, 161145 tile pattern.
-eschertiletrap1 Fill 11 tiled trapezoid, 216208 tile pattern.
-eschertiletrap10 Fill 1010 tiled trapezoid, 216208 tile pattern.
-eschertiletrap100 Fill 100100 tiled trapezoid, 216208 tile pattern.
-eschertiletrap300 Fill 300300 tiled trapezoid, 216208 tile pattern.
-complex10 Fill 10-pixel/side complex polygon.
-complex100 Fill 100-pixel/side complex polygon.
-64poly10convex Fill 1010 convex 64-gon.
- 64poly100convex Fill 100100 convex 64-gon.
-64poly10complex Fill 1010 complex 64-gon.
-64poly100complex Fill 100100 complex 64-gon.
-ftext Character in 80-char line (613).
-f8text Character in 70-char line (813).
-f9text Character in 60-char line (915).
-f14text16 2-byte character in 40-char line (k14).
- tr10text Character in 80-char line (Times-Roman 10).
-tr24text Character in 30-char line (Times-Roman 24).
-polytext Character in 20/40/20 line (613, Times-Roman 10, 613).
-polytext16 2-byte character in 7/14/7 line (k14, k24).
-fitext Character in 80-char image line (613).
-f8itext Character in 70-char image line (813).
-f9itext Character in 60-char image line (915).
-f14itext16 2-byte character in 40-char image line (k14).
-f24itext16 2-byte character in 23-char image line (k24).
-tr10itext Character in 80-char image line (Times-Roman 10).
-tr24itext Character in 30-char image line (Times-Roman 24).
-scroll10 Scroll 1010 pixelsvertically.
-scroll100 Scroll 100100 pixelsvertically.
-scroll500 Scroll 500500 pixelsvertically.
x11perf
Part I: User Commands
584
-copywinwin10 Copy 1010 square from window to window.
-copywinwin100 Copy 100100 square from window to window.
-copywinwin500 Copy 500500 square from window to window.
-copypixwin10 Copy 1010 square from pixmap to window.
-copypixwin100 Copy 100100 square from pixmap to window.
-copypixwin500 Copy 500500 square from pixmap to window.
-copywinpix10 Copy 1010 square from window to pixmap.
-copywinpix100 Copy 100100 square from window to pixmap.
-copywinpix500 Copy 500500 square from window to pixmap.
-copypixpix10 Copy 1010 square from pixmap to pixmap.
-copypixpix100 Copy 100100 square from pixmap to pixmap.
-copypixpix500 Copy 500500 square from pixmap to pixmap.
-copyplane10 Copy 1010 1-bit deep plane.
-copyplane100 Copy 100100 1-bit deep plane.
-copyplane500 Copy 500500 1-bit deep plane.
-putimage10 PutImage 1010 square.
-putimage100 PutImage 100100 square.
-putimage500 PutImage 500500 square.
-putimagexy10 PutImage XY format 1010 square.
-putimagexy100 PutImage XY format 100100 square.
-putimagexy500 PutImage XY format 500500 square.
-shmput10 PutImage 1010 square, MIT-shared memory extension.
-shmput100 PutImage 100100 square, MIT-shared memory extension.
-shmput500 PutImage 500500 square, MIT-shared memory extension.
-shmputxy10 PutImage XY format 1010 square, MIT-shared memory extension.
-shmputxy100 PutImage XY format 100100 square, MIT-shared memory extension.
-shmputxy500 PutImage XY format 500500 square, MIT-shared memory extension.
-getimage10 GetImage 1010 square.
-getimage100 GetImage 100100 square.
-getimage500 GetImage 500500 square.
-getimagexy10 GetImage XY format 1010 square.
-getimagexy100 GetImage XY format 100100 square.
-getimagexy500 GetImage XY format 500500 square.
-noop X protocol NoOperation.
-atom GetAtomName.
-pointer QueryPointer.
-prop GetProperty.
-gc Change graphicscontext.
-create Create child window and map using MapSubwindows.
-ucreate Create unmapped window.
-map Map child window via MapWindow on parent.
-unmap Unmap child window via UnmapWindow on parent.
-destroy Destroy child window via DestroyWindow parent.
-popup Hide/expose window via Map/Unmap pop-up window.
585
-move Move window.
-umove Moved unmapped window.
-movetree Move window via MoveWindow on parent.
-resize Resize window.
-uresize Resize unmapped window.
-circulate Circulate lowest window to top.
-ucirculate Circulate unmapped window to top.
X DEFAULTS
There are no X defaultsused by thisprogram.
SEE ALSO
X(1), xbench(1), x11perfcomp(1)
AUTHORS
Joel McCormack
Phil Karlton
Susan Angebranndt
ChrisKent
Keith Packard
Graeme Gill
X Version 11 Release6
x11perfcomp
x11perfcompX11 server performance comparison program
SYNTAX
x11perfcomp [-rj -ro ] [ -l label_file ] f i l es
DESCRIPTION
The x11perfcomp program mergesthe output of several x11perf(1) runsinto a nice tabular format. It takesthe resultsin
each file, fillsin any missing test resultsif necessary, and for each test showsthe objects/second rate of each server. If invoked
with the -r or -ro options, it showsthe relative performance of each server to the first server.
Normally, x11perfcomp usesthe first file specified to determine which specific testsit should report on. Some (non-DEC:)
serversmay fail to perform all tests. In thiscase, x11perfcomp automatically substitutesin a rate of 0.0 objects/second. Since
the first file determineswhich teststo report on, thisfile must contain a superset of the testsreported in the other files, else
x11perfcomp will fail.
You can provide an explicit list of teststo report on by using the -l switch to specify a file of labels. You can create a label file
by using the -label option in x11perf.
OPTIONS
x11perfcomp acceptsthe following options:
-r Specifiesthat the output should also include relative server performance.
-ro Specifiesthat the output should include only relative server performance.
-l_label_file Specifiesa label file to use.
x11perfcomp
Part I: User Commands
586
X DEFAULTS
There are no X defaultsused by thisprogram.
SEE ALSO
X(1), x11perf(1)
AUTHORS
Mark Moraeswrote the original scriptsto compare servers. Joel McCormack just munged them together a bit.
X Version 11 Release6
xargs
xargsBuild and execute command linesfrom standard input
SYNOPSIS
xar gs [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]] [-n max-args]
[-s max-chars] [-P max-procs] [--null] [--eof[=eof-str]] [--replace[=replace-str]]
[--max-lines[=max-lines]] [--interactive] [--max-chars=max-chars] [--verbose]
[--exit] [--max-procs=max-procs] [--max-args=max-args] [--no-run-if-empty]
[--version] [--help] [command [initial-arguments]]
DESCRIPTION
Thismanual page documentsthe GNU version of xargs. xargs readsargumentsfrom the standard input, delimited by
blanks(which can be protected with double or single quotesor a backslash) or newlines, and executesthe command (default is
/bin/echo) one or more timeswith any initial-arguments followed by argumentsread from standard input. Blank lines
on the standard input are ignored.
xargs exitswith the following status:
0 if it succeeds
123 if any invocation of the command exited with status1-125
124 if the command exited with status255
125 if the command iskilled by a signal
126 if the command cannot be run
127 if the command isnot found
1 if some other error occurred.
OPTIONS
--null, -0 Input filenamesare terminated by a null character instead of by whitespace, and the quotes
and backslash are not special (every character istaken literally). Disablesthe end-of-file
string, which istreated like any other argument. Useful when argumentsmight contain
whitespace, quote marks, or backslashes. The GNU find -print0 option producesinput
suitable for thismode.
--eof[=eof-str], Set the end-of-file string to eof-str. If the end-of-file string occursasa line of input, the
-e[eof-str] rest of the input isignored. If eof-str isomitted, there isno end of file string. If this
option isnot given, the end-of-file string defaultsto an underscore.
--help Print a summary of the optionsto xargs and exit.
--replace[=r epl ace- st r ], Replace occurrencesof r epl ace- st r in the initial argumentswith namesread from
-i[r epl ace- st r ] standard input. Also, unquoted blanksdo not terminate arguments. If replace-str
isomitted, it defaultsto {} (like for find -exec). Implies-x and -l 1.
587
--max-lines[=max- l i nes], Use at most max- l i nes nonblank input linesper command line; max- l i nes defaultsto 1
-l[max- l i nes] if omitted. Trailing blankscause an input line to be logically continued on the next input
line. Implies-x.
--max-args=max- ar gs, Use at most max- ar gs argumentsper command line. Fewer than max- ar gs argumentswill
-n max- ar gs be used if the size (see the -s option) isexceeded, unlessthe -x option isgiven, in which
case xargs will exit.
--interactive, -p Prompt the user about whether to run each command line and read a line from the
terminal. Only run the command line if the response startswith y or Y. Implies-t.
--no-run-if-empty, -r If the standard input doesnot contain any nonblanks, do not run the command. Normally,
the command isrun once even if there isno input.
--max-chars=max- char s, Use at most max- char s charactersper command line, including the command and initial
-s max- char s argumentsand the terminating nulls at the endsof the argument strings. The default is
aslarge aspossible, up to 20k characters.
--verbose, -t Print the command line on the standard error output before executing it.
--version Print the version number of xargs and exit.
--exit, -x Exit if the size (see the -s option) isexceeded.
--max-procs=max- pr ocs, Run up to max- pr ocs processesat a time; the default is1. If max- pr ocs is0, xargs will
-P max- pr ocs run asmany processesaspossible at a time. Use the -n option with - P; otherwise, chances
are that only one exec will be done.
SEE ALSO
find(1L), locate(1L), locatedb(5L), updatedb(1) FindingFiles (online in info, or printed)
xauth
xauthX authority file utility
SYNOPSIS
xauth [ -f aut hf i l e ][-vqib ][command ar g ... ]
DESCRIPTION
The xauth program isused to edit and display the authorization information used in connecting to the X server. This
program isusually used to extract authorization recordsfrom one machine and merge them in on another (asisthe case
when using remote loginsor granting accessto other users). Commands(described below) may be entered interactively, on
the xauth command line, or in scripts. Note that thisprogram doesnot contact the X server. Normally xauth isnot used to
create the authority file entry in the first place; xdm doesthat.
OPTIONS
The following optionsmay be used with xauth. They may be given individually (for example, -q -i ) or may combined (for
example, -qi).
-f aut hf i l e Thisoption specifiesthe name of the authority file to use. By default, xauth will use the file
specified by the XAUTHORITY environment variable or Xauthority in the usershome
directory.
-q Thisoption indicatesthat xauth should operate quietly and not print unsolicited status
messages. Thisisthe default if an xauth command isgiven on the command line or if the
standard output isnot directed to a terminal.
-v Thisoption indicatesthat xauth should operate verbosely and print statusmessages
indicating the resultsof variousoperations(such ashow many recordshave been read in or
written out). Thisisthe default if xauth isreading commandsfrom itsstandard input and
itsstandard output isdirected to a terminal.
xauth
Part I: User Commands
588
-i Thisoption indicatesthat xauth should ignore any authority file locks. Normally, xauth
will refuse to read or edit any authority filesthat have been locked by other programs
(usually xdm or another xauth).
-b Thisoption indicatesthat xauth should attempt to break any authority file locksbefore
proceeding. Use thisoption only to clean up stale locks.
COMMANDS
The following commandsmay be used to manipulate authority files:
add di spl ayname An authorization entry for the indicated display using the given protocol and key data is
pr ot ocol name hexkey added to the authorization file. The data isspecified asan even-lengthed string of
hexadecimal digits, each pair representing one octet. The first digit of each pair gives
the most significant 4 bitsof the octet, and the second digit of the pair givesthe least
significant 4 bits. For example, a 32-character hexkey would represent a 128-bit value. A
protocol name consisting of just a single period istreated asan abbreviation for
MIT-MAGIC-COOKIE-1.
[n]extract f i l ename Authorization entriesfor each of the specified displaysare written to the indicated file. If
di spl ayname... the nextract command isused, the entriesare written in a numeric format suitable for
nonbinary transmission (such assecure electronic mail). The extracted entriescan be read
back in using the merge and nmerge commands.
If the filename consistsof just a single dash, the entrieswill be written to the standard
output.
[n]list [di spl ayname...] Authorization entriesfor each of the specified displays(or all if no displaysare named) are
printed on the standard output. If the nlist command isused, entrieswill be shown in the
numeric format used by the nextract command; otherwise, they are shown in a textual
format. Key data isalwaysdisplayed in the hexadecimal format given in the description of
the add command.
[n]merge [f i l ename...] Authorization entriesare read from the specified filesand are merged into the authorization
database, superceding any matching existing entries. If the nmerge command isused, the
numeric format given in the description of the extract command isused. If a filename
consistsof just a single dash, the standard input will be read if it hasnt been read before.
remove di spl ayname... Authorization entriesmatching the specified displaysare removed from the authority file.
source f i l ename The specified file istreated asa script containing xauth commandsto execute. Blank lines
and linesbeginning with a pound sign (#) are ignored. A single hyphen may be used to
indicate the standard input, if it hasnt already been read.
info Information describing the authorization file, whether or not any changeshave been made,
and from where xauth commandsare being read isprinted on the standard output.
exit If any modificationshave been made, the authority file iswritten out (if allowed), and the
program exits. An end-of-file istreated asan implicit exit command.
quit The program exits, ignoring any modifications. Thismay also be accomplished by pressing
the interrupt character.
help [st r i ng] A description of all commandsthat begin with the given string (or all commandsif no
string isgiven) isprinted on the standard output.
? A short list of the valid commandsisprinted on the standard output.
DISPLAY NAMES
Display namesfor the add, [n]extract, [n]list, [n]merge,and remove commandsuse the same format asthe DISPLAY
environment variable and the common -display command-line argument. Display-specific information (such asthe screen
number) isunnecessary and will be ignored. Same-machine connections(such aslocal-host sockets, shared memory, and the
Internet Protocol hostname localhost) are referred to ashostname/unix:displaynumber so that local entriesfor different
589
machinesmay be stored in one authority file.
EXAMPLE
The most common use for xauth isto extract the entry for the current display, copy it to another machine, and merge it into
the usersauthority file on the remote machine:
% xauth extract
- $DISPLAY | rsh otherhost xauth merge -
ENVIRONMENT
Thisxauth program usesthe following environment variables:
XAUTHORITY To get the name of the authority file to use if the -f option isnt used.
HOME To get the usershome directory if XAUTHORITY isnt defined.
FILES
$HOME/.Xauthority isthe default authority file if XAUTHORITY isnt defined.
X Version 11 Release6
xauth
Part I: User Commands
590
591
[n]list [di spl ayname...] Authorization entriesfor each of the specified displays(or all if
no displaysare named) are printed on the standard output. If
the nlist command isused, entrieswill be shown in the
numeric format used by the nextract command; otherwise,
they are shown in a textual format. Key data isalways
displayed in the hexadecimal format given in the description of
the add command.
[n]merge [f i l ename...] Authorization entriesare read from the specified filesand are
merged into the authorization database, superseding any
matching existing entries. If the nmerge command isused, the
numeric format given in the description of the extract
command isused. If a filename consistsof just a single dash,
the standard input will be read if it hasnt been read before.
remove di spl ayname... Authorization entriesmatching the specified displaysare
removed from the authority file.
source f i l ename The specified file istreated asa script containing xauth
commandsto execute. Blank linesand linesbeginning with a #
are ignored. A single dash may be used to indicate the standard
input, if it hasnt already been read.
info Information describing the authorization file, whether or not
any changeshave been made, and from where xauth com-
mandsare being read isprinted on the standard output.
exit If any modificationshave been made, the authority file is
written out (if allowed), and the program exits. An end of file
istreated asan implicit exit command.
quit The program exits, ignoring any modifications. Thismay also
be accomplished by pressing the interrupt character.
help [st r i ng] A description of all commandsthat begin with the given string
(or all commandsif no string isgiven) isprinted on the
standard output.
? A short list of the valid commandsisprinted on the standard
output.
DISPLAY NAMES
Display namesfor the add, [n]extract, [n]list, [n]merge, and remove commandsuse the same format asthe DISPLAY
environment variable and the common display command-line argument. Display-specific information (such asthe screen
number) isunnecessary and will be ignored. Same-machine connections(such aslocal-host sockets, shared memory, and the
Internet Protocol hostnamel ocal host ) are referred to ashostname/unix:displaynumber so that local entriesfor different
machinesmay be stored in one authority file.
EXAMPLE
The most common use for xauth isto extract the entry for the current display, copy it to another machine, and merge it into
the usersauthority file on the remote machine:
% xauth extract
$DISPLAY j rsh otherhost xauth merge
Part I: User Commands
592
ENVIRONMENT
Thisxauth program usesthe following environment variables:
XAUTHORITY To get the name of the authority file to use if the f option
isnt used
HOME To get the usershome directory if XAUTHORITY isnt defined
FILES
$HOME/.Xauthority Default authority file if XAUTHORITY isnt defined
BUGS
Usersthat have unsecured networksshould take care to use encrypted file transfer mechanismsto copy authorization entries
between machines. Similarly, the MIT-MAGIC-COOKIE-1 protocol isnot very useful in unsecured environments. Sitesthat are
interested in additional security may need to use encrypted authorization mechanismssuch asKerberos.
Spacesare currently not allowed in the protocol name. Quoting could be added for the truly perverse.
AUTHOR
Jim Fulton, MIT X Consortium
X Version 11 Release6
xbmtopbm
xbmtopbmConvert an X11 or X10 bitmap into a portable bitmap
SYNOPSIS
xbmtopbm [bi t mapf i l e]
DESCRIPTION
Readsan X11 or X10 bitmap asinput. Producesa portable bitmap asoutput.
SEE ALSO
pbmtoxbm(1), pbmtox10bm(1), pbm(5)
AUTHOR
Copyright (c) 1988 by Jef Poskanzer.
31 August 1988
xcmsdb
xcmsdbDevice Color Characterization utility for X Color Management System
SYNOPSIS
xcmsdb [ query ][remove ][format 32j16j8 ][f i l ename ]
593
DESCRIPTION
xcmsdb isused to load, query, or remove device color characterization data stored in propertieson the root window of the
screen asspecified in section 7, Device Color Characterization, of the ICCCM. Device color characterization data (also
called the Device Profile) isan integral part of XlibsX Color Management System (xcms), necessary for proper conversion
of color specification between device-independent and device-dependent forms. xcms uses33 matricesstored in the
XDCCC_LINEAR_RGB_MATRICES property to convert color specificationsbetween CIEXYZ and RGB Intensity (XcmsRGBi, also
referred to aslinear RGB). xcms then usesdisplay gamma information stored in the XDCCC_LINEAR_RGB_CORRECTION property to
convert color specificationsbetween RGBi and RGB device (XcmsRGB, also referred to asdevice RGB).
Note that xcms allowsclientsto register function setsin addition to itsbuilt-in function set for CRT color monitors.
Additional function setsmay store their device profile information in other propertiesin function set specific format. This
utility isunaware of these nonstandard properties.
The ASCII readable contentsof filename (or the standard input if no input file isgiven) are appropriately transformed for
storage in properties, provided the query or remove optionsare not specified.
OPTIONS
xcmsdb program acceptsthe following options:
query Thisoption attemptsto read the XDCCC propertiesoff the
screensroot window. If successful, it transformsthe data into
a more readable format, then sendsthe data to standard out.
remove Thisoption attemptsto remove the XDCCC propertieson the
screensroot window.
format 32j16j8 Specifiesthe property format (32, 16, or 8 bitsper entry) for
the XDCCC_LINEAR_RGB_CORRECTION property. Precision of
encoded floating-point valuesincreaseswith the increase in
bitsper entry. The default is32 bitsper entry.
SEE ALSO
xprop(1), Xlib documentation
ENVIRONMENT
DISPLAY To figure out which display and screen to use
AUTHOR
Chuck Adams, Tektronix, Inc., and Al Tabayoyon, SynChromatics, Inc. (added multivisual support)
X Version 11 Release6
xclock
xclockAnalog/digital clock for X
SYNOPSIS
xclock [ help ][analog ][digital ][chime ][hd col or ][hl col or ]
[update seconds ][padding number ]
DESCRIPTION
The xclock program displaysthe time in analog or digital form. The time iscontinuously updated at a frequency which may
be specified by the user.
xclock
Part I: User Commands
594
OPTIONS
xclock acceptsall of the standard X Toolkit command-line optionsalong with the additional optionslisted here:
help Thisoption indicatesthat a brief summary of the allowed
optionsshould be printed on the standard error.
analog Thisoption indicatesthat a conventional 12-hour clock face
with tick marksand handsshould be used. Thisisthe default.
digital or d Thisoption indicatesthat a 24-hour digital clock should be
used.
chime Thisoption indicatesthat the clock should chime once on the
half hour and twice on the hour.
hands col or (or hd col or ) Thisoption specifiesthe color of the handson an analog
clock. The default isblack.
highlight col or (or hl col or ) Thisoption specifiesthe color of the edgesof the handson an
analog clock, and isonly useful on color displays. The default
isblack.
update seconds Thisoption specifiesthe frequency in secondsat which xclock
should update itsdisplay. If the clock isobscured and then
exposed, it will be updated immediately. A value of 30 seconds
or lesswill enable a second hand on an analog clock. The
default is60 seconds.
padding number Thisoption specifiesthe width in pixelsof the padding
between the window border and clock text or picture. The
default is10 on a digital clock and 8 on an analog clock.
X DEFAULTS
Thisprogram usesthe Clock widget. It understandsall of the core resource namesand classesaswell as:
width (class Width) Specifiesthe width of the clock. The default for analog clocks
is164 pixels; the default for digital clocksiswhatever isneeded
to hold the clock when displayed in the chosen font.
height (class Height) Specifiesthe height of the clock. The default for analog clocks
is164 pixels; the default for digital clocksiswhatever isneeded
to hold the clock when displayed in the chosen font.
update (class Interval) Specifiesthe frequency in secondsat which the time should be
redisplayed.
foreground (class Foreground) Specifiesthe color for the tick marks. The default isdepends
on whether reverseVideo isspecified. If reverseVideo is
specified, the default islwhite; otherwise, the default isblack.
hands (class Foreground) Specifiesthe color of the insidesof the clockshands. The
default dependson whether reverseVideo isspecified. If
reverseVideo isspecified, the default islwhite; otherwise, the
default isblack.
highlight (class Foreground) Specifiesthe color used to highlight the clockshands. The
default dependson whether reverseVideo isspecified. If
reverseVideo isspecified, the default islwhite; otherwise, the
default isblack.
analog (class Boolean) Specifieswhether or not an analog clock should be used
instead of a digital one. The default isTrue.
chime (class Boolean) Specifieswhether or not a bell should be rung on the hour and
half hour.
595
padding (class Margin) Specifiesthe amount of internal padding in pixelsto be used.
The default is8.
font (class Font) Specifiesthe font to be used for the digital clock. Note that
variable width fontscurrently will not alwaysdisplay correctly.
WIDGETS
In order to specify resources, it isuseful to know the hierarchy of the widgetswhich compose xclock. In the following
notation, indentation indicateshierarchical structure. The widget classname isgiven first, followed by the widget instance
name:
XClock xclock
Clock clock
ENVIRONMENT
DISPLAY To get the default host and display number
XENVIRONMENT To get the name of a resource file that overridesthe global
resourcesstored in the RESOURCE_MANAGER property
FILES
<XRoott/lib/X11/app-defaults/XClock Specifiesrequired resources
SEE ALSO
X(1), xrdb(1), time(3C)
BUGS
xclock believesthe system clock.
When in digital mode, the string should be centered automatically.
AUTHORS
Tony Della Fera (MIT-Athena, DEC), Dave Mankins(MIT-Athena, BBN), and Ed Moy (UC Berkeley)
X Version 11 Release6
xclipboard
xclipboardX clipboard client
SYNOPSIS
xclipboard [ toolkitoption ... ] [ w ][nw ]
DESCRIPTION
The xclipboard program isused to collect and display text selectionsthat are sent to the Clipboard by other clients. It is
typically used to save Clipboard selectionsfor later use. It storeseach Clipboard selection asa separate string, each of which
can be selected. Each time Clipboard isasserted by another application, xclipboard transfersthe contentsof that selection to
a new buffer and displaysit in the text window. Buffersare never automatically deleted, so youll want to use the delete
button to get rid of uselessitems.
Since xclipboard usesa Text Widget to display the contentsof the clipboard, text sent to the Clipboard may be reselected for
use in other applications. xclipboard also respondsto requestsfor the Clipboard selection from other clientsby sending the
entire contentsof the currently displayed buffer.
xclipboard
Part I: User Commands
596
An xclipboard window hasthe following buttonsacrossthe top:
quit When thisbutton ispressed, xclipboard exits.
delete When thisbutton ispressed, the current buffer isdeleted and
the next one displayed.
new Createsa new buffer with no contents. Useful in constructing
a new Clipboard selection by hand.
save Displaysa File Save dialog box. Pressing the Accept button
savesthe currently displayed buffer to the file specified in the
text field.
next Displaysthe next buffer in the list.
previous Displaysthe previousbuffer.
OPTIONS
The xclipboard program acceptsall of the standard X Toolkit command-line optionsaswell asthe following:
w Thisoption indicatesthat linesof text that are too long to be
displayed on one line in the clipboard should wrap around to
the following lines.
nw Thisoption indicatesthat long linesof text should not wrap
around. Thisisthe default behavior.
WIDGETS
In order to specify resources, it isuseful to know the hierarchy of the widgetswhich compose xclipboard. In the following
notation, indentation indicateshierarchical structure. The widget classname isgiven first, followed by the widget instance
name.
XClipboard xclipboard
Form form
Command Quit
Command delete
Command new
Command Save
Command next
Command prev
Label index
Text text
TransientShell fileDialogShell
Dialog fileDialog
Label label
Command accept
Command cancel
Text value
TransientShell failDialogShell
Dialog failDialog
Label label
Command continue
SENDING/RETRIEVING CLIPBOARD CONTENTS
Text iscopied to the Clipboard whenever a client assertsownership of the Clipboard selection. Text iscopied from the
Clipboard whenever a client requeststhe contentsof the Clipboard selection. Examplesof event bindingsthat a user may
wish to include in a resource configuration file to use the Clipboard are
*VT100.Translations: #override \
<Btn3Up>: select-end(CLIPBOARD) \n\
597
<Btn2Up>: insert-selection(PRIMARY,CLIPBOARD) \n\
<Btn2Down>: ignore ()
SEE ALSO
X(1), xcutsel(1), xterm(1), individual client documentation for how to make a selection and send it to the Clipboard.
ENVIRONMENT
DISPLAY To get the default host and display number
XENVIRONMENT To get the name of a resource file that overridesthe global
resourcesstored in the RESOURCE_MANAGER property
FILES
<XRoot>/lib/X11/app-defaults/XClipboard Specifiesrequired resources
AUTHOR
Ralph R. Swick (DEC/MIT Project Athena), ChrisD. Peterson (MIT X Consortium), Keith Packard (MIT X Consortium)
X Version 11 Release6
xconsole
xconsoleMonitor system console messageswith X
SYNOPSIS
xconsole [-t ool ki t opt i on ...] [-file f i l e- name] [-notify] [-stripNonprint] [-daemon] [-verbose]
[-exitOnFail]
DESCRIPTION
The xconsole program displaysmessagesthat are usually sent to /dev/console.
OPTIONS
xconsole acceptsall of the standard X Toolkit command-line optionsalong with the additional optionslisted here:
file f i l e- name To monitor some other device, use thisoption to specify the
device name. Thisdoesnot work on regular filesasthey are
alwaysready to be read from.
notify, nonotify When new data are received from the console and the notify
option isset, the icon name of the application has* appended,
so that it isevident even when the application isiconified.
notify isthe default.
daemon Thisoption causesXconsole to place itself in the background,
using fork/exit.
verbose When set, thisoption directsxconsole to display an informa-
tive message in the first line of the text buffer.
exitOnFail When set, thisoption directsxconsole to exit when it isunable
to redirect the console output.
X DEFAULTS
Thisprogram usesthe Athena Text widget, look in the Athena Widget Set documentation for controlling it.
xconsole
Part I: User Commands
598
WIDGETS
In order to specify resources, it isuseful to know the hierarchy of the widgetsthat compose xconsole. In the following
notation, indentation indicateshierarchical structure. The widget classname isgiven first, followed by the widget instance
name.
XConsole xconsole
XConsole text
ENVIRONMENT
DISPLAY To get the default host and display number.
XENVIRONMENT To get the name of a resource file that overridesthe global
resourcesstored in the RESOURCE_MANAGER property.
FILES
<XRoot>/lib/X11/app-defaults/XConsole Specifiesrequired resources
SEE ALSO
X(1), xrdb(1), Athena Text widget
AUTHOR
Keith Packard (MIT X Consortium)
X Version 11 Release6
xcutsel
xcutselInterchange between cut buffer and selection
SYNOPSIS
xcutsel [ -t ool ki t opt i on ...] [-selection sel ect i on] [-cutbuffer number ]
DESCRIPTION
The xcutsel program isused to copy the current selection into a cut buffer and to make a selection that containsthe current
contentsof the cut buffer. It actsasa bridge between applicationsthat dont support selectionsand those that do.
By default, xcutsel will use the selection named PRIMARY and the cut buffer CUT_BUFFER0. Either or both of these can be
overridden by command-line argumentsor by resources.
An xcutsel window hasthe following buttons:
quit When thisbutton ispressed, xcutsel exits. Any selectionsheld
by xcutsel are automatically released.
copy PRIMARY to 0 When thisbutton ispressed, xcutsel copiesthe current
selection into the cut buffer.
copy 0 to PRIMARY When thisbutton ispressed, xcutsel convertsthe current
contentsof the cut buffer into the selection.
The button labelsreflect the selection and cut buffer selected by command-line optionsor through the resource database.
When the copy 0 to PRIMARY button isactivated, the button will remain inverted aslong asxcutsel remainsthe owner of
the selection. Thisservesto remind you which client ownsthe current selection. Note that the value of the selection remains
constant; if the cut buffer ischanged, you must again activate the copy button to retrieve the new value when desired.
599
OPTIONS
Xcutsel acceptsall of the standard X Toolkit command-line optionsaswell asthe following:
selection name Thisoption specifiesthe name of the selection to use. The
default isPRIMARY. The only supported abbreviationsfor this
option are -select, -sel, and -s, asthe standard toolkit option
-selectionTimeout hasa similar name.
cutbuffer number Thisoption specifiesthe cut buffer to use. The default is
cutbuffer 0.
X DEFAULTS
Thisprogram acceptsall of the standard X Toolkit resource namesand classesaswell asthe following:
selection (class Selection) Thisresource specifiesthe name of the selection to use. The
default isPRIMARY.
cutBuffer (class CutBuffer) Thisresource specifiesthe number of the cutbuffer to use.
The default is0.
WIDGET NAMES
The following instance namesmay be used when user configuration of the labelsin them isdesired:
sel-cut (class Command) Thisisthe copy SELECTION to BUFFER button.
cut-sel (class Command) Thisisthe copy BUFFER to SELECTION button.
quit (class Command) Thisisthe quit button.
SEE ALSO
X(1), xclipboard(1), xterm(1), text widget documentation, individual client documentation for how to make a selection.
BUGS
There isno way to change the name of the selection or the number of the cut buffer while the program isrunning.
AUTHOR
Ralph R. Swick (DEC/MIT Project Athena)
X Version 11 Release6
xdm
xdmX Display Manager with support for XDMCP, host chooser
SYNOPSIS
xdm [ config conf i gur at i on_f i l e ][nodaemon ][debug debug_l evel ]
[error er r or _l og_f i l e ][resources r esour ce_f i l e ][server ser ver _ent r y ]
[sessi onsessi on_pr ogr am]
DESCRIPTION
xdm managesa collection of X displays, which may be on the local host or remote servers. The design of xdm wasguided by
the needsof X terminalsaswell asthe X Consortium standard XDMCP, the X Display Manager Control Protocol. Xdm provides
servicessimilar to those provided by init, getty, and login on character terminals: prompting for login name and password,
authenticating the user, and running a session.
xdm
Part I: User Commands
600
A session isdefined by the lifetime of a particular process; in the traditional character-based terminal world, it isthe users
login shell. In the xdm context, it isan arbitrary session manager. Thisisbecause in a windowing environment, a userslogin
shell processdoesnot necessarily have any terminal-like interface with which to connect. When a real session manager isnot
available, a window manager or terminal emulator istypically used asthe session manager, meaning that termination of this
processterminatesthe userssession.
When the session isterminated, xdm resetsthe X server and (optionally) restartsthe whole process.
When xdm receivesan Indirect query via XDMCP, it can run a chooser processto perform an XDMCP BroadcastQuery (or
an XDMCP Query to specified hosts) on behalf of the display and offer a menu of possible hoststhat offer XDMCP display
management. Thisfeature isuseful with X terminalsthat do not offer a host menu themselves.
Because xdm providesthe first interface that userswill see, it isdesigned to be simple to use and easy to customize to the needs
of a particular site. xdm hasmany options, most of which have reasonable defaults. Browse through the varioussectionsof this
manual, picking and choosing the thingsyou want to change. Pay particular attention to the Session Program subsection,
which will describe how to set up the style of session desired.
OVERVIEW
xdm ishighly configurable, and most of itsbehavior can be controlled by resource filesand shell scripts. The namesof these
filesthemselvesare resourcesread from the file xdm-config or the file named by the config option.
xdm offersdisplay management two different ways. It can manage X serversrunning on the local machine and specified in
Xservers, and it can manage remote X servers(typically X terminals) using XDMCP (the XDM Control Protocol) asspecified in
the Xaccess file.
The resourcesof the X clientsrun by xdm outside the userssession, including xdmsown login window, can be affected by
setting resourcesin the Xresources file.
For X terminalsthat do not offer a menu of hoststo get display management from, xdm can collect willing hostsand run the
chooser program to offer the user a menu. For X displaysattached to a host, thisstep istypically not used, asthe local host
doesthe display management.
After resetting the X server, xdm runsthe Xsetup script to assist in setting up the screen the user seesalong with the xlogin
widget.
When the user logsin, xdm runsthe Xstartup script asroot.
Then xdm runsthe Xsession script asthe user. Thissystem session file may do some additional startup and typically runsa
script in the usershome directory. When the Xsession script exits, the session isover.
At the end of the session, the Xreset script isrun to clean up, the X server isreset, and the cycle startsover.
The file /usr/X11R6/lib/X11/xdm/xdm-errors will contain error messagesfrom xdm and anything output to stderr by Xsetup,
Xstartup, Xsession, or Xreset. When you have trouble getting xdm working, check thisfile to see if xdm hasany cluesto the
trouble.
OPTIONS
All of these options, except config itself, specify valuesthat can also be specified in the configuration file asresources.
config conf i gur at i on_f i l e Namesthe configuration file, which specifiesresourcesto
control the behavior of xdm. <XRoot>/lib/X11/xdm/xdm-config is
the default. See the subsection called Configuration File.
nodaemon Specifiesfalse asthe value for the DisplayManager.daemonMode
resource. Thissuppressesthe normal daemon behavior, which
isfor xdm to close all file descriptors, disassociate itself from the
controlling terminal, and put itself in the background when it
first startsup.
601
debug debug_l evel Specifiesthe numeric value for the DisplayManager.debugLevel
resource. A non-zero value causesxdm to print lotsof
debugging statementsto the terminal; it also disablesthe
DisplayManager.daemonModeresource, forcing xdm to run
synchronously. To interpret these debugging messages, a copy
of the source code for xdm isalmost a necessity. No attempt has
been made to rationalize or standardize the output.
error er r or _l og_f i l e Specifiesthe value for the DisplayManager.errorLogFile
resource. Thisfile containserrorsfrom xdm aswell asanything
written to stderr by the variousscriptsand programsrun
during the progressof the session.
resources r esour ce_f i l e Specifiesthe value for the DisplayManager*resources resource.
Thisfile isloaded using xrdb to specify configuration
parametersfor the authentication widget.
server ser ver _ent r y Specifiesthe value for the DisplayManager.servers resource.
See the subsection Local Server Specification for a descrip-
tion of thisresource.
udpPort por t _number Specifiesthe value for the DisplayManager.requestPort
resource. Thissetsthe port number, which xdm will monitor
for XDMCP requests. AsXDMCP usesthe registered well-
known UDP port 177, thisresource should not be changed
except for debugging.
session sessi on_pr ogr am Specifiesthe value for the DisplayManager*session resource.
Thisindicatesthe program to run asthe session after the user
haslogged in.
xrm r esour ce_spec i f i cat i on Allowsan arbitrary resource to be specified, asin most X
Toolkit applications.
RESOURCES
At many stagesthe actionsof xdm can be controlled through the use of itsconfiguration file, which isin the X resource
format. Some resourcesmodify the behavior of xdm on all displays, while othersmodify itsbehavior on a single display.
Where actionsrelate to a specific display, the display name isinserted into the resource name between Display-Manager and
the final resource name segment.
For local displays, the resource name and classare asread from the Xservers file.
For remote displays, the resource name iswhat the network addressof the display resolvesto. See the removeDomain resource.
The name must match exactly; xdm isnot aware of all the network aliasesthat might reach a given display. If the name resolve
fails, the addressisused. The resource classisassent by the display in the XDMCP Manage request.
Because the resource manager usescolonsto separate the name of the resource from itsvalue and dotsto separate resource
name parts, xdm substitutesunderscoresfor both dotsand colonswhen generating the resource name. For example,
DisplayManager.expo x org 0.startup isthe name of the resource that definesthe startup shell file for the expo.x.org:0
display.
DisplayManager.servers Thisresource either specifiesa filename full of server entries,
one per line (if the value startswith a slash), or a single server
entry. See the subsection Local Server Specification for the
details.
DisplayManager.requestPort Thisindicatesthe UDP port number that xdm usesto listen for
incoming XDMCP requests. Unlessyou need to debug the
system, leave thiswith itsdefault value of 177.
xdm
Part I: User Commands
602
DisplayManager.errorLogFile Error output isnormally directed at the system console. To
redirect it, set thisresource to a filename. A method to send
these messagesto syslog should be developed for systemsthat
support it; however, the wide variety of interfacesprecludes
any system-independent implementation. Thisfile also
containsany output directed to stderr by the Xsetup, Xstartup,
Xsession, and Xreset files, so it will contain descriptionsof
problemsin those scriptsaswell.
DisplayManager.debugLevel If the integer value of thisresource isgreater than zero, reams
of debugging information will be printed. It also disables
daemon mode, which would redirect the information into the
bit-bucket, and allowsnonroot usersto run xdm, which would
normally not be useful.
DisplayManager.daemonMode Normally, xdm attemptsto make itself into a daemon process
unassociated with any terminal. Thisisaccomplished by
forking and leaving the parent processto exit, then closing file
descriptorsand releasing the controlling terminal. In some
environmentsthisisnot desired (in particular, when
debugging). Setting thisresource to false will disable this
feature.
DisplayManager.pidFile The filename specified will be created to contain an ASCII
representation of the process-id of the main xdm process. xdm
also usesfile locking on thisfile to attempt to eliminate
multiple daemonsrunning on the same machine, which would
cause quite a bit of havoc.
DisplayManager.lockPidFile Thisisthe resource which controlswhether xdm usesfile
locking to keep multiple display managersfrom running
amok. On System V, thisusesthe lockf library call, while on
BSD it usesflock.
DisplayManager.authDir Thisnamesa directory in which xdm storesauthorization files
while initializing the session. The default value isy.
DisplayManager.autoRescan ThisBoolean controlswhether xdm rescansthe configuration,
servers, accesscontrol and authentication keysfilesafter a
session terminatesand the fileshave changed. By default it is
true. You can force xdm to reread these filesby sending a
SIGHUP to the main process.
DisplayManager.removeDomainname When computing the display name for XDMCP clients, the name
resolver will typically create a fully qualified hostname for the
terminal. Asthisissometimesconfusing, xdm will remove the
domain name portion of the hostname if it isthe same asthe
domain name of the local host when thisvariable isset. By
default the value istrue.
DisplayManager.keyFile XDM-AUTHENTICATION-1 style XDMCP authentication requires
that a private key be shared between xdm and the terminal. This
resource specifiesthe file containing those values. Each entry
in the file consistsof a display name and the shared key. By
default, xdm doesnot include support for XDM-AUTHENTICATION-1,
asit requiresDES, which isnot generally distributable because
of United Statesexport restrictions.
603
DisplayManager.accessFile To prevent unauthorized XDMCP service and to allow
forwarding of XDMCP IndirectQuery requests, thisfile
containsa database of hostnamesthat are either allowed direct
accessto thismachine, or have a list of hoststo which queries
should be forwarded to. The format of thisfile isdescribed in
the subsection XDMCP AccessControl.
DisplayManager.exportList A list of additional environment variables, separated by
whitespace, to passon to the Xsetup, Xstartup, Xsession,and
Xreset programs.
DisplayManager.randomFile A file to checksum to generate the seed of authorization keys.
Thisshould be a file that changesfrequently. The default is
/dev/mem.
DisplayManager.greeterLib On systemsthat support a dynamically loadable greeter library,
the name of the library. Default is<XRoot>/lib/X11/xdm/
libXdmGreet.so.
DisplayManager.choiceTimeout Number of secondsto wait for display to respond after user
hasselected a host from the chooser. If the display sendsan
XDMCP IndirectQuery within thistime, the request is
forwarded to the chosen host. Otherwise, it isassumed to be
from a new session and the chooser isoffered again. Default
is15.
DisplayManager.DI SPLAY.resources Thisresource specifiesthe name of the file to be loaded by
xrdb asthe resource database onto the root window of screen 0
of the display. The Xsetup program, the Login widget, and
chooser will use the resourcesset in thisfile. Thisresource
database isloaded just before the authentication procedure is
started, so it can control the appearance of the login window.
See the subsection Authentication Widget, which describes
the variousresourcesthat are appropriate to place in thisfile.
There isno default value for thisresource, but <XRoot>/lib/
X11/xdm/Xresources isthe conventional name.
DisplayManager.DI SPLAY.chooser Specifiesthe program run to offer a host menu for Indirect
queriesredirected to the special hostname CHOOSER. <XRoot>
/lib/X11/xdm/chooser isthe default. See the subsections
XDMCP AccessControl and chooser.
DisplayManager.DI SPLAY.xrdb Specifiesthe program used to load the resources. By default,
xdm uses<XRoot>/bin/xrdb.
DisplayManager.DI SPLAY.cpp Thisspecifiesthe name of the C preprocessor that isused by
xrdb.
DisplayManager.DI SPLAY.setup Thisspecifiesa program that isrun (asroot) before offering
the Login window. Thismay be used to change the appearance
of the screen around the Login window or to put up other
windows(for example, you may want to run xconsole here).
By default, no program isrun. The conventional name for a
file used here isXsetup. See the subsection Setup Program.
DisplayManager.DI SPLAY.startup Thisspecifiesa program that isrun (asroot) after the
authentication processsucceeds. By default, no program isrun.
The conventional name for a file used here isXstartup. See the
subsection Startup Program.
DisplayManager.DI SPLAY.session Thisspecifiesthe session to be executed (not running asroot).
By default, <XRoot>/bin/xterm isrun. The conventional name
isXsession. See the subsection Session Program.
xdm
Part I: User Commands
604
DisplayManager.DI SPLAY.reset Thisspecifiesa program which isrun (asroot) after the session
terminates. Again, by default, no program isrun. The
conventional name isXreset. See the subsection Reset
Program.
DisplayManager.DI SPLAY.openDelay, These numeric resourcescontrol the behavior of xdm when
DisplayManager.DI SPLAY.openRepeat, attempting to open intransigent servers. openDelay isthe length
DisplayManager.DI SPLAY.openTimeout, of the pause (in seconds) between successive attempts,
DisplayManager.DI SPLAY.startAttempts openRepeat isthe number of attemptsto make, openTimeout is
the amount of time to wait while actually attempting the open
(that is, the maximum time spent in the connect(2) system
call) and startAttempts isthe number of timesthisentire
processisdone before giving up on the server. After openRepeat
attemptshave been made, or if openTimeout secondselapse in
any particular attempt, xdm terminatesand restartsthe server,
attempting to connect again. Thisprocessisrepeated
startAttempts times, at which point the display isdeclared
dead and disabled. Although thisbehavior may seem arbitrary,
it hasbeen empirically developed and worksquite well on
most systems. The default valuesare 5 for openDelay, 5 for
openRepeat, 30 for openTimeout and 4 for startAttempts.
DisplayManager.DI SPLAY.pingInterval, To discover when remote displaysdisappear, xdm
DisplayManager.DI SPLAY. pingTimeout occasionally pingsthem, using an X connection and XSync
calls. pingInterval specifiesthe time (in minutes) between
each ping attempt, pingTimeout specifiesthe maximum
amount of time (in minutes) to wait for the terminal to
respond to the request. If the terminal doesnot respond, the
session isdeclared dead and terminated. By default, both are
set to 5 minutes. If you frequently use X terminalsthat can
become isolated from the managing host, you might want to
increase thisvalue. The only worry isthat sessionswill
continue to exist after the terminal hasbeen accidentally
disabled. xdm will not ping local displays. Although it would
seem harmless, it isunpleasant when the workstation session is
terminated asa result of the server hanging for NFS service
and not responding to the ping.
DisplayManager.DI SPLAY. ThisBoolean resource specifieswhether the X server should be
terminateServer terminated when a session terminates(instead of resetting it).
Thisoption can be used when the server tendsto grow
without bound over time, in order to limit the amount of time
the server isrun. The default value isfalse.
DisplayManager.DI SPLAY.userPath xdm setsthe PATH environment variable for the session to this
value. It should be a colon separated list of directories; see
sh(1) for a full description. :/bin:/usr/bin:/usr/X11R6/bin
:/usr/ucb isa common setting. The default value can be
specified at build time in the X system configuration file with
DefaultUserPath.
DisplayManager.DI SPLAY. Xdm setsthe PATH environment variable for the startup and reset
systemPath scriptsto the value of thisresource. The default for this
resource isspecified at build time by the DefaultSystem-Path
entry in the system configuration file; /etc:/bin:/usr/bin
605
: /usr/X11R6/bin:/usr/ ucb isa common choice. Note the
absence of (.) from thisentry. Thisisa good practice to follow
for root; it avoidsmany common Trojan Horse system
penetration schemes.
DisplayManager.DI SPLAY. Xdm setsthe SHELL environment variable for the startup and
systemShell reset scriptsto the value of thisresource. It is/bin/sh by
default.
DisplayManager.DI SPLAY If the default session failsto execute, xdm will fall back to this
failsafeClient program. Thisprogram isexecuted with no arguments, but
executesusing the same environment variablesasthe session
would have had. (See the subsection Session Program.) By
default, <XRoot>/bin/xterm isused.
DisplayManager.DI SPLAY.grabServer, To improve security, thisgrabsthe server and keyboard while
DisplayManager.DI SPLAY. grabTimeout xdm reading the login name and password. The grabServer resource
specifiesif the server should be held for the duration of the
name/password reading. When false, the server isungrabbed
after the keyboard grab succeeds; otherwise, the server is
grabbed until just before the session begins. The default is
false. The grabTimeout resource specifiesthe maximum time
xdm will wait for the grab to succeed. The grab may fail if some
other client hasthe server grabbed, or possibly if the network
latenciesare very high. Thisresource hasa default value of 3
seconds; you should be cautiouswhen raising it, asa user can
be spoofed by a look-alike window on the display. If the grab
fails, xdm killsand restartsthe server (if possible) and the
session.
DisplayManager.DI SPLAY.authorize, authorize isa Boolean resource that controlswhether xdm
DisplayManager.DI SPLAY.authName generatesand usesauthorization for the local server connec-
tions. If authorization isused, authName isa list of authorization
mechanismsto use, separated by whitespace. XDMCP
connectionsdynamically specify which authorization
mechanismsare supported, so authName isignored in thiscase.
When authorize isset for a display and authorization isnot
available, the user isinformed by having a different message
displayed in the Login widget. By default, authorize istrue.
authName isMIT-MAGIC-COOKIE-1, or, if XDM-AUTHORIZATION-1 is
available, XDM-AUTHORIZATION-1 MIT-MAGIC-COOKIE-1.
DisplayManager.DI SPLAY.authFile Thisfile isused to communicate the authorization data from
xdm to the server, using the auth server command-line option.
It should be kept in a directory that isnot world-writable asit
could easily be removed, disabling the authorization mecha-
nism in the server.
DisplayManager.DI SPLAY. If set to false, disablesthe use of the unsecureGreeting in the
authComplain login window. See the subsection Authentication Widget.
The default istrue.
DisplayManager.DI SPLAY. The number of the signal xdm sendsto reset the server.
resetSignal See the subsection Controlling the Server. The default is1
(SIGHUP).
DisplayManager.DI SPLAY. The number of the signal xdm sendsto terminate the server. See
termSignal the subsection Controlling the Server. The default is15
(SIGTERM).
xdm
Part I: User Commands
606
DisplayManager.DI SPLAY. The original implementation of authorization in the sample
resetForAuth server reread the authorization file at server reset time, instead
of when checking the initial connection. Asxdm generatesthe
authorization information just before connecting to the
display, an old server would not get up-to-date authorization
information. Thisresource causesxdm to send SIGHUP to the
server after setting up the file, causing an additional server reset
to occur, during which time the new authorization information
will be read. The default isfalse, which will work for all MIT
servers.
DisplayManager.DI SPLAY. When xdm isunable to write to the usual user authorization file
userAuthDir ($HOME/.Xauthority), it createsa unique filename in this
directory and pointsthe environment variable XAUTHORITY at
the created file. It uses/tmp by default.
CONFIGURATION FILE
First, the xdm configuration file should be set up. Make a directory (usually <XRoot>/lib/X11/xdm, where <XRoot> refersto the
root of the X11 install tree) to contain all of the relevant files. In the examplesthat follow, /usr/X11R6 isused asthe value of
<XRoot>.
Here isa reasonable configuration file, which could be named xdm-config:
DisplayManager.servers: /usr/X11R6/lib/X11/xdm/Xservers
DisplayManager.errorLogFile: /usr/X11R6/lib/X11/xdm/xdm-errors
DisplayManager*resources: /usr/X11R6/lib/X11/xdm/Xresources
DisplayManager*startup: /usr/X11R6/lib/X11/xdm/Xstartup
DisplayManager*session: /usr/X11R6/lib/X11/xdm/Xsession
DisplayManager.pidFile: /usr/X11R6/lib/X11/xdm/xdm-pid
DisplayManager. 0.authorize: true
DisplayManager*authorize: false
Note that thisfile mostly containsreferencesto other files. Note also that some of the resourcesare specified with *
separating the components. These resourcescan be made unique for each different display, by replacing the * with the
display name, but normally thisisnot very useful. See the Resources section for a complete discussion.
XDMCP ACCESS CONTROL
The database file specified by the DisplayManager.accessFile providesinformation which xdm usesto control accessfrom
displaysrequesting XDMCP service. Thisfile containsthree typesof entries: entriesthat control the response to Direct and
Broadcast queries, entriesthat control the response to Indirect queries, and macro definitions.
The format of the Direct entriesissimple, either a hostname or a pattern, which isdistinguished from a hostname by the
inclusion of one or more metacharacters(* matchesany sequence of 0 or more characters, and ? matchesany single
character) which are compared against the hostname of the display device. If the entry isa hostname, all comparisonsare
done using network addresses, so any name which convertsto the correct network addressmay be used. For patterns, only
canonical hostnamesare used in the comparison, so ensure that you do not attempt to match aliases. Preceding either a
hostname or a pattern with a ! character causeshoststhat match that entry to be excluded.
An Indirect entry also containsa hostname or pattern, but followsit with a list of hostnamesor macrosto which indirect
queriesshould be sent.
A macro definition containsa macro name and a list of hostnamesand other macrosthat the macro expandsto. To
distinguish macrosfrom hostnames, macro namesstart with a % character. Macrosmay be nested.
Indirect entriesmay also specify to have xdm run chooser to offer a menu of hoststo connect to. See the subsection
chooser.
607
When checking accessfor a particular display host, each entry isscanned in turn and the first matching entry determinesthe
response. Direct and Broadcast entriesare ignored when scanning for an Indirect entry and vice versa.
Blank linesare ignored, # istreated asa comment delimiter causing the rest of that line to be ignored, and \newline causesthe
newline to be ignored, allowing indirect host liststo span multiple lines. Here isa sample Xaccess file:
#
# Xaccess XDMCP access control file
#
#
# Direct/Broadcast query entries
#
!xtra.lcs.mit.edu # disallow direct/broadcast service for xtra
bambi.ogi.edu # allow access from this particular display
.lcs.mit.edu # allow access from any display in LCS
#
# Indirect query entries
#
%HOSTS expo.lcs.mit.edu xenon.lcs.mit.edu \
excess.lcs.mit.edu kanga.lcs.mit.edu extract.lcs.mit.edu xenon.lcs.mit.edu #force extract to contact xenon
!xtra.lcs.mit.edu dummy #disallow indirect access
.lcs.mit.edu %HOSTS #all others get to choose
chooser
For X terminalsthat do not offer a host menu for use with Broadcast or Indirect queries, the chooser program can do this
for them. In the Xaccess file, specify CHOOSER asthe first entry in the Indirect host list. chooser will send a Query request to
each of the remaining hostnamesin the list and offer a menu of all the hoststhat respond.
The list may consist of the word BROADCAST, in which case chooser will send a Broadcast instead, again offering a menu of all
hoststhat respond. Note that on some operating systems, UDP packetscannot be broadcast, so thisfeature will not work.
Example Xaccess file using chooser:
extract.lcs.mit.edu CHOOSER %HOSTS #offer a menu of these hosts
xtra.lcs.mit.edu CHOOSER BROADCAST #offer a menu of all hosts
The program to use for chooser isspecified by the DisplayManager.DI SPLAY.chooser resource. For more flexibility at thisstep,
the chooser could be a shell script. chooser isthe session manager here; it isrun instead of a child xdm to manage the display.
Resourcesfor thisprogram can be put into the file named by DisplayManager.DI SPLAY.resources.
When the user selectsa host, chooser printsthe host chosen, which isread by the parent xdm, and exits. xdm closesits
connection to the X server, and the server resetsand sendsanother Indirect XDMCP request. xdm remembersthe users
choice (for DisplayManager. choiceTimeout seconds) and forwardsthe request to the chosen host, which startsa session on that
display.
LOCAL SERVER SPECIFICATION
The resource DisplayManager.servers givesa server specification or, if the valuesstartswith a slash (/), the name of a file
containing server specifications, one per line.
Each specification indicatesa display which should constantly be managed and which isnot using XDMCP. Thismethod is
used typically for local serversonly. If the resource or the file named by the resource isempty, xdm will offer XDMCP service
only.
Each specification consistsof at least three parts: a display name, a display class, a display type, and (for local servers) a
command line to start the server. A typical entry for local display number 0 would be
:0 Digital-QV local /usr/X11R6/bin/X :0
xdm
Part I: User Commands
608
The display typesare
Local local display: xdm must run the server
Foreign remote display: xdm opensan X connection to a running server
The display name must be something that can be passed in the display option to an X program. Thisstring isused to
generate the display-specific resource names, so be careful to match the names(for example, use :0 Sun-CG3 local /usr
/X11R6/bin/X :0 instead of localhost:0 Sun-CG3 local /usr/X11R6/bin/X :0 if your other resourcesare specified as
DisplayManager._0.session). The display classportion isalso used in the display-specific resources, asthe classof the
resource. Thisisuseful if you have a large collection of similar displays(such asa corral of X terminals) and would like to set
resourcesfor groupsof them. When using XDMCP, the display isrequired to specify the display class, so the manual for
your particular X terminal should document the display classstring for your device. If it doesnt, you can run xdm in debug
mode and look at the resource stringsthat it generatesfor that device, which will include the classstring.
When xdm startsa session, it setsup authorization data for the server. For local servers, xdm passesauth filename on the
serverscommand line to point it at itsauthorization data. For XDMCP servers, xdm passesthe authorization data to the
server via the Accept XDMCP request.
RESOURCES FILE
The Xresources file isloaded onto the display asa resource database using xrdb. Asthe authentication widget readsthis
database before starting up, it usually containsparametersfor that widget:
xlogin*login.translations: #override\
Ctrl<Key>R: abort-display()\n\
<Key>F1: set-session-argument(failsafe) finish-field()\n\
<Key>Return: set-session-argument() finish-field()
xlogin*borderWidth: 3
xlogin*greeting: CLIENTHOST
#ifdef COLOR
xlogin*greetColor: CadetBlue
xlogin*failColor: red
#endif
Please note the translationsentry; it specifiesa few new translationsfor the widget that allow usersto escape from the default
session (and avoid troublesthat may occur in it). Note that if #override isnot specified, the default translationsare removed
and replaced by the new value, not a very useful result assome of the default translationsare quite useful (such as<Key>:
insert-char (), which respondsto normal typing).
Thisfile may also contain resourcesfor the setup program and chooser.
SETUP PROGRAM
The Xsetup file isrun after the server isreset, but before the Login window isoffered. The file istypically a shell script. It is
run asroot, so you should be careful about security. Thisisthe place to change the root background or bring up other
windowsthat should appear on the screen along with the Login widget.
In addition to any specified by DisplayManager.exportList, the following environment variablesare passed:
DISPLAY The associated display name
PATH The value of DisplayManager.DI SPLAY.systemPath
SHELL The value of DisplayManager.DI SPLAY.systemShell
XAUTHORITY May be set to an authority file
Note that since xdm grabsthe keyboard, any other windowswill not be able to receive keyboard input. They will be able to
interact with the mouse, however; beware of potential security holeshere. If DisplayManager.DI SPLAY.grabServer isset, Xsetup
will not be able to connect to the display at all. Resourcesfor thisprogram can be put into the file named by
DisplayManager.DI SPLAY.resources.
609
Here isa sample Xsetup script:
#!/bin/sh
# Xsetup 0 setup script for one workstation
xcmsdb </usr/X11R6/lib/monitors/alex.0
xconsole geometry 480x13000 notify verbose exitOnFail &
AUTHENTICATION WIDGET
The authentication widget readsa name/password pair from the keyboard. Nearly every imaginable parameter can be
controlled with a resource. Resourcesfor thiswidget should be put into the file named by DisplayManager.DI SPLAY.resources.
All of these have reasonable default values, so it isnot necessary to specify any of them.
xlogin.Login.width, The geometry of the Login widget isnormally computed
xlogin.Login.height, automatically. If you wish to position it elsewhere, specify each
xlogin.Login.x, of these resources.
xlogin.Login.y
xlogin.Login.foreground The color used to display the typed-in username.
xlogin.Login.font The font used to display the typed-in username.
xlogin.Login.greeting A string which identifiesthiswindow. The default isX Window
System.
xlogin.Login.unsecureGreeting When X authorization isrequested in the configuration file
for thisdisplay and none isin use, thisgreeting replacesthe
standard greeting. The default isThis is an unsecure session.
xlogin.Login.greetFont The font used to display the greeting.
xlogin.Login.greetColor The color used to display the greeting.
xlogin.Login.namePrompt The string displayed to prompt for a username. Xrdb strips
trailing whitespace from resource values, so to add spacesat
the end of the prompt (usually a nice thing), add spaces
escaped with backslashes. The default isLogin:.
xlogin.Login.passwdPrompt The string displayed to prompt for a password. The default is
Password:.
xlogin.Login.promptFont The font used to display both prompts.
xlogin.Login.promptColor The color used to display both prompts.
xlogin.Login.fail A message that isdisplayed when the authentication fails. The
default isLogin incorrect.
xlogin.Login.failFont The font used to display the failure message.
xlogin.Login.failColor The color used to display the failure message.
xlogin.Login.failTimeout The number of secondsthat the failure message isdisplayed.
The default is30.
xlogin.Login.translations Thisspecifiesthe translationsused for the login widget. Refer
to the X Toolkit documentation for a complete discussion on
translations. The default translation table is
Ctrl<Key>H delete-previous-character() \n\
Ctrl<Key>D delete-character() \n\
Ctrl<Key>B move-backward-character() \n\
Ctrl<Key>F move-forward-character() \n\
Ctrl<Key>A move-to-begining() \n\
Ctrl<Key>E move-to-end() \n\
xdm
Part I: User Commands
610
Ctrl<Key>K erase-to-end-of-line() \n\
Ctrl<Key>U erase-line() \n\
Ctrl<Key>X erase-line() \n\
Ctrl<Key>C restart-session() \n\
Ctrl<Key>nn abort-session() \n\
<Key>BackSpace delete-previous-character() \n\
<Key>Delete delete-previous-character() \n\
<Key>Return finish-field() \n\
<Key> insert-char() \
The actionsthat are supported by the widget are
delete-previous-character Erasesthe character before the cursor.
delete-character Erasesthe character after the cursor.
move-backward-character Movesthe cursor backward.
move-forward-character Movesthe cursor forward.
move-to-begining (Apologiesabout the spelling error.) Movesthe cursor to the
beginning of the editable text.
move-to-end Movesthe cursor to the end of the editable text.
erase-to-end-of-line Erasesall text after the cursor.
erase-line Erasesthe entire text.
finish-field If the cursor isin the name field, proceedsto the password field;
if the cursor isin the password field, checksthe current name/
password pair. If the name/password pair isvalid, xdm startsthe
session. Otherwise, the failure message isdisplayed and the
user isprompted again.
abort-session Terminatesand restartsthe server.
abort-display Terminatesthe server, disabling it. Thisaction isnot accessible
in the default configuration. There are variousreasonsto stop
xdm on a system console, such aswhen shutting the system
down, when using xdmshell, to start another type of server, or
to generally accessthe console. Sending xdm a SIGHUP will
restart the display. See the subsection Controlling XDM.
restart-session Resetsthe X server and startsa new session. Thiscan be used
when the resourceshave been changed and you want to test
them or when the screen hasbeen overwritten with system
messages.
insert-char Insertsthe character typed.
set-session-argument Specifiesa single word argument that ispassed to the session at
startup. See the subsection Session Program.
allow-all-access Disablesaccesscontrol in the server. Thiscan be used when
the .Xauthority file cannot be created by xdm. Be very careful
using this; it might be better to disconnect the machine from
the network before doing this.
STARTUP PROGRAM
The Xstartup file istypically a shell script. It isrun asroot and should be very careful about security. Thisisthe place to put
commandsthat add entriesto /etc/utmp (the sessreg program may be useful here), mount users home directoriesfrom file
servers, display the message of the day, or abort the session if loginsare not allowed.
611
In addition to any specified by DisplayManager.exportList, the following environment variablesare passed:
DISPLAY The associated display name
HOME The initial working directory of the user
USER The username
PATH The value of DisplayManager.DI SPLAY.systemPath
SHELL The value of DisplayManager.DI SPLAY.systemShell
XAUTHORITY May be set to an authority file
No argumentsare passed to the script. xdm waitsuntil thisscript exitsbefore starting the user session. If the exit value of this
script isnon-zero, xdm discontinuesthe session and startsanother authentication cycle.
The sample Xstartup file shown here preventslogin while the file /etc/nologin exists. Thus, thisisnot a complete example,
but simply a demonstration of the available functionality.
Here isa sample Xstartup script:
#!/bin/sh
#
# Xstartup
#
# This program is run as root after the user is verified
#
if [ f /etc/nologin ]; then
xmessage file /etc/nologin
exit 1
fi
sessreg a l $DISPLAY x /usr/X11R6/lib/xdm/Xservers $USER
/usr/X11R6/lib/xdm/GiveConsole
exit 0
SESSION PROGRAM
The Xsession program isthe command that isrun asthe userssession. It isrun with the permissionsof the authorized user.
In addition to any specified by DisplayManager.exportList, the following environment variablesare passed:
DISPLAY The associated display name
HOME The initial working directory of the user
USER The username
PATH The value of DisplayManager.DI SPLAY.userPath
SHELL The usersdefault shell (from getpwnam)
AUTHORITY May be set to a nonstandard authority file
KRB5CCNAME May be set to a Kerberoscredentialscache file
At most installations, Xsession should look in $HOME for a file xsession, which containscommandsthat each user would like
to use asa session. Xsession should also implement a system default session if no user-specified session exists. See the
subsection Typical Usage.
An argument may be passed to thisprogram from the authentication widget using the set-session-argument action. Thiscan
be used to select different stylesof session. One good use of thisfeature isto allow the user to escape from the ordinary
session when it fails. Thisallowsusersto repair their own .xsession if it fails, without requiring administrative intervention.
The example following demonstratesthisfeature.
Thisexample recognizesthe special failsafe mode, specified in the translationsin the Xresources file, to provide an escape
from the ordinary session. It also requiresthat the .xsession file be executable so you dont have to guesswhat shell it wants
to use.
xdm
Part I: User Commands
612
#!/bin/sh
#
# Xsession
#
# This is the program that is run as the client
# for the display manager.
case $# in
1)
case $1 in
failsafe)
exec xterm geometry 80x2400
;;
esac
esac
startup=$HOME/.xsession
resources=$HOME/.Xresources
if [ f $startup ]; then
exec $startup
else
if [ f $resources ]; then
xrdb load $resources
fi
twm &
xman geometry +1010 &
exec xterm geometry 80x24+10+10 ls
fi
The users.xsession file might look something like the following example. Dont forget that the file must have execute
permission.
#!/bin/csh
# no f in the previous line so .cshrc gets run to set $PATH
twm &
xrdb merge $HOME/.Xresources
emacs geometry +0+50 &
xbiff geometry 430+5 &
xterm geometry 0+50 -ls
RESET PROGRAM
Symmetrical with Xstartup, the Xreset script isrun after the user session hasterminated. Run asroot, it should contain
commandsthat undo the effectsof commandsin Xstartup, removing entriesfrom /etc/utmp or unmounting directoriesfrom
file servers. The environment variablesthat were passed to Xstartup are also passed to Xreset.
A sample Xreset script:
#!/bin/sh
#
# Xreset
#
# This program is run as root after the session ends
#
sessreg d l $DISPLAY x /usr/X11R6/lib/xdm/Xservers $USER
/usr/X11R6/lib/xdm/TakeConsole
exit 0
CONTROLLING THE SERVER
xdm controlslocal serversusing POSIX signals. SIGHUP isexpected to reset the server, closing all client connectionsand
performing other cleanup duties. SIGTERM isexpected to terminate the server. If these signalsdo not perform the expected
actions, the resourcesDisplayManager.DISPLAY.resetSignal and DisplayManager.DISPLAY.termSignal can specify alternate
signals.
613
To control remote terminalsnot using XDMCP, xdm searchesthe window hierarchy on the display and usesthe protocol
request KillClient in an attempt to clean up the terminal for the next session. Thismay not actually kill all of the clients, as
only those which have created windowswill be noticed. XDMCP providesa more sure mechanism; when xdm closesitsinitial
connection, the session isover and the terminal isrequired to close all other connections.
CONTROLLING xdm
xdm respondsto two signals: SIGHUP and SIGTERM. When sent a SIGHUP, xdm rereadsthe configuration file, the accesscontrol file,
and the serversfile. For the serversfile, it noticesif entrieshave been added or removed. If a new entry hasbeen added, xdm
startsa session on the associated display. Entriesthat have been removed are disabled immediately, meaning that any session
in progresswill be terminated without notice and no new session will be started.
When sent a SIGTERM, xdm terminatesall sessionsin progressand exits. Thiscan be used when shutting down the system.
xdm attemptsto mark itsvarioussubprocessesfor ps(1) by editing the command-line argument list in place. Because xdm cant
allocate additional space for thistask, it isuseful to start xdm with a reasonably long command line (using the full pathname
should be enough). Each processwhich isservicing a display ismarked display.
OTHER POSSIBILITIES
You can use xdm to run a single session at a time, using the 4.3 init optionsor other suitable daemon by specifying the server
on the command line:
xdm server :0 SUN-3/60CG4 local /usr/X11R6/bin/X :0
Or you might have a file server and a collection of X terminals. The configuration for thisisidentical to that of the preceding
sample, except the Xservers file would look like this:
extol:0 VISUAL-19 foreign
exalt:0 NCD-19 foreign
explode:0 NCR-TOWERVIEW3000 foreign
Thisdirectsxdm to manage sessionson all three of these terminals. See the subsection Controlling xdm for a description of
using signalsto enable and disable these terminalsin a manner reminiscent of init(8).
LIMITATIONS
One thing that xdm isnt very good at doing iscoexisting with other window systems. To use multiple window systemson the
same hardware, youll probably be more interested in xinit.
FILES
<XRoot>/lib/X11/xdm/xdm-config The default configuration file
$HOME/.Xauthority User authorization file where xdm storeskeysfor clientsto read
<XRoot>/lib/X11/xdm/chooser The default chooser
<XRoot>/bin/X11/xrdb The default resource database loader
<XRoot>/bin/X11/X The default server
<XRoot>/bin/X11/xterm The default session program and failsafe client
<XRoot>/lib/X11/xdm/A<display><suffix> The default place for authorization files
/tmp/K5C<display> Kerberos Credentialscache
Note: <XRoot> refers to the root of the X11 install tree.
See Also
X(1), xinit(1), xauth(1), Xsecurity(1), sessreg(1), Xserver(1)
X Display Manager Control Protocol
xdm
Part I: User Commands
614
AUTHOR
Keith Packard (MIT X Consortium)
X Version 11 Release6
xdpyinfo
xdpyinfoDisplay information utility for X
SYNOPSIS
xdpyinfo [display di spl ayname] [queryExtensions] [ext ext ensi on- name]
DESCRIPTION
xdpyinfo isa utility for displaying information about an X server. It isused to examine the capabilitiesof a server, the
predefined valuesfor variousparametersused in communicating between clientsand the server, and the different typesof
screensand visualsthat are available.
By default, numeric information (opcode, base event, base error) about protocol extensionsisnot displayed. Thisinforma-
tion can be obtained with the queryExtensions option. Use of thisoption on serversthat dynamically load extensionswill
likely cause all possible extensionsto be loaded, which can be slow and can consume significant server resources.
Detailed information about a particular extension isdisplayed with the ext extensionName option. If extensionName isall,
information about all extensionssupported by both xdpy-info and the server isdisplayed.
ENVIRONMENT
DISPLAY To get the default host, display number, and screen
SEE ALSO
X(1), xwininfo(1), xprop(1), xrdb(1)
AUTHOR
Jim Fulton (MIT X Consortium)
X Version 11 Release6
Xf86_Accel
XF86_AccelAccelerated X Window System serversfor UNIX on x86 platformswith an S3, Mach8, Mach32, Mach64,
P9000, AGX, ET4000/W32, or 8514/A accelerator board
SYNOPSIS
XF86_S3 [:displaynumber] [ option ] ...
XF86_Mach8 [:displaynumber] [ option ] ...
XF86_Mach32 [:displaynumber] [ option ] ...
XF86_Mach64 [:displaynumber] [ option ] ...
XF86_P9000 [:displaynumber] [ option ] ...
XF86_AGX [:displaynumber] [ option ] ...
XF86_W32 [:displaynumber] [ option ] ...
XF86_8514 [:displaynumber] [ option ] ...
615
DESCRIPTION
XF86_S3 isan 8-bit PseudoColor, 16-bit TrueColor and 24-bit TrueColor server for S3 graphic accelerator boards. Note, 16-
bit and 24-bit operation isnot supported on all S3 accelerator boards. Refer to README.S3 for detailsof which boardsare
supported at which depths.
XF86_Mach8 isan 8-bit PseudoColor server for ATI Mach8 graphic accelerator boards.
XF86_Mach32 isan 8-bit PseudoColor and 16-bit TrueColor server for ATI Mach32 graphic accelerator boards. Note, 16-bit
operation isnot supported on all Mach32 accelerator boards.
XF86_Mach64 isan 8-bit PseudoColor, 16-bit TrueColor, and 24-bit TrueColor server for ATI Mach64 graphic accelerator
boards. Note, 16-bit and 24-bit operation isnot supported for all RAMDACs. Refer to README.Mach64 for detailsof which
RAMDACsare supported at which depths.
XF86_P9000 isan 8-bit PseudoColor, 16-bit TrueColor, and 24-bit TrueColor server for Weitek Power 9000 (P9000) graphic
accelerator boards.
XF86_AGX isan 8-bit PseudoColor and 16-bit TrueColor server for AGX/XGA graphic accelerator boards.
XF86_W32 isan 8-bit PseudoColor server for ET4000/W32, ET4000/W32i, and ET4000/W32p graphic accelerator boards.
XF86_8514 isan 8-bit PseudoColor server for 8514/A graphic accelerator boards.
These are derived from the X386 server provided with X11R5, and from the X8514 server developed by Kevin Martin
(<martin@cs.unc.edu>).
CONFIGURATIONS
The serverssupport the following chipsets:
XF86_S3 86C911, 86C924, 86C801, 86C805, 86C805i, 86C928, 86C928- P,
86C732 (Trio32), 86C764 (Trio64), 86C864, 86C868, 86C964, 86C968
XF86_Mach8 ATI Mach8, ATI Mach32
XF86_Mach32 ATI Mach32
XF86_Mach64 ATI Mach64
XF86_P9000 Diamond Viper VLB, Diamond Viper PCI, Orchid P9000, and
some clones(Weitek P9000)
XF86_AGX AGX-010, AGX-014, AGX-015, AGX-016, XGA-1, XGA-2
XF86_W32 ET4000/W32, ET4000/W32i, ET3000/W32p
XF86_8514 IBM 8514/A and true clones
For S3, virtual resolutionsup to (approximately) 1,152800 are supported, using (up to) 1MB of display memory (the S3
usesan internal width of 1,280 except for new revisionsof some of the chips, hence 1MB cant support 1,152900). Physical
resolutionsup to 1,2801,024 (1,6001,280 on some cards) are possible using 2MB or more of display memory. (Virtual
resolution isdependent solely on the amount of memory installed, with the maximum virtual width being 2,048, and
maximum virtual height is4,096.)
Similar resolutionsare supported on the Mach64. Refer to README.Mach64 for configuration details.
Similar resolutionsare supported on the Mach32. For the Mach32, the maximum virtual width is1,536, and the maximum
virtual height is1,280.
For Mach8, the maximum virtual width is1,024.
For 8514, the maximum resolution is1,024768.
For the AGX chips, maximum resolution dependsupon the chip revision and amount of available display memory. Refer to
README.agx for configuration details.
xf86_Accel
Part I: User Commands
616
For the P9000, the virtual and physical resolutionsmust be the same. With sufficient memory, resolutionsup to
1,2801,024 are supported.
All the serversthat support 24-bit visualsdo so using a 32-bit per pixel configuration where 8 bitsin every 32 bitsisunused.
Thisneedsto be taken into account when calculating the maximum virtual display size that can be supported at thisdepth.
OPTIONS
In addition to the normal server optionsdescribed in the Xserver(1) manual page, these serversaccept some more command-
line switches, asdescribed in the XFree86(1) man page.
The Mach64, Mach32, S3, P9000, and AGX serversnow support more than 8-bit color. The Mach32 and AGX servers
support 16-bit TrueColor and the Mach64, S3, and P9000 serverssupport 16-and 32-bit TrueColor. The 32-bit TrueColor
mode only uses24 bitsper pixel for color information (giving you 16 million colors). These modesmay be used by
specifying the bpp option asspecified in the XFree86(1) man page.
SETUP
XFree86 usesa configuration file called XF86Config for itsinitial setup.
See the XF86Config(4/5) man page for general details. Here only the partsspecific to the XF86_S3, XF86_Mach8, XF86_Mach32,
XF86_Mach64, XF86_P9000, XF86_AGX, XF86_W32, and XF86_8514 serversare explained.
Entriesfor the Device section in the XF86Config file include the following:
Chipset name Specifiesa chipset so the correct driver can be used. Possible
chipsetsare
XF86_S3
S3_generic: (for a standard IO-driven server)
Mmio_928: (for a memory-mapped IO-driven server on
86C928, 86C732, 86C764, 86C864, 86C868, 86C964, and
86C968 boards)
XF86_Mach8, Mach8 (to force the Mach8 server to run on
Mach32 boards)
XF86_Mach32, Mach32
XF86_Mach64, Mach64
XF86_P9000
Vipervlb (for the Diamond Viper VLB)
Viperpci (for the Diamond Viper PCI)
Orchidp9000 (for the Orchid P9000 and many
generic P9000-based boards)
XF86_AGX
Agx-016
Agx-015
Agx-014
Agx-010
Xga-2
Xga-1
NOTE
Only the agx-016, agx-015, agx-014, and XGA-2 have been tested. Refer to the XGA and AGX-010 section of README.agx before
attempting to use the other chipsets.
617
XF86 W32
Et4000w32
Et4000w32i
Et4000w32i_rev_b
Et4000w32i_rev_c
Et4000w32p_rev_a
Et4000w32p_rev_b
Et4000w32p_rev_c
Et4000w32p_rev_d
XF86_8514
Ibm8514
Clocks cl ock ... For boardswith nonprogrammable clock chips, the clockscan
be specified here (see XF86Config(4/5)). The P9000 server now
no longer requiresa Clocks line. It will now work the same
way asother serverswith a programmable clock chip (that is,
use the clocksasspecified in the Modes). Note, clocksover
110 MHz are not recommended or supported by the P9000
server. The Mach64 server also doesnot require a Clocks line
because the clocksare normally read directly from the video
cardsBIOS. For the Mach64 server, the clocksgiven in the
XF86Config file are ignored unlessthe no_bios_clocks option is
given (see below).
ClockChip cl ockchi p- t ype For boardswith programmable clock chips(except with the
P9000 and AGX servers), the name of the clock chip isgiven.
Possible valuesfor the S3 server include icd2061a,
ics9161a, dcs2834, sc11412, s3gendac, s3 sdac,
ti3025, ti3026, ics2595, ics5300, ics5342, ch8391,
stg1703, and ibm_rgb5xx.
Ramdac r amdac- t ype Thisspecifiesthe type of RAMDAC used on the board. Only
the S3, AGX, and W32 serversuse this.
Normal(S3, AGX) Card doesnot have one of the other
RAMDACsmentioned here. Thisoption isonly required for
the S3 server if the server incorrectly detectsone of those other
RAMDACs. The AGX server doesnot yet auto-detect
RAMDACs, thisisthe default if no RAMDAC isspecified.
Generic(W32) Thisforcesthe W32 server to treat the
RAMDAC asa generic VGA RAMDAC.
Att20c490(S3, AGX) Card hasan AT&T 20C490 or AT&T
20C491 RAMDAC. When the dac_8_bit option isspecified,
these RAMDACsmay be operated in 8-bit per RGB mode. It
also allows16bpp operation with 801/805/928 boards. True
AT&T 20C490 RAMDACsshould be autodetected by the S3
server. ThisRAMDAC must be specified explicitly in other
cases. Note that 8-bit per RGB mode doesnot appear to work
with the Winbond 82C490 RAMDACs(which SuperProbe
identifiesasAT&T 20C492). 16bpp worksfine with the
Winbond 82C490. The Diamond SS2410 RAMDAC is
reported to be compatible when operating in 15bpp mode
(not 16bpp). The Chrontel 8391 appearsto be compatible in
all modes.
xf86_Accel
Part I: User Commands
618
Sc15025(S3, AGX) Card hasa Sierra SC15025 or SC15026
RAMDAC. The S3 server hascode to autodetect this
RAMDAC.
Sc11482(S3) Card hasa Sierra SC11482, SC11483, or
SC11484 RAMDAC. The S3 server hascode to autodetect
thisRAMDAC.
Sc11485(S3) Card hasa Sierra SC11485, SC11487 or
SC11489 RAMDAC. The S3 server will detect these
RAMDACsasan sc11482, so thisoption must be specified to
take advantage of extra features(they support 16bpp, 15bpp,
and 8bpp, while the othersonly support 15bpp and 8bpp).
Bt485(S3) Card hasa BrookTree Bt485 or Bt9485
RAMDAC. Thismust be specified if the server failsto detect it.
Att20c505(S3) Card hasan AT&T 20C505 RAMDAC.
Thismust be specified either if the server failsto detect the
20C505, or if the card hasa Bt485 RAMDAC and there are
problemsusing clockshigher than 67.5MHz.
Att20c498(S3) Card hasan AT&T 20C498 or 21C498
RAMDAC. Thismust be specified if the server failsto detect it.
Att22c498(S3) Card hasan AT&T 22C498 RAMDAC.
Thismust be specified if the server failsto detect it.
Ibm_rgb514(S3) Card hasan IBM RGB514 RAMDAC. This
must be specified if the server failsto detect it.
Ibm_rgb524(S3) Card hasan IBM RGB524 RAMDAC. This
must be specified if the server failsto detect it.
Ibm_rgb525(S3) Card hasan IBM RGB525 RAMDAC. This
must be specified if the server failsto detect it.
Ibm_rgb528(S3) Card hasan IBM RGB528 RAMDAC. This
must be specified if the server failsto detect it.
Stg1700(S3) Card has an STG1700 RAMDAC. Thismust be
specified if the server failsto detect it.
Stg1703(S3) Card has an STG1703 RAMDAC. Thismust be
specified if the server failsto detect it.
S3gendac(S3) Card hasan S3 86C708 GENDAC. This
RAMDAC doesnot support 8-bit per RGB mode (dont
specify the dac_8_bit option). It allows16bpp operation with
801/805 boards. There iscurrently no autodetection for this
RAMDAC.
S3_sdac(S3) Card hasan S3 86C716 SDAC RAMDAC.
Thismust be specified if the server failsto detect it.
Ics5300(S3) Card hasan ICS5300 RAMDAC. Thismust be
specified if the server failsto detect it (the server will recognize
thisasan S3 GENDAC which isOK).
Ics5342(S3) Card hasan ICS5342 RAMDAC. Thismust be
specified if the server failsto detect it (the server will recognize
thisasan S3 SDAC which isOK).
Ti3020(S3) Card hasa TI ViewPoint Ti3020 RAMDAC.
Thismust be specified if the server failsto detect the Ti3020.
Note that pixel multiplexing will be used for thisRAMDAC if
any mode requiresa dot clock higher than 70MHz.
619
Ti3025(S3) Card hasa TI ViewPoint Ti3025 RAMDAC.
Thismust be specified if the server failsto detect the Ti3025.
Ti3026(S3) Card hasa TI ViewPoint Ti3026 RAMDAC.
Thismust be specified if the server failsto detect the Ti3026.
Bt481(AGX) Card hasa BrookTree Bt481 RAMDAC.
Bt482(AGX) Card hasa BrookTree Bt482 RAMDAC.
Herc_dual_dac(AGX) Card (HerculesGraphite Pro) has
both the 84-pin (Bt485 or AT&T20C505) and 44-pin (Bt481
or Bt482) RAMDACsinstalled.
Herc_small_dac(AGX) Card (HerculesGraphite Pro) has
only the 44-pin (Bt481 or Bt482) RAMDAC installed.
IOBase i oaddr ess Specifiesthe base addressfor extended IO registers. Thisis
only used by the AGX server, and by the P9000 server for the
Viper PCI. For detailsof how to use it, refer to README.agx and
README.P9000.
MemBase memaddr ess Specifiesthe hard-wired part of the linear framebuffer base
address. Thisoption isonly used by the P9000, S3, Mach64,
and Mach32 servers(and only when using a linear
framebuffer). For the S3 server, the hard-wired part isthe high
10 bitsof the 32-bit address(that is, memaddr ess ismasked with
0xFFC00000). Note: Thisshould not be required for the 864
and 964 chipswhere the entire framebuffer addressissoftware-
selectable. Also, note that in versionsprior to 3.1.1, the S3
server used only the top 6 bitsof memaddr ess, and ORed it with
0x3C00000. To get the same behavior, OR 0x3C00000 with the
value given previously. For the Mach32 server, the mask is
0xF8000000 (except for PCI cards, where the membase setting is
ignored).
Thisoption must be specified with the P9000 server. With
local busDiamond Vipersthe value of memaddr ess can be
either 0x80000000, 0x20000000, or 0xA0000000. The default is
0x80000000. Any value should work aslong asit doesnot
conflict with another device already at that address. For the
Viper PCI, refer to README.P9000. For the Orchid P9000, the
base addressmay be 0xC0000000, 0xD0000000, or 0xE0000000,
and must correspond the boardsjumper setting. Note: The S3
server will normally probe for thisaddressautomatically.
Setting thisoption overridesthat probe. Thisisnot normally
recommended because the failure of the serversprobe usually
indicatesproblemsin using the linear framebuffer.
NOTE
The Mach64 server requiresthe memory aperture. For ISA busvideo cards, thismeansthat the aperture must be enabled
and the aperture addressmust be set to a value lessthan 16MB (which meansthat, on ISA systemsonly, to use the Mach64
server you must have 12MB of main memory or less). Normally the Mach64 server will use predefined valuesfor this
address, but setting thisoption will override the predefined address.
The Mach32 server should not require the use of thisoption under normal circumstances.
xf86_Accel
Part I: User Commands
620
COPBase baseaddr ess Thissetsthe coprocessor base addressfor the AGX server.
Refer to README.agx for details.
Instance i nst ance Thissetsthe XGA instance number for the AGX server. Refer
to README.agx for details.
S3MClk memcl k Thisallowsthe video cardsmemory clock value to be
specified. Thisisonly used for 805i, 864 and Trio32/64 cards,
and the value should not normally be given here for cardswith
an S3 Gendac or Trio64. Thisentry doesnt change the cards
memory clock, but it isused to calculate the DRAM timing
parameters. For further detailsrefer to README.S3.
S3MNAdjust M N Thisallowssome memory timing parametersto be adjusted
for DRAM cards. For further detailsrefer to README.S3.
S3RefClk r ef cl k Thisallowsthe PLL reference clock to be specified. Thismay
be required for some cardsthat use the IBM RGB5xx
RAMDACs. The value isin MHz. For further detailsrefer to
README.S3.
Option flagsmay be specified in either the Device section or the Display subsection of the XF86Config file.
Option opt i onst r i ng Allowsthe user to select certain optionsprovided by the
drivers. Currently the following stringsare recognized:
Nomemaccess(S3) Disable direct accessto video memory.
Thisoption isignored for the 864 and 964 chips.
Noaccel(AGX, P9000) Disable hardware acceleration for the
P9000, and disablesthe font cache with the AGX.
Vram_128(AGX, P9000) When memory probe fails, use if
you have 128Kx8 VRAMs.
Vram_256(AGX, P9000) When memory probe fails, use if
you dont have 128Kx8 VRAMs.
Nolinear(S3 and Mach32) Disable use of a linear-mapped
framebuffer.
Ti3020_curs(S3) Enablesthe Ti3020sinternal HW cursor.
(Default)
No_ti3020_curs(S3) Disablesthe Ti3020sinternal HW
cursor.
Sw_cursor(S3, Mach32, Mach64, P9000, AGX) Disable the
hardware cursor.
Dac_8_bit(S3, Mach32, Mach64, AGX) Enables8-bit per
RGB. Currently only supported with the Ti3020/5/6, Bt485,
AT&T20C505, AT&T20C490/1, Sierra SC15025/6, AT&T20C498 and
STG1700/3, IBM RGB5xx (S3 server), Bt481 and Bt482 (AGX
server), ATI68875/TLC34075/Bt885 (Mach32 server), ATI68875,
TLC34075, ATI68860, ATI68880, STG1702, and STG1703 (Mach64
server) RAMDACs. Thisisnow set by default in the S3 server
when one of the preceding RAMDACsother than the
AT&T20C490/1 isused.
Dac_6_bit(S3) Force 6-bit per RGB in caseswhere 8-bit
mode would automatically be enabled.
Sync_on_green(S3, P9000) Enablesgeneration of sync on the
green signal on cardswith Bt485, AT&T20C505, Ti3020/5/6 or
IBMRGB5xx RAMDACs. Note: Although these RAMDACs
support sync_on_green, it wont work on many cardsbecause
of the way they are designed.
621
Power_saver(S3 and Mach64) Thisoption enablesthe server
to use the power-saving featuresof VESA DPMS-compatible
monitors. The suspend level iscurrently only supported for the
Mach64 and for the 732, 764, 864, 868, 964, 968 S3 chips. Refer
to the XF86Config(4/5) manual page for detailsof how to set
the time-outsfor the different levelsof operation. Thisoption
isexperimental.
intel_gx(Mach32) Setsthe hard-wired offset for the linear
framebuffer correctly for the Intel GX Pro cards. Thisoption
isequivalent to setting the membase to 0x78000000.
spea_mercury(S3) Enablespixel multiplex support for SPEA
Mercury cards(928 + Bt485 RAMDAC). For these cards, pixel
multiplexing isrequired in order to use dot clockshigher than
67.5 MHz and to accessmore than 1MB of video memory.
Pixel multiplexing iscurrently supported only for
noninterlaced modes, and modeswith a physical width no
smaller than 1,024.
stb_pegasus(S3) Enablespixel multiplex support for STB
Pegasuscards(928 + Bt485 RAMDAC). For these cards, pixel
multiplexing isrequired in order to use dot clockshigher than
67.5 MHz. Pixel multiplexing iscurrently supported only for
noninterlaced modes, and modeswith a physical width no
smaller than 1,024.
number_nine(S3) Enablespixel multiplex support for
Number Nine GXe level 10, 11, 12 cards(928 + Bt485
RAMDAC). For these cards, pixel multiplexing isrequired in
order to use dot clockshigher than 85MHz. Pixel multiplexing
iscurrently supported only for noninterlaced modes, and
modeswith a physical width no smaller than 800. Thisoption
isalso required for some other Number Nine cards(for
example, GXE64 and GXE64pro).
diamond(S3) Thisoption may be required for some
Diamond cards(in particular, the 964/968 VRAM cards).
elsa_w1000pro(S3) Enablessupport for the ELSA Winner
1000 PRO. Thisoption isnot usually required because the
board can be autodetected.
elsa_w1000isa(S3) Enablessupport for the ELSA Winner
1000 ISA. Thisoption isnot usually required because the
board can be autodetected.
elsa_w2000pro(S3) Enablessupport for the ELSA Winner
2000 PRO. Thisoption isnot usually required because the
board can be autodetected.
pci_hack(S3) Enablesa workaround for problemsseen with
some PCI 928 cardson machineswith a buggy SMC UART.
s3_964_bt485_vclk(S3) Enablesa workaround for possible
problemson cardsusing the 964 and Bt485.
genoa, stb, hercules, or number_nine,(S3) These optionsmay
be used to select different defaultsfor the blank delay settings
for untested cardswith IBM RGB5xx RAMDACsto avoid
pixel-wrapping problems.
xf86_Accel
Part I: User Commands
622
slow_vram(S3) Adjuststhe VRAM timingsfor cardsusing
slow VRAM. Thisisrequired for some Diamond Stealth 64
VRAM and HerculesTerminator 64 cards.
Fast_vram(S3) Adjuststhe VRAM timingsfor faster VRAM
access. There will be display errorsand pixel garbage if your
card cant support it.
Slow_dram_refresh(S3) Adjuststhe DRAM refresh for cards
with slow DRAM to avoid linesof corrupted pixelswhen
switching modes.
No_block_write(Mach64) Disablesthe block write mode on
certain typesof VRAM Mach64 cards. If noise or shadows
appear on the screen, thisoption should remove them.
Block_write(Mach64) Enablesthe block write mode on
certain typesof VRAM Mach64 cards. Normally the Mach64
server will automatically determine if the card can handle
block write mode, but thisoption will override the probe
result.
No_bios_clocks(Mach64) The Mach64 server normally
readsthe clocksfrom the bios. Thisoption overridesthe bios
clocksand forcesthe server to use the clocksgiven in the
XF86Config file.
There are also numeroustuning optionsfor the AGX server.
Refer to README.agx for details.
Note that XFree86 hassome internal capabilitiesto determine what hardware it isrunning on. Thus, normally the keywords
chipset, clocks, and videoram dont have to be specified. But there may be occasionswhen thisautodetection mechanism
fails, (for example, too high a load on the machine when you start the server). For caseslike this, one should first run the
server on an unloaded machine, look at the resultsof the autodetection (that are printed out during server startup), and then
explicitly specify these parametersin the configuration file. It isrecommended that all parameters, especially Clock values, be
specified in the XF86Config file.
FILES
<XRoot>/bin/XF86 S3 The 8-, 16-, and 24-bit color X server for S3
<XRoot>/bin/XF86 Mach8 The 8-bit color X server for Mach8
<XRoot>/bin/XF86 Mach32 The 8- and 16-bit color X server for Mach32
<XRoot>/bin/XF86 Mach64 The 8-, 16-, and 24-bit color X server for Mach64
<XRoot>/bin/XF86 P9000 The 8-, 16-, and 24-bit color X server for the P9000
<XRoot>/bin/XF86 AGX The 8- and 16-bit color X server for AGX and XGA
<XRoot>/bin/XF86 W32 The 8-bit color X server for ET4000/W32
<XRoot>/bin/XF86 8514 The 8-bit color X server for IBM 8514 and true compatibles
/etc/XF86Config Server configuration file
<XRoot>/lib/X11/XF86Config Server configuration file (secondary location)
<XRoot>/lib/X11/doc/README.agx Extra documentation for the AGX server
<XRoot>/lib/X11/doc/README.P9000 Extra documentation for the P9000 server
<XRoot>/lib/X11/doc/README.S3 Extra documentation for the S3 server
<XRoot>/lib/X11/doc/README.W32 Extra documentation for the W32 server
Note: <XRoot> refersto the root of the X11 install tree.
623
SEE ALSO
X(1), Xserver(1), XFree86(1), XF86Config(4/5), xvidtune(1), xdm(1), xf86config(1), xinit(1)
AUTHORS
In addition to the authorsof XFree86 the following people contributed major work to thisserver: Kevin Martin
(martin@cs.unc.edu), Jon Tombs(tombs@XFree86.org), Rik Faith (faith@cs.unc.edu). (Did the overall work on the base
accelerated servers.)
David Dawes(dawes@XFree86.org), Dirk Hohndel (hohndel@XFree86.org), David Wexelblat (dwex@XFree86.org). (Merged
their work into XFree86.)
Jon Tombs(tombs@XFree86.org), David Wexelblat (dwex@XFree86.org), David Dawes(dawes@XFree86.org), Amancio Hasty
(hasty@netcom.com), Robin Cutshaw (robin@XFree86.org), Norbert Distler (Norbert.Distler@physik.tu-muenchen.de), Leonard
N. Zubkoff (lnz@dandelion.com), Harald Koenig (koenig@tat.physik.uni-tuebingen.de), Bernhard Bender
(br@elsa.mhs.compuserve.com), HansNasten (nasten@everyware.se). (Development and improvement of the S3-specific code.)
Kevin Martin (martin@cs.unc.edu), Rik Faith (faith@cs.unc.edu), Tiago Gons(tiago@comosjn.hobby.nl), HansNasten
(nasten@everyware.se), Scott Laird (lair@midway.uchicago.edu). (Development and improvement of the Mach8- and 8514/A-
specific code.)
Kevin Martin (martin@cs.unc.edu), Rik Faith (faith@cs.unc.edu), Mike Bernson (mike@mbsun.mlb.org), Mark Weaver
(MarkWeaver@brown.edu), Craig Groeschel (craig@metrolink.com). (Development and improvement of the Mach32-specific code.
Kevin Martin, (martin@cs.unc.edu). (Development of the Mach64-specific code.)
Erik Nygren (nygren@mit.edu), Harry Langenbacher (harry@brain.jpl.nasa.gov), ChrisMason
(clmtch@osfmail.isc.rit.edu), Henrik Harmsen (harmsen@eritel.se). (Development and improvement of the P9000-specific
code.)
Henry Worth (henry.worth@amail.amdahl.com). (Development of the AGX specific code.)
Glenn Lai (glenn@cs.utexas.edu). (Development of the ET4000/W32-specific code.)
See also the XFree86(1) manual page.
BUGS
Some S3 cardswith Bt485 RAMDACsare currently restricted to dot-clockslessthan 85MHz.
The P9000 server may still have problemswith cardsother than the Diamond Viper VLB. There may still be problemswith
VGA mode restoration, but these should almost never occur. Using physical resolutionsdifferent from the virtual resolution
isnot supported and isnot possible with the P9000. Use at dot-clocksgreater than 110MHz isnot recommended and not
supported. Diamond claimsthat 135MHz isthe maximum clock speed, but some of itsbt485sare not rated that high. If you
do not have a 135MHz bt485 on your Viper, contact Diamond tech support and they will send you an RMA number to
replace the board. Acceleration isbeing added in slowly. At the present, only CopyArea, MoveWindow, and DrawLine are
implemented. Other accelerated featuresare being tested and may be available in the next release. There seemsto be a
problem with olvwm when used with xdm and VT switching. The cursor will be messed up when you return to a VT if the cursor
changed while you were in the VT.
CONTACT INFO
XFree86 source isavailable from the FTP server ftp.XFree86.Org and mirrors. Send e-mail to XFree86@XFree86.Org for details.
XFree86 Version 3.1.2
xf86_Accel
Part I: User Commands
624
XF86_Mono
XF86_Mono1-bit nonaccelerated X Window System serversfor UNIX on x86 platforms
SYNOPSIS
XF86 Mono [:displaynumber] [ option ] ...
DESCRIPTION
XF86_Mono isa 1-bit StaticGrey server for VGA and Super VGA cardsand for some other monochrome cards.
CONFIGURATIONS
The XF86_Mono server supportsthe following popular Super VGA chipsetsin monochrome mode:
ATI 18800, 18800-1, 28800-2, 28800-4, 28800-5, 28800-6, 68800-3,
68800-6, 68800AX, 68800LX, 88800CX, 88800GX
Tseng ET3000, ET4000, ET4000/W32
Western Digital PVGA1, WD90C00, WD90C10, WD90C11, WD90C30, WD90C31, WD90C33
Genoa GVGA
Trident TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000
NCR 77C22, 77C22E
Compaq AVGA
Oak OTI067, OTI077, OTI087
Cirrus CLGD5420, CLGD5422, CLGD5424, CLGD5426, CLGD5428, CLGD5429,
CLGD5430, CLGD5434, CLGD5436, CLGD6205, CLGD6215, CLGD6225,
CLGD6235, CL6410, CL6412, CL6420, CL6440
The XF86_Mono server supportsthe following monochrome cardsand resolutions:
Sigma L-View, LaserView PLUS (in 1bpp mode): 1,6641,280
Hyundai HGC-1280: 1,280[1,472]1,024
Apollo Monochrome card (with ID 9) from Apollo workstations:
1,2801,024
Herculesand compatiblescards 720348
Additionally, it supportsgeneric VGA cardswith a maximum virtual resolution of (approximately) 800650.
On supported SVGA chipsets, XF86_Mono will use up to
1
/4 of display memory, which yieldsa maximum virtual resolution of
(approximately) 1,6641,260 with 1MB of display memory. XF86_Mono doesnot support the accelerated functionsof the
supported chipsets.
OPTIONS
In addition to the normal server optionsdescribed in the Xserver(1) manual page, XF86_Mono acceptssome more command-
line switches, asdescribed in the XFree86(1) man page.
SETUP
XFree86 usesa configuration file called XF86Config for itsinitial setup.
See the XF86Config(4/5) man page for general details. Here only the XF86_Mono specific partsare explained.
The Driver entry in Screen section of the XF86Config file should be set to vga2 for VGA and SVGA boards, and mono for non-
VGA mono boards. If Screen sectionsare present for both of these, the server will start in a dual-headed configuration.
625
Entriesfor the Device section in the XF86Config file include the following:
chipset name Specifiesa chipset so the correct driver can be used. Possible
chipsetsfor VGA2:
ATI Vgawonder
Tseng Et3000, et4000, et4000w32, et4000w32i,
et4000w32p
Western Digital Pvga1, wd90c00, wd90c10, wd90c30,
wd90c31, wd90c33
Genoa Gvga
Trident Tvga8800cs, tvga8900b, tvga8900c,
tvga8900cl, tvga9000
NCR Ncr77c22, ncr77c22e Compaq: cpq avga
OAK: oti067, oti077, oti087
Cirrus Clgd5420, clgd5422, clgd5424, clgd5426,
clgd5428, clgd5429, clgd5430, clgd5434,
clgd5436, clgd6205, clgd6215, clgd6225,
clgd6235, cl6410, cl6412, cl6420, cl6440
Generic VGA generic
Possible chipsetsfor mono:
Hyundai hgc1280
Sigma sigmalview
Apollo apollo9
Hercules hercules
MemBase memaddr ess Specifiesthe base addressof the video memory. Thisoption is
only used for the Sigma LaserViewcards. Valid addressesfor
these cardsare 0xA0000, 0xB0000, 0xC0000, 0xD0000, 0xE0000. The
default is0xE0000.
Black r ed gr een bl ue Setsthe black color to the RGB valuesspecified. These values
must be given asintegersin the range 063. The default is0 0
0. Thisoption isonly valid for the vga2 screen type.
White r ed gr een bl ue Setsthe white color to the RGB valuesspecified. These values
must be given asintegersin the range 063. The default is63
63 63. Thisoption isonly valid for the vga2 screen type.
Option opt i onst r i ng Allowsthe user to select certain optionsprovided by the
drivers. Currently the following stringsare recognized:
legendFor Sigma Legend ET4000-based boards. This
option enablesa special clock-selection algorithm used on
Legend boards, and MUST be specified for these boardsto
function correctly.
swap_hibitFor Western Digital/PVGA1 chipsets. Some
Western Digital-based boardsrequire the high-order clock-
select lead to be inverted. It isnot possible for the server to
determine thisinformation at run-time. If the 9th clock in the
list of clocksdetected by the server islessthan 30Mhz, this
option likely needsto be set.
xF86_Mono
Part I: User Commands
626
Hibit_low, hibit_highFor Tseng ET4000 chipsets. With
some ET4000 cards, the server hasdifficulty getting the state
of the high-order clocksselect bit right when started from a
high-resolution text mode. These optionsallow the correct
initial state of that bit to be specified. To find out what the
correct initial state is, start the server from an 8025 text
mode. Thisoption isonly needed if the clocksreported by the
server when started from a high-resolution text mode differ
from those reported when it isstarted from an 8025 text
mode.
8clocksFor the PVGA1 chipset, the default is4 clocks.
Some cardswith thischipset may support 8 clocks. Specifying
thisoption will allow the driver to detect and use the extra
clocks.
16clocksFor Trident TVGA8900B and 8900C chipsets. Some
newer boardsusing 8900B and 8900C chipsetsactually support
16 clocksrather than the standard 8 clocks. Such boardswill
have a TCK9002 or TCK9004 chip on them. Specifying thisoption
will allow the driver to detect and use the extra 8 clocks.
Power_saverThisoption enablesthe server to use the power
saving featuresof VESA DPMS-compatible monitors. The
suspend level iscurrently not supported. Refer to the
XF86Config(4/5) manual page for detailsof how to set the time-
outsfor the different levelsof operation. Thisoption is
experimental.
secondaryFor the hgc1280 and apollo9 chipsets. Thisoption
allowsthe use of these cardsjumpered to the secondary I/O/
memory address. These addressesare
hgc1280: I/O 0x3B0-0x3BF, mem 0xB0000-0xBFFFF (prim.)
I/O 0x390-0x39F, mem 0xC8000-0xCFFFF (sec.)
apollo9: I/O 0x3B0-0x3BF, mem 0xFA0000-0xFDFFFF (prim.)
I/O 0x3D0-0x3DF, mem 0xA0000-0xDFFFF (sec.)
XFree86 can detect the HGC-1280 on both primary and
secondary address; for the apollo card the primary addressis
used by default.
Note that XFree86 hassome internal capabilitiesto determine what hardware it isrunning on. Thus, normally the keywords
chipset, clocks, and videoram dont have to be specified. But there may be occasionswhen thisautodetection mechanism
fails, (for example, too high a load on the machine when you start the server). For caseslike this, one should first run
XF86_Mono on an unloaded machine, look at the resultsof the autodetection (that are printed out during server startup) and
then explicitly specify these parametersin the configuration file. It isrecommended that all parameters, especially Clock
values, be specified in the XF86Config file.
FILES
<XRoot>/bin/XF86 Mono The monochrome X server for VGA, SVGA and other
monochrome cards
/etc/XF86Config Server configuration file
<XRoot>/lib/X11/XF86Config Server configuration file
Note: <XRoot refersto the root of the X11 install tree.
627
SEE ALSO
X(1), Xserver(1), XFree86(1), XF86Config(4/5), xf86config(1), xvidtune(1), xdm(1), xinit(1)
BUGS
There are no known bugsat thistime, although we welcome reportse-mailed to the addresslisted below.
CONTACT INFO
XFree86 source isavailable from the FTP server ftp.XFree86.org.
Send e-mail to XFree86@XFree86.org for details.
AUTHORS
Refer to the XFree86(1) manual page.
XFree86 Version 3.1.2
XF86_SVGA
XF86_SVGANonaccelerated SVGA X Window System serversfor UNIX on x86 platforms
SYNOPSIS
XF86 SVGA [:displaynumber] [ option ] ...
DESCRIPTION
XF86_SVGA isan 8-bit PseudoColor, 16-bit TrueColor and 24-bit TrueColor server for Super VGA cards. It isderived from
the X386 server provided with X11R5. Note: 16-bit TrueColor iscurrently only supported for some Cirrusand ARK chips, and
24-bit TrueColor isonly supported for some Cirruschips.
CONFIGURATIONS
The XF86_SVGA server supportsthe following popular Super VGA chipsetsin 256-color mode. Virtual resolutionsup to
(approximately) 1152900 are supported, using (up to) 1MB of display memory. The Western Digital WD90C33 and some of
the Cirruschipsetssupport up to 2MB of display memory and virtual resolutionsof 1,2801,024 and higher. Some of the
Cirruschipsetsalso support 16bpp and 32bpp (truecolor) modeson certain configurations. Some of the ARK chipsets
support 16bpp modeson certain configurations. Generic VGA cardsare also supported at 8bpp 320200 only.
ATI 18800, 18800-1, 28800-2, 28800-4, 28800-5, 28800-6, 68800-3,
68800-6, 68800AX, 68800LX, 88800CX, 88800GX
Tseng ET3000, ET4000, ET4000/W32
Western Digital PVGA1, WD90C00, WD90C10, WD90C11, WD90C24A, WD90C30, WD90C31,
WD90C33
Genoa GVGA
Trident TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000
NCR 77C22, 77C22E
CirrusLogic CLGD5420, CLGD5422, CLGD5424, CLGD5426, CLGD5428,
CLGD5429,CLGD5430, CLGD5434, CLGD5436, CLGD6205, CLGD6215,
CLGD6225, CLGD6235, CL6410, CL6412, CL6420, CL6440
ARK ARK1000PV, ARK1000VL, ARK2000PV
RealTek RTG3106
Compaq AVGA
Oak OTI067, OTI077, OTI087
XF86_SVGA
Part I: User Commands
628
Avance Logic AL2101, ALI2301, ALI2302, ALI2308, ALI2401
Chips& Technology 65520, 65530, 65540, 65545
MX MX68000, MX68010
Video7 HT216-32
Accelerated support isincluded for most of the Cirruschipsets, and for the Western Digital WD90C31 and WD90C33 chipsets.
Accelerated support for the ET4000/W32 isimplemented in a separate server (see XF86_W32(1)). Usersof boardsbased on ATIs
Mach8, Mach32, and Mach64 chipsetsshould refer to the XF86_Mach8(1), XF86_Mach32(1) and XF86_Mach64(1) manual pages,
respectively.
OPTIONS
In addition to the normal server optionsdescribed in the Xserver(1) manual page, XF86_SVGA acceptssome more command-
line switches, asdescribed in the XFree86(1) man page.
SETUP
XFree86 usesa configuration file called XF86Config for itsinitial setup.
See the XF86Config(4/5) man page for general details. Here only the XF86_SVGA specific partsare explained.
Thisserver requiresa Screen section in the XF86Config file with the Driver entry set to svga.
Entriesfor the Device section in the XF86Config file include
chipset name Specifiesa chipset so the correct driver can be used. Possible
chipsetsare
ATI vgawonder
Tseng et3000, et4000, et4000w32,
et4000w32i, et4000w32p
Western Digital pvga1, wd90c00, wd90c10, wd90c24,
wd90c30, wd90c31, wd90c33
Genoa gvga
Trident tvga8800cs, tvga8900b, tvga8900c,
tvga8900cl, tvga9000
NCR ncr77c22, ncr77c22e
CirrusLogic clgd5420, clgd5422, clgd5424,
clgd5426, clgd5428, clgd5429,
clgd5430, clgd5434, clgd5436,
clgd6205, clgd6215, clgd6225,
clgd6235, cl6410, cl6412, cl6420,
cl6440
RealTek realtek
ARK ark1000pv, ark1000vl, ark2000pv
Compaq cpq_avga
Oak oti067, oti077, oti087
Avance Logic al2101, ali2301, ali2302, ali2308,
ali2401
Chips& Technology ct65520, ct65530, ct65540, ct65545
MX mx
Video7 video7
Generic generic
629
Option opt i onst r i ng Allowsthe user to select certain optionsprovided by the
drivers. Currently the following stringsare recognized:
legendFor Sigma Legend ET4000-based boards. Thisoption
enablesa special clock-selection algorithm used on Legend
boards, and MUST be specified for these boardsto function
correctly.
swap_hibitFor Western Digital/PVGA1 chipsets. Some
Western Digital-based boardsrequire the high-order clock-
select lead to be inverted. It isnot possible for the server to
determine thisinformation at run-time. If the 9th clock in the
list of clocksdetected by the server islessthan 30Mhz, this
option likely needsto be set.
Hibit_low, hibit_highFor Tseng ET4000 chipsets. With some
ET4000 cards, the server hasdifficulty getting the state of the
high-order clocksselect bit right when started from a high-
resolution text mode. These optionsallow the correct initial
state of that bit to be specified. To find out what the correct
initial state is, start the server from an 8025 text mode. This
option isonly needed if the clocksreported by the server when
started from a high-resolution text mode differ from those
reported when it isstarted from an 8025 text mode.
8clocksFor the PVGA1 chipset, the default is4 clocks.
Some cardswith thischipset may support 8 clocks. Specifying
thisoption will allow the driver to detect and use the extra
clocks.
16clocksFor Trident TVGA8900B and 8900C chipsets. Some
newer boardsusing 8900B and 8900C chipsetsactually support
16 clocksrather than the standard 8 clocks. Such boardswill
have a TCK9002 or TCK9004 chip on them. Specifying thisoption
will allow the driver to detect and use the extra 8 clocks.
probe_clocksFor Cirruschipsets. The Cirrusdriver hasa
fixed set of clocksthat are normally used. Specifying this
option will force the driver to probe for clocksinstead of
reporting the built-in defaults. Thisoption isfor debugging
purposesonly.
power_saverThisoption enablesthe server to use the power-
saving featuresof VESA DPMS-compatible monitors. The
suspend level iscurrently not supported. Refer to the
XF86Config(4/5) manual page for detailsof how to set the time-
outsfor the different levelsof operation. Thisoption is
experimental.
noaccelFor Cirrusand WD chipsets. Thisoption disables
the accelerated featuresfor the clgd5426, clgd5428, wd90c24,
wd90c31, and wd90c33 chipsets.
fifo_conservativeFor Cirruschipsets. Thisoption setsthe
CRT_FIFO threshold to a conservative value for dot clocksabove
65MHz. Thisreducesperformance, but may help in
eliminating problemswith streaks on the screen during
BitBLT operations.
fifo_aggressiveFor Cirruschipsets. Thisoption setsthe
CRT_FIFO threshold to an aggressive value for dot clocksabove
65MHz. Thismay increase performance.
XF86_SVGA
Part I: User Commands
630
slow_dramFor Cirruschipsets. Thisoption setsthe DRAM
timingsfor slow DRAM chips.
fast_dramFor ET4000 and Cirruschipsets. Thisoption sets
the DRAM timingsfor fast DRAM chips.
no_2mb_bankselFor Cirruschipsets. Thisoption isrequired
for Cirruscardswith 2MB of videoram, which isin the form of
512kx8 DRAMs(4 chips) rather than 256kx4 DRAMs(16
chips).
no_bitbltFor Cirruschipsets. Thisoption disablesuse of
hardware BitBLT.
linearAttempt a linear mapping of the framebuffer into
high memory. Currently only supported for some Cirrus
configurations.
med_dram, favour_bitblt, sw_cursor, clgd6225_lcd, mmioMore
Cirrus-specific options. Refer to /usr/X11R6/lib/X11/doc/
README.cirrus for a detailed description of Cirrusoptions.
speedup sel ect i on Setsthe selection of SpeedUps to use. The optional selection
string can take the following values:
none
all
If the selection string isomitted, or if the speedup option is
omitted, the selection defaultsto all. Some of the SpeedUps
can only be used with the ET4000, WD90C31, and WD90C33
chipsetsand othersrequire a virtual resolution with a xdim of
1024. SpeedUpsthat wont work with a given configuration
are automatically disabled.
nospeedup Disablesthe SpeedUp code. Thisisequivalent to speedup
none.
Ramdac r amdac- t ype Thisspecifiesthe type of RAMDAC used on the board. Only
the ARK driver currently usesthis. RAMDAC typesrecognized
include
Att20c490AT&T 20C490 or compatible 8-bit RAMDAC.
Att20c498AT&T 20C498 or compatible 16-bit RAMDAC.
ZoomdacRAMDAC used by the HerculesStingray Pro/V and
64/V.
Stg1700STG1700 or compatible RAMDAC.
Note that XFree86 hassome internal capabilitiesto determine what hardware it isrunning on. Thus, normally the keywords
chipset, clocks, and videoram dont have to be specified. But there may be occasionswhen thisautodetection mechanism
fails, (for example, too high a load on the machine when you start the server). For caseslike this, you should first run
XF86_SVGA on an unloaded machine, look at the resultsof the autodetection (that are printed out during server startup), and
then explicitly specify these parametersin the configuration file. It isrecommended that all parameters, especially Clock
values, be specified in the XF86Config file.
FILES
<XRoot>/bin/XF86 SVGA The SVGA color X server
/etc/XF86Config Server configuration file
<XRoot>/lib/X11/XF86Config Server configuration file
<XRoot>/lib/X11/doc/README.ark Extra documentation for the ARK driver
<XRoot>/lib/X11/doc/README.ati Extra documentation for the ATI vgawon-der driver
631
<XRoot>/lib/X11/doc/README.cirrus Extra documentation for the Cirrusdriver
<XRoot>/lib/X11/doc/README.trident Extra documentation for the Trident driver
<XRoot>/lib/X11/doc/README.tseng Extra documentation for the ET4000 and ET3000 drivers
<XRoot>/lib/X11/doc/README.Oak Extra documentation for the Oak driver
<XRoot>/lib/X11/doc/README.Video7 Extra documentation for the Video7 driver
<XRoot>/lib/X11/doc/README.WstDig Extra documentation for the WD/PVGA driver
Note: <XRoot> refersto the root of the X11 install tree.
SEE ALSO
X(1), Xserver(1), XFree86(1), XF86Config(4/5), xf86config(1), xvidtune(1), xdm(1), xinit(1)
BUGS
Bug reportsare welcome, and should be e-mailed to the addresslisted below.
CONTACT INFO
XFree86 source isavailable from the FTP server ftp.XFree86.org.
Send e-mail to XFree86@XFree86.org for details.
AUTHORS
Refer to the XFree86(1) manual page.
XFree86 Version 3.1.2
XF86_VGA16
XF86 VGA164-bit nonaccelerated X Window System server for UNIX on x86 platforms
SYNOPSIS
XF86 VGA16 [:displaynumber] [ option ] ...
DESCRIPTION
XF86_VGA16 isa 4-bit color server for VGA cards. The default root visual for thisserver isStaticColor. It also includessupport
for the non-VGA monochrome cardsdescribed in the XF86_Mono(1) manual page. It may be run in a dual-headed configura-
tion.
CONFIGURATIONS
The XF86_VGA16 server supportsthe following popular SVGA chipsetsin 16-color mode.
ATI 18800, 18800-1, 28800-2, 28800-4, 28800-5, 28800-6, 68800-3,
68800-6, 68800AX, 68800LX, 88800CX, 88800GX
Tseng ET4000
Trident TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000
Cirrus CL6410, CL6412, CL6420, CL6440
Oak OTI067, OTI077, OTI087
Additionally, it supportsgeneric VGA cards.
XF86_VGA16 doesnot support the accelerated functionsof the supported chipsets.
XF86_VGA16
Part I: User Commands
632
OPTIONS
In addition to the normal server optionsdescribed in the Xserver(1) manual page, XF86_VGA16 acceptssome more command-
line switches, asdescribed in the XFree86(1) man page.
SETUP
XFree86 usesa configuration file called XF86Config for itsinitial setup.
See the XF86Config(4/5) man page for general details. Here, only the XF86_VGA16 specific partsare explained.
The Driver entry in the Screen section of the XF86Config file should be set to vga16.To run in dual-headed configuration,
there should also be a Screen section with the Driver entry set to mono.
Entriesfor the Device section in the XF86Config file include the following:
chipset name Specifiesa chipset so the correct driver can be used. Possible
chipsetsare
ATI vgawonder
Tseng et4000, et4000w32, et4000w32i, et4000w32p
Trident tvga8800cs, tvga8900b, tvga8900c,
tvga8900cl, tvga9000
Cirrus cl6410, cl6412, cl6420, cl6440
Oak oti067, oti077, oti087
Generic VGA generic
Option opt i onst r i ng Allowsthe user to select certain optionsprovided by the
drivers. Currently, the following stringsare recognized:
legendFor Sigma Legend ET4000-based boards. Thisoption
enablesa special clock-selection algorithm used on Legend
boards, and MUST be specified for these boardsto function
correctly.
hibit_low, hibit_highFor Tseng ET4000 chipsets. With some
ET4000 cards, the server hasdifficulty getting the state of the
high-order clocksselect bit right when started from a high-
resolution text mode. These optionsallow the correct initial
state of that bit to be specified. To find out what the correct
initial state is, start the server from an 8025 text mode. This
option isonly needed if the clocksreported by the server when
started from a high-resolution text mode differ from those
reported when it isstarted from an 8025 text mode.
power_saverThisoption enablesthe server to use the power
saving featuresof VESA DPMS-compatible monitors. The
suspend level iscurrently not supported.
Refer to the XF86Config(4/5) manual page for detailsof how to
set the time-outsfor the different levelsof operation. This
option isexperimental.
Note that XFree86 hassome internal capabilitiesto determine what hardware it isrunning on. Thusnormally the keywords
chipset, clocks, and videoram dont have to be specified. But there may be occasionswhen thisautodetection mechanism
fails, (for example, too high a load on the machine when you start the server). For caseslike this, you should first run XF86
VGA16 on an unloaded machine, look at the resultsof the autodetection (that are printed out during server startup), and then
explicitly specify these parametersin the configuration file. It isrecommended that all parameters, especially Clock values, be
specified in the XF86Config file.
633
FILES
<XRoot>/bin/XF86 VGA16 The 16-color X server
/etc/XF86Config Server configuration file
<XRoot>/lib/X11/XF86Config Server configuration file
Note: <XRoot> refersto the root of the X11 install tree.
SEE ALSO
X(1), Xserver(1), XFree86(1), XF86Config(4/5), XF86 Mono(1), xf86config(1), xvidtune(1), xdm(1), xinit(1)
CONTACT INFO
XFree86 source isavailable from the FTP server ftp.XFree86.org.
Send e-mail to XFree86@XFree86.org for details.
AUTHORS
The primary developer of thisserver isGertjan Akkerman (akkerman@dutiba.twi.tudelft.nl).
See also the XFree86(1) manual page.
XFree86 Version 3.1.2
xf86config
xf86configGenerate an XF86Config file
SYNOPSIS
xf86config
DESCRIPTION
xf86config isan interactive program for generating an XF86Configfile for use with XFree86 X servers.
FILES
<xroot>/lib/X11/Cards Video cardsdatabase
SEE ALSO
XFree86(1), XF86Config(4/5), reconfig(1)
AUTHOR
Harm Hanemaayer
XFree86 Version 3.1.1
xfd
xfdDisplay all the charactersin an X font
SYNOPSIS
xfd [options ...] fn f ont name
xfd
Part I: User Commands
634
DESCRIPTION
The xfd utility createsa window containing the name of the font being displayed, a row of command buttons, several linesof
text for displaying character metrics, and a grid containing one glyph per cell. The charactersare shown in increasing order
from left to right, top to bottom. The first character displayed at the top left will be character number 0 unlessthe start
option hasbeen supplied, in which case the character with the number given in the start option will be used.
The charactersare displayed in a grid of boxes, each large enough to hold any single character in the font. Each character
glyph isdrawn using the PolyText16 request (used by the Xlib routine XDrawString16). If the box option isgiven, a rectangle
will be drawn around each character, showing where an ImageText16 request (used by the Xlib routine XDrawImageString16)
would cause background color to be displayed.
The origin of each glyph isnormally set so that the character isdrawn in the upper left corner of the grid cell. However, if a
glyph hasa negative left bearing or an unusually large ascent, descent, or right bearing (asisthe case with cursor font), some
charactersmay not appear in their own grid cells. The center option may be used to force all glyphsto be centered in their
respective cells.
All the charactersin the font may not fit in the window at once. To see the next page of glyphs, pressthe Next button at the
top of the window. To see the previouspage, pressPrev. To exit xfd, pressQuit.
Individual character metrics(index, width, bearings, ascent, and descent) can be displayed at the top of the window by
clicking on the desired character.
The font name displayed at the top of the window isthe full name of the font, asdetermined by the server. See xlsfonts for
waysto generate listsof fonts, aswell asmore detailed summariesof their metricsand properties.
OPTIONS
xfd acceptsall of the standard toolkit command-line optionsalong with the following additional options:
fn f ont Thisoption specifiesthe font to be displayed. Thiscan also be
set with the FontGrid font resource. A font must be specified.
box Thisoption indicatesthat a box should be displayed outlining
the area that would be filled with background color by an
ImageText request. Thiscan also be set with the FontGrid
boxChars resource. The default isFalse.
center Thisoption indicatesthat each glyph should be centered in its
grid. Thiscan also be set with the FontGrid centerChars
resource. The default isFalse.
start number Thisoption specifiesthe glyph index of the upper left corner
of the grid. Thisisused to view charactersat arbitrary
locationsin the font. Thiscan also be set with the FontGrid
startChar resource. The default is0.
bc col or Thisoption specifiesthe color to be used if ImageText boxes
are drawn. Thiscan also be set with the FontGrid boxColor
resource.
rows numr ows Thisoption specifiesthe number of rowsin the grid. Thiscan
also be set with the FontGrid cellRows resource.
columns numcol s Thisoption specifiesthe number of columnsin the grid. This
can also be set with the FontGrid cellColumns resource.
WIDGETS
In order to specify resources, it isuseful to know the widgetsthat compose xfd. In the notation below, indentation indicates
hierarchical structure. The widget classname isgiven first, followed by the widget instance name. The application classname
isXfd.
635
Xfd xfd
Paned pane
Label fontname
Box box
Command quit
Command prev
Command next
Label select
Label metrics
Label range
Label start
Form form
FontGrid grid
FONTGRID RESOURCES
The FontGrid widget isan application-specific widget, and a subclassof the Simple widget in the Athena widget set. The
effectsand instance namesof thiswidgetsresourcesare given in the Options subsection. Capitalize the first letter of the
resource instance name to get the corresponding classname.
APPLICATION SPECIFIC RESOURCES
The instance namesof the application-specific resourcesare given in the following list. Capitalize the first letter of the
resource instance name to get the corresponding classname. These resourcesare unlikely to be interesting unlessyou are
localizing xfd for a different language.
selectFormat Specifiesa printf-style format string used to display informa-
tion about the selected character. The default ischaracter
0x%02x%02x (%u,%u) (%#o,%#o). The argumentsthat will come
after the format string are
char.byte1, char.byte2, char.byte1, char.byte2, char.byte1,
char.byte2. char.byte1 isbyte 1 of the selected character.
char.byte2 isbyte 2 of the selected character.
metricsFormat Specifiesa printf-style format string used to display character
metrics. The default iswidth %d; left %d, right %d; ascent
%d, descent %d (font %d, %d). The argumentsthat will come
after the format string are the character metricswidth,
lbearing, rbearing, character ascent, character descent, font
ascent, and font descent.
rangeFormat Specifiesa printf-style format string used to display the range
of characterscurrently being displayed. The default isrange:
0x%02x%02x (%u,%u) thru 0x%02x%02x (%u,%u). The arguments
that will come after the format string are the following fields
from the XFontStruct that isreturned from opening the font:
min_byte1, min_char_or_byte2, min_byte1, min_char_or_byte2,
max_byte1, max_char_or_byte2, max_byte1, max_char_or_byte2.
startFormat Specifiesa printf-style format string used to display informa-
tion about the character at the upper left corner of the font
grid. The default isupper left: 0x%04x (%d,%d). The
argumentsthat will come after the format string are the new
character, the high byte of the new character, and the low byte
of the new character.
nocharFormat Specifiesa printf-style format string to display when the
selected character doesnot exist. The default isno such
character 0x%02x%02x (%u,%u) (%#o,%#o. The argumentsthat
will come after the format string are the same asfor the
select-Format resource.
xfd
Part I: User Commands
636
SEE ALSO
X(1), xlsfonts(1), xrdb(1), xfontsel(1), X Logical Font Description Conventions
BUGS
The program should skip over pagesfull of nonexistent characters.
AUTHOR
Jim Fulton (MIT X Consortium); previousprogram of the same name by Mark Lillibridge (MIT Project Athena)
X Version 11 Release6
XFree86
XFree86X11R6 for UNIX on x86 platforms
DESCRIPTION
XFree86 isa collection of X serversfor UNIX-like OSson Intel x86 platforms. Thiswork isderived from X386n1.2, which was
contributed to X11R5 by Snitily GraphicsConsulting Service.
CONFIGURATIONS
XFree86 operatesunder the following operating systems:
I SVR3.2: SCO 3.2.2, 3.2.4, ISC 3.x, 4.x
I SVR4.0: ESIX, Microport, Dell, UHC, Consensys, MST, ISC, AT&T, NCR
I SVR4.2: Consensys, Univel (UNIXWare)
I Solaris(x86) 2.1, 2.4
I FreeBSD 1.1.5, 2.0, 2.0.5, NetBSD 1.0 (i386 port only)
I BSD/386 version 1.1 and BSD/OS 2.0
I Mach (from CMU)
I Linux
I Amoeba version 5.1
I Minix-386vm version 1.6.25.1
I LynxOSAT versions2.2.1 and 2.3
NETWORK CONNECTIONS
XFree86 supportsconnectionsmade using the following reliable byte-streams:
Local XFree86 supportslocal connectionsvia Streamspipe via various
mechanisms, using the following paths(n representsthe
display number):
/dev/X/server.n (SVR3 and SVR4)
/dev/X/Nserver.n (SVR4)
/dev/XnS and /dev/XnR (SCO SVR3)
In SVR4.0.4, if the Advanced Compatibility Package is
installed, and in SVR4.2, XFree86 supportslocal connections
from clientsfor SCO XSight/ODT, and (with modifications
to the binary) clientsfor ISC SVR3.
UNIX Domain XFree86 uses/tmp/.X11-unix/Xn asthe filename for the socket,
where n isthe display number.
637
TCPIP XFree86 listenson port htons(6000+n), where n isthe display
number.
Amoeba RPC Thisisthe default communication medium used under native
Amoeba. Note that under Amoeba, the server should be
started with a host name: di spl aynumber argument.
ENVIRONMENT VARIABLES
For operating systemsthat support local connectionsother than UNIX Domain sockets(SVR3 and SVR4), there isa
compiled-in list specifying the order in which local connectionsshould be attempted. Thislist can be overridden by the
XLOCAL environment variable described next. If the display name indicatesa best-choice connection should be made (for
example, :0.0), each connection mechanism istried until a connection succeedsor no more mechanismsare available. Note:
For these OSs, the UNIX Domain socket connection istreated differently from the other local connection types. To use it
the connection must be made to unix:0.0.
The XLOCAL environment variable should contain a list of one more of the following:
NAMED
PTS
SCO
ISC
which represent SVR4 Named Streamspipe, Old-style USL Streamspipe, SCO XSight Streamspipe, and ISC Streamspipe,
respectively. You can select a single mechanism (for example, XLOCAL=NAMED), or an ordered list, for example,
XLOCAL=NAMED:PTS:SCO
Thisvariable overridesthe compiled-in defaults. For SVR4 it isrecommended that NAMED be the first preference connection.
The default setting is
PTS:NAMED:ISC:SCO.
To globally override the compiled-in defaults, you should define (and export if using sh or ksh) XLOCAL globally. If you use
startx/xinit, the definition should be at the top of your .xinitrc file. If you use xdm, the definitionsshould be early on in
the <XRoot>/lib/X11/xdm/Xsession script.
OPTIONS
In addition to the normal server optionsdescribed in the Xserver(1) manual page, XFree86 acceptsthe following command-
line switches:
vtXX XX specifiesthe Virtual Terminal device number that XFree86
will use. Without thisoption, XFree86 will pick the first
available Virtual Terminal that it can locate. Thisoption
appliesonly to SVR3, SVR4, Linux, and BSD OSs with the
syscons or pcvt driver.
probeonly Causesthe server to exit after the device probing stage. The
XF86Config file isstill used when thisoption isgiven, so
information that can be auto detected should be commented
out.
quiet Suppressesmost informational messagesat startup.
bpp n Set number of bitsper pixel. The default is8. Legal valuesare
8, 15, 16, 24, 32. Not all serverssupport all values.
weight nnn SetsRGB weighting at 16 bpp. The default is565. Thisapplies
only to those serversthat support 16 bpp.
gamma val ue Setsthe gamma correction. val ue must be between 0.1 and 10.
The default is1.0. Thisvalue isapplied equally to the R, G,
and B values. Not all serverssupport this.
xFree86
Part I: User Commands
638
rgamma value Setsthe red gamma correction. value must be between 0.1 and
10. The default is1.0. Not all serverssupport this.
ggamma value Setsthe green gamma correction. value must be between 0.1
and 10. The default is1.0. Not all serverssupport this.
bgamma value Setsthe blue gamma correction. value must be between 0.1
and 10. The default is1.0. Not all serverssupport this.
showconfig Printsout a list of screen driversconfigured in the server.
verbose Maximizesinformation printed at startup (more than the
default).
xf86config file Readsthe server configuration from file. Thisoption isonly
available when the server isrun asroot (that is, with real-
UID 0).
keeptty Preventsthe server from detaching itsinitial controlling
terminal. Thisoption isonly useful when debugging the
server.
KEYBOARD
Multiple key pressesrecognized directly by XFree86 are
Ctrl+Alt+Backspace Immediately killsthe serverno questionsasked. (Can be
disabled by specifying DontZap in the Server-Flagssection of
the XF86Config file.)
Ctrl+Alt+Keypad-Plus Changesvideo mode to next one specified in the configuration
file, (increasing video resolution order).
Ctrl+Alt+Keypad-Minus Changesvideo mode to previousone specified in the
configuration file, (decreasing video resolution order).
Ctrl+Alt+F1F12 For BSD systemsusing the sysconsdriver and Linux, these
keystroke combinationsare used to switch to Virtual Console
1 through 12.
SETUP
XFree86 usesa configuration file called XF86Config for itsinitial setup. Refer to the XF86Config(4/5) manual page for more
information.
FILES
<XRoot>/bin/XF86 SVGA The color SVGA X server
<XRoot>/bin/XF86 Mono The monochrome X server for VGA and other mono cards
<XRoot>/bin/XF86 S3 The accelerated S3 X server
<XRoot>/bin/XF86 Mach8 The accelerated Mach8 X server
<XRoot>/bin/XF86 Mach32 The accelerated Mach32 X server
<XRoot>/bin/XF86 Mach64 The accelerated Mach64 X server
<XRoot>/bin/XF86 P9000 The accelerated P9000 X server
<XRoot>/bin/XF86 AGX The accelerated AGX X server
<XRoot>/bin/XF86 W32 The accelerated ET4000/W32 X server
<XRoot>/bin/XF86 8514 The accelerated 8514/A X server
/etc/XF86Config Server configuration file
<XRoot>/lib/X11/XF86Config.hostname Server configuration file
<XRoot>/lib/X11/XF86Config Server configuration file
<XRoot>/bin/ Client binaries
639
<XRoot>/include/ Header files
<XRoot>/lib/ Libraries
<XRoot>/lib/X11/fonts/ Fonts
<XRoot>/lib/X11/rgb.txt Color namesto RGB mapping
<XRoot>/lib/X11/XErrorDB Client error message database
<XRoot>/lib/X11/app-defaults/ Client resource specifications
<XRoot>/man/man?/ Manual pages
/etc/Xn.hosts Initial accesscontrol list for display n
Note: <XRoot> refersto the root of the X11 install tree.
SEE ALSO
X(1), Xserver(1), xdm(1), xinit(1), XF86Config(4/5), xf86config(1), XF86 SVGA(1), XF86 VGA16(1), XF86 Mono(1), XF86 Accel(1),
xvidtune(1)
AUTHORS
For X11R5, XF86 1.2 wasprovided by the following:
ThomasRoell (roell@informatik.tu-muenchen.de; server and SVR4 stuff), Mark W. Snitily (mark@sgcs.com SGCS; SVR3
support, X Consortium Sponsor), and many more people out there on the Net who helped with ideasand bug fixes.
XFree86 wasintegrated into X11R6 by the following team:
Stuart Anderson (anderson@metrolink.com), Doug Anson (danson@lgc.com), Gertjan Akkerman
(akkerman@dutiba.twi.tudelft.nl), Mike Bernson (mike@mbsun.mlb.org), Robin Cutshaw (robin@XFree86.org), David Dawes
(dawes@XFree86.org), Marc Evans(marc@XFree86.org), Pascal Haible (haible@izfm.uni-stuttgart.de), Matthieu Herrb
(Matthieu.Herrb@laas.fr), Dirk Hohndel (hohndel@XFree86.org), David Holland (davidh@use.com), Alan Hourihane
(alanh@fairlite.demon.co.uk), Jeffrey Hsu (hsu@soda.berkeley.edu), Glenn Lai (glenn@cs.utexas.edu), Ted Lemon
(mellon@ncd.com), Rich Murphey (rich@XFree86.org), HansNasten (nasten@everyware.se), Mark Snitily (mark@sgcs.com),
Randy Terbush (randyt@cse.unl.edu), Jon Tombs(tombs@XFree86.org), KeesVerstoep (versto@cs.vu.nl), Paul Vixie
(paul@vix.com), Mark Weaver (Mark Weaver@brown.edu), David Wexelblat (dwex@XFree86.org), Philip Wheatley
(Philip.Wheatley@ColumbiaSC.NCR.COM), ThomasWolfram (wolf@prz.tu-berlin.de), and Orest Zborowski
(orestz@eskimo.com).
The XFree86 enhancement package wasprovided by
David Dawes, dawes@XFree86.org Release coordination, administration of FTP repository and
mailing lists. Source tree management and integration,
accelerated server integration, fixing, and coding.
Glenn Lai, glenn@cs.utexas.edu The SpeedUp code for ET4000-based SVGA cards, and ET4000/
W32 accelerated server.
Jim Tsillas, jtsilla@ccs.neu.edu Many server speedupsfrom the fX386 seriesof enhancements.
David Wexelblat, dwex@XFree86.org Integration of the fX386 code into the default server, many
driver fixes, and driver documentation, assembly of the VGA
card/monitor database, development of the generic video
mode listing. Accelerated server integration, fixing, and
coding.
Dirk Hohndel, hohndel@XFree86.org Linux-shared librariesand release coordination. Accelerated
server integration and fixing. Generic administrivia and
documentation.
Amancio Hasty Jr., hasty@netcom.com Porting to 386BSD version 0.1 and XS3 development.
Rich Murphey, rich@XFree86.org Ported to 386BSD version 0.1 based on the original port by
Pace Willison. Support for 386BSD, FreeBSD, and NetBSD.
xFree86
Part I: User Commands
640
Robert Baron, Robert.Baron@ernst.mach.cs.cmu.edu Ported to Mach.
Orest Zborowski, orestz@eskimo.com Ported to Linux.
Doug Anson, danson@lgc.com Ported to Solarisx86.
David Holland, davidh@use.com Ported to Solarisx86.
David McCullough, davidm@stallion.oz.au Ported to SCO SVR3.
Michael Rohleder, michael.rohleder@stadt-frankfurt.de Ported to ISC SVR3.
KeesVerstoep, versto@cs.vu.nl Ported to Amoeba based on Leendert van Doornsoriginal
Amoeba port of X11R5.
Marc Evans, Marc@XFree86.org Ported to OSF/1.
Philip Homburg, philip@cs.vu.nl Ported to Minix-386vm.
ThomasMueller, tm@systrix.de Ported to LynxOS.
Jon Tombs, tombs@XFree86.org S3 server and accelerated server coordination.
Harald Koenig, koenig@tat.physik.uni-tuebingen.de S3 server development.
Bernhard Bender, br@elsa.mhs.compuserve.com S3 server development.
Kevin Martin, martin@cs.unc.edu Overall work on the base accelerated servers(ATI and 8514/
A), and Mach64 server.
Rik Faith, faith@cs.unc.edu Overall work on the base accelerated servers(ATI and 8514/A).
Tiago Gons, tiago@comosjn.hobby.nl Mach8 and 8514/A server development.
HansNasten, nasten@everyware.se Mach8, 8514/A, and S3 server development and BSD/386
support.
Mike Bernson, mike@mbsun.mlb.org Mach32 server development.
Mark Weaver, Mark Weaver@brown.edu Mach32 server development.
Craig Groeschel, craig@metrolink.com Mach32 server development.
Henry Worth, Henry.Worth@amail.amdahl.com AGX server.
Erik Nygren, nygren@mit.edu P9000 server.
Harry Langenbacher, harry@brain.jpl.nasa.gov P9000 server.
ChrisMason, mason@mail.csh.rit.edu P9000 server.
Henrik Harmsen, harmsen@eritel.se P9000 server.
Simon Cooper, scooper@vizlab.rutgers.edu Cirrusaccelerated code (based on work by Bill Reynolds).
Harm Hanemaayer, hhanemaa@cs.ruu.nl Cirrusaccelerated code and ARK driver.
Mike Tierney, floyd@eng.umd.edu WD accelerated code.
Bill Conn, conn@bnr.ca WD accelerated code.
Brad Bosch, brad@lachman.com WD 90C24A support.
Alan Hourihane, alanh@fairlite.demon.co.uk Trident SVGA driver
Marc La France, Marc.La-France@ualberta.ca ATI vgawonder SVGA driver
Steve Goldman, sgoldman@encore.com Oak 067/077 SVGA driver.
Jorge Delgado, ernar@dit.upm.es Oak SVGA driver, and 087 accelerated code.
Bill Conn, conn@bnr.ca WD accelerated code.
Paolo Severini, lendl@dist.dist.unige.it AL2101 SVGA driver.
Ching-Tai Chiu, cchiu@netcom.com Avance Logic ALI SVGA driver.
Manfred Brands, mb@oceonics.nl Cirrus64xx SVGA driver.
Randy Hendry, randy@sgi.com Cirrus6440 support in the cl64xx SVGA driver.
Frank Dikker, dikker@cs.utwente.nl MX SVGA driver.
RegisCridlig, cridlig@dmi.ens.fr Chips& Technology driver.
Jon Block, block@frc.com Chips& Technology driver.
641
Mike Hollick, hollick@graphics.cis.upenn.edu Chips& Technology driver
Peter Trattler, peter@sbox.tu-graz.ac.at RealTek SVGA driver.
Craig Struble, cstruble@acm.vt.edu Video7 SVGA driver.
Gertjan Akkerman, akkerman@dutiba.twi.tudelft.nl 16-color VGA server, and XF86Config parser.
Davor Matic, dmatic@Athena.MIT.EDU Herculesdriver.
Pascal Haible, haible@izfm.uni-stuttgart.de Banked monochrome VGA support, Herculessupport, and
mono frame buffer support for dumb monochrome devices.
and many more people out there on the Net who helped with beta-testing thisenhancement.
XFree86 source isavailable from the FTP server ftp.XFree86.org, among others. Send e-mail to XFree86@XFree86.org for
details.
XFree86 Version 3.1.2
xfs
xfsX font server
SYNOPSIS
xfs [config conf i gur at i on_f i l e] [port t cp_por t ]
DESCRIPTION
xfs isthe X Window System font server. It suppliesfontsto X Window System display servers.
STARTING THE SERVER
The server isusually run by a system administrator, and started via boot fileslike /etc/rc.local. Usersmay also wish to start
private font serversfor specific setsof fonts.
OPTIONS
config configuration_file Specifiesthe configuration file the font server will use.
ls listen-socket Specifiesa file descriptor that isalready set up to be used asthe
listen socket. Thisoption isonly intended to be used by the
font server itself when automatically spawning another copy of
itself to handle additional connections.
port tcp_port Specifiesthe TCP port number on which the server will listen
for connections.
SIGNALS
SIGTERM Thiscausesthe font server to exit cleanly.
SIGUSR1 Thissignal isused to cause the server to reread itsconfigura-
tion file.
SIGUSR2 Thissignal isused to cause the server to flush any cached data
it may have.
SIGHUP Thissignal isused to cause the server to reset, closing all active
connectionsand rereading the configuration file.
xfs
Part I: User Commands
642
CONFIGURATION
The configuration language isa list of keyword and value pairs. Each keyword isfollowed by an = and then the desired value.
Recognized keywordsinclude the following:
catalogue (list of string) Ordered list of font path element names. Use of the key-word
catalogue isvery misleading at present; the current
implementation only supportsa single catalogue (all),
containing all of the specified fonts.
alternate-servers (list of string) List of alternate serversfor thisfont server.
client-limit (cardinal) Number of clientsthisfont server will support before refusing
service. Thisisuseful for tuning the load on each individual
font server.
clone-self (Boolean) Whether thisfont server should attempt to clone itself when it
reachesthe client-limit.
default-point-size The default pointsize (in decipoints) for
(cardinal) fontsthat dont specify. The default is120.
default-resolutions Resolutionsthe server supportsby default.
(list of resolutions) Thisinformation may be used asa hint for
prerendering, and substituted for scaled fontsthat do not
specify a resolution. A resolution isa comma-
separated pair of x and y resolutionsin pixels
per inch. Multiple resolutionsare separated by commas.
error-file (string) Filename of the error file. All warningsand errorswill be
logged here.
port (cardinal) TCP port on which the server will listen for connections.
use-syslog (Boolean) Whether syslog(3) (on supported systems) isto be used for
errors.
deferglyphs (string) Set the mode for delayed fetching and caching of glyphs. Value
isnone, meaning deferred glyphsisdisabled, all, meaning it is
enabled for all fonts, and 16, meaning it isenabled only for 16-
bitsfonts.
EXAMPLE
#
# sample font server configuration file
#
# allow a max of 10 clients to connect to this font server client-limit = 10
# when a font server reaches its limit, start up a new one clone-self = on
# alternate font servers for clients to use alternate-servers = hansen:7101,hansen:7102
# where to look for fonts
# the first is a set of Speedo outlines, the second is a set of
# misc bitmaps and the last is a set of 100dpi bitmaps
#
catalogue = /usr/X11R6/lib/X11/fonts/speedo,
/usr/X11R6/lib/X11/fonts/misc,
/usr/X11R6/lib/X11/fonts/100dpi/
# in 12 points, decipoints
default-point-size = 120
# 100 x 100 and 75 x 75
default-resolutions = 100,100,75,75
use-syslog = off
643
FONT SERVER NAMES
One of the following formscan be used to name a font server that acceptsTCP connections:
tcp/host name: por t tcp/host name: por t /cat al oguel i st
The host name specifiesthe name (or decimal numeric address) of the machine on which the font server isrunning. The por t
isthe decimal TCP port on which the font server islistening for connections. The cat al oguel i st specifiesa list of catalogue
names, with + asa separator.
Examples: tcp/fs.x.org:7100, tcp/18.30.0.212:7101/all.
One of the following formscan be used to name a font server that acceptsDECnet connections:
decnet/nodename::font$obj name decnet/nodename::font$obj name/cat al oguel i st
The nodename specifiesthe name (or decimal numeric address) of the machine on which the font server isrunning. The
obj name isa normal, case-insensitive DECnet object name. The cat al oguel i st specifiesa list of catalogue names, with + asa
separator.
Examples: DECnet/SRVNOD::FONT$DEFAULT, decnet/44.70::font$special/symbols.
SEE ALSO
X(1), font server implementation overview
BUGS
Multiple cataloguesshould be supported.
AUTHORS
Dave Lemke (Network Computing Devices, Inc.), Keith Packard (MassachusettsInstitute of Technology)
X Version 11 Release6
xhost
xhostServer accesscontrol program for X
SYNOPSIS
xhost [[+]name ...]
DESCRIPTION
The xhost program isused to add and delete hostnamesor usernamesto the list allowed to make connectionsto the X server.
In the case of hosts, thisprovidesa rudimentary form of privacy control and security. It isonly sufficient for a workstation
(single user) environment, although it doeslimit the worst abuses. Environmentsthat require more sophisticated measures
should implement the user-based mechanism or use the hooksin the protocol for passing other authentication data to the
server.
OPTIONS
Xhost acceptsthe following command-line options. For security, the optionsthat effect accesscontrol may only be run from
the controlling host. For workstations, thisisthe same machine asthe server. For X terminals, it isthe login host.
help Printsa usage message.
[+]name The given name (the plussign isoptional) isadded to the list
allowed to connect to the X server. The name can be a
hostname or a username.
xhost
Part I: User Commands
644
name The given name isremoved from the list allowed to connect to
the server. The name can be a hostname or a username.
Existing connectionsare not broken, but new connection
attemptswill be denied. Note that the current machine is
allowed to be removed; however, further connections
(including attemptsto add it back) will not be permitted.
Resetting the server (thereby breaking all connections) isthe
only way to allow local connectionsagain.
+ Accessisgranted to everyone, even if they arent on the list (in
other words, accesscontrol isturned off).
Accessisrestricted to only those on the list (that is, access
control isturned on).
not hi ng If no command-line argumentsare given, a message indicating
whether or not accesscontrol iscurrently enabled isprinted,
followed by the list of those allowed to connect. Thisisthe
only option that may be used from machinesother than the
controlling host.
NAMES
A complete name hasthe syntax f ami l y :name where the familiesare asfollows:
inet Internet host
dne DECnet host
nis Secure RPC network name
krb KerberosV5 principal
local Containsonly one name, the empty string
The family iscase insensitive. The format of the name varieswith the family.
When Secure RPC isbeing used, the network-independent netname (for example, nis:unix.uid@domainname) can be
specified, or a local user can be specified with just the username and a trailing at sign (@) (for example, nis:pat@).
For backward compatibility with pre-R6 xhost, namesthat contain an at sign are assumed to be in the nis family. Otherwise,
the inet family isassumed.
DIAGNOSTICS
For each name added to the accesscontrol list, a line of the form name being added to access control list isprinted. For
each name removed from the accesscontrol list, a line of the form name being removed from access control list isprinted.
FILES
/etc/X*.hosts
SEE ALSO
X(1), Xsecurity(1), Xserver(1), xdm(1)
ENVIRONMENT
DISPLAY To get the default host and display to use
BUGS
You cant specify a display on the command line because display isa valid command-line argument (indicating that you
want to remove the machine named display from the accesslist).
645
The X server storesnetwork addresses, not hostnames. Thisisnot really a bug. If somehow you change a hostsnetwork
addresswhile the server isstill running, xhost must be used to add the new addressand/or remove the old address.
AUTHORS
Bob Scheifler (MIT Laboratory for Computer Science) and Jim Gettys(MIT Project Athena/DEC)
X Version 11 Release6
xieperf
xieperfXIE server extension test and demo program
SYNTAX
xieperf [-option ...]
DESCRIPTION
The xieperf program isbased upon R5 x11perf(1) , and while not entirely comprehensive in itscoverage of the XIE protocol
(see the Bugs subsection), it isintended to be useful in the evaluation of XIE implementationsin the areasof protocol
adherence and performance. The xieperf program includesteststhat execute each of the protocol requestsand photoflo
elementsspecified by revision 5.0 of the XIE protocol. In addition, xieperf providesa set of teststhat can be used to validate
the detection and transmission of XIE protocol request errors, such asFloMatch, FloValue, and so forth. Finally, xieperf
providesa customizable demonstration program for XIE.
A test ismade up of three componentsexecuted in sequence: an initialization function, a test function, and an end function.
The initialization function isresponsible for allocating and populating test resources, such asphotomapsand LUTs, and for
creating a stored photoflo that will be executed by the test function. The test function, in most cases, simply executesthe
stored photoflo for a specified number of repetitions. The end function, which iscalled following the test function, isused
primarily to destroy any noncacheable server resourcesused by the test, and to free any memory that wasdynamically
allocated by the client. Some tests, such as-modify1, -await, -abort, and -redefine, perform additional stepswithin the test
function inner loop, asrequired by the element being tested, or in an attempt to make the test more visually appealing.
Evaluating the performance of individual XIE elementsisnot assimple asmeasuring Core X drawing times. The XIE protocol
requireselementsto be embedded within photoflosin order to be exercised, and the minimum possible photoflo size istwo.
Thisimpliesthat it isimpossible to measure performance of a single element in isolationthe time it takesto run the flo
dependson what other elementsexist in the flo. Extrapolating performance of a single element (or technique) in a flo must
be done carefully, on a case-by-case basis, because in general, measured element performance dependson input image size,
data type, and other factors, all of which can be influenced by upstream flo elements. Note further that the number and type
of elementsin a flo can be influenced by the visualsavailable on the display, so even flo-flo comparisonson machineswith
different visualsmust be done with caution.
Many test labelscontain an abbreviated pipeline description. For instance, IP/IL/P/ED indicatesImportPhotomap, ImportLUT,
Point, and ExportDrawable. Pipelinesending in ED (ExportDrawable) often include hidden elementssuch asBandExtract,
ConvertToIndex, Dither, or Point to match the flo output to the screen visual. Pipelinesending in EP (ExportPhotomap) will
result in a blank window.
xieperf iscompatible with x11perfcomp(1), which isused to compare the outputsof different xieperf and x11perf runsin a
nice, tabular format. In xieperf you will need to use the -labels option (see the Options subsection), and provide the
resulting labelsfile to x11perfcomp(1) to obtain correct output. See the x11perfcomp(1) man pagesfor more detailson this.
xieperf
Part I: User Commands
646
OPTIONS
xieperf acceptsthe following options:
display host:dpy Specifieswhich display to use.
images <pat h> Normally, xieperf referencesimage fileslocated in the
directory images, which xieperf assumesislocated in your
current directory. If the images directory isnot in your current
directory, or the file hasbeen renamed, use thisoption to
specify itslocation.
timeout<s> Some testsrequire the reception of an event such asFloNotify
to continue, and may cause xieperf to hang should these
eventsnot be received. Thisoption allowsthe user to specify a
time-out value which, if exceeded, will cause xieperf to give
up waiting for an event, and continue on with the next test in
sequence. Should an event time-out, a warning message will be
printed to stderr. The default time-out value is60 seconds.
sync Runsthe testsin synchronousmode.
script <f i l e> Using thisoption givesthe user the ability to run a subset of
the available testsand control the number of timesthe testsare
executed on an individual basis. Thisisthought to be
especially useful for those running xieperf for demonstration
purposes. Using thisoption causesxieperf to read commands
specified in a script file, or from stdin if <file> is-. Testsare
specified by newline-terminated input linesof the form
command [-reps n ] [ -repeat m ]. Charactersfollowing and
including # are treated ascomments. See the -mkscript option.
repeat <n> Repeatseach test n times(by default each test isrun two
times). Thisoption may be used in script filesalso, in which
case the script file -repeat overridesthe command-line option.
time <s > Specifieshow long in secondseach test should be run (default
5 seconds).
depth <dept h> Use a visual with <depth> planesper pixel (default isthe
default visual).
GrayScale Use a GrayScale visual (default isthe default visual).
PseudoColor Use a PseudoColor visual (default isthe default visual).
StaticGray Use a StaticGray visual (default isthe default visual).
StaticColor Use a StaticColor visual (default isthe default visual).
TrueColor Use a TrueColor visual (default isthe default visual).
DirectColor Use a DirectColor visual (default isthe default visual).
WMSafe If xieperf must be run in a window manager environment, use
thisflag to make xieperf aware of this. If specified, xieperf
will create a window, identical to the size of the root window,
and all further windowscreated by xieperf will be transient
pop-up children of thiswindow. If thisflag isomitted, xieperf
will set the override_redirect attribute of all windowsto True
and will also do evil thingssuch ascalling XInstallColormap.
Using thisoption will cause the window manager to (hope-
fully) obey window geometry hintsspecified by xieperf.
647
showtechs Display a comprehensive list of techniques, by category,
indicating which of the techniquesare supported by the XIE
server.
showlabels Print test label to screen prior to calling any of the test code.
Thisallowsthe user to know which test isexecuting in case the
test hangsfor some reason.
showevents Be verbose when running event and error tests. Also, can be
used to catch and display information on any signalsreceived
during execution of xieperf. Note that thisflag isbest used in
a debugging situation, or to validate that the error events
received by xieperf are valid the first time the testsare
executed on a new platform.
events Run teststhat test for event generation.
errors Run teststhat test for error event generation.
loCal Skip test calibration. Thismay be used when running xieperf
in situationswhere execution timing isnot important.
Execution timeswill not be reported by xieperf when this
option isenabled. The inner loop repeat count, additionally, is
set to a value of 5 (but can be overridden by the -reps option).
all Runsall tests. Thismay take a while, depending on the speed
of your machine, and itsfloating-point capabilities. This
option isignored if a script file isused.
tests Generate a list of the available testsfor the xieperf program.
In x11perf, thislist isnormally displayed in the usage
statement. It wasyanked from the usage of xieperf because it
wastoo lengthy.
mkscript Generate a script file suitable for use with the script option. If
-repeat or -reps are also specified, they will be automatically
placed at the end of each command in the script. The script is
generated to stderr. See the -script command, above.
cache <n> Most test flosutilize a photomap resource for a source. A
photomap cache of up to n entriesiscontrolled by xieperf to
avoid having to constantly reload these imagesduring test
initialization. The default cache size is4. If a value lessthan the
default isspecified, the cache size will be set to the default.
labels Generatesjust the descriptive labelsfor each test specified. Use
-all or -range to specify which testsare included. See
x11perfcomp(1) for more details.
DIS Pretend we are running xieperf while connected to a DIS-only
capable implementation of XIE. Thiswill cause xieperf to
execute those teststhat only use protocol requestsfound in the
DIS subset of XIE, and bypassthose which are not DIS-
compatible. If xieperf detectsa DIS server, it will do this
automatically, and thisoption isignored. Use -all or -range to
specify the initial range of tests.
range <t est 1>[,<t est 2>] Runsall the testsstarting from the specified name test1 until
the name test2, including both the specified tests. Some tests,
like the event and error tests, also require the -errors or -
events optionsto specified. Thisoption isignored if a script is
used.
xieperf
Part I: User Commands
648
reps <n> Fix the inner loop repetitionsto n. Thisindicateshow many
timesthe photoflo will be executed each time the test isrun.
Thisoption isoverridden on a per test basisif specified in a
script. Typically, xieperf determinesthe ideal number of reps
during each testscalibration period.
ImportObscuredEvent Test generation of events. Requires-events flag.
through ExportAvailable
BadValue through Test generation of errors. Requires-errors flag.
FloValueError
-ColorList Create anddestroy ColorList resource test.
LUT Create and destroy LUT resource test.
Photomap Create and destroy Photomap resource test.
ROI Create and destroy ROI resource test.
Photospace Create and destroy Photospace test.
Photoflo Create and destroy Photoflo test.
QueryPhotomap Query Photomap resource test.
QueryColorList Query ColorList resource test.
QueryTechniquesDefault Query techniquesasspecified by test name.
through QueryTechniques
WhiteAdjust
QueryPhotoflo Query Photoflo test.
PurgeColorList Purge ColorList test.
Abort Thistest createsa photoflo that isstarted and blocksfor data
provided by PutClientData(). Instead of sending the data, the
test usesXieAbort() to stop the photoflo, and then waitsfor
the PhotofloDone event to be sent by the server. If the test times
out waiting for the event, an error message issent to stderr.
Await Thistest createsa flo of the form ImportClientLUT ->
ExportLUT, and startsthe flo executing. xieperf then forks, and
the child processstreamsthe LUT data to the flo using
PutClientData, while the parent blocksin XieAwait. If the flo
successfully finishes, XieAwait will return and the flo state, after
query, will indicate that it hascompleted. If XieAwait doesnot
complete naturally, or after return from XieAwait the flo isstill
active, an error isreported to stderr. Note, on a really slow
machine, it ispossible that XieAwait will return before the flo
hasa chance to finish. In thiscase, use the -timeout option to
increase the time-out for thistest.
importclientlut1 ImportClientLUT -> ExportLUT test.
importclientphoto1 through Flosof the form ImportClient-Photo -> ExportPhotomap using
importclientphoto9 variousdecode techniques, for example, G32D, TIFF2,
UncompressedTriple.
importclientroi1 ImportClientROI with 10 rectangles.
importclientroi2 ImportClientROI with 100 rectangles.
encodephoto1 through Flosof the form ImportPhotomap - ExportPhotomap using
encodephoto14 variousencode techniques, for example G32D, TIFF2,
UncompressedTriple. Original encoding isshown in left
window; image after encoding isshown in right window.
649
encodeclientphoto1 through Two flos, one of the form ImportPhotomap ->
encodeclientphoto11 ExportClientPhoto, and the other of the form
ImportClientPhoto -> ExportPhotomap, where
ExportClientPhoto in the first flo usesvariousencode
techniques, for example G32D, TIFF2, UncompressedTriple. The
image before encoding isdisplayed in the left window, while
the right window showsthe image that wasencoded in the
first flo and read back in the second flo.
exportclientlut1 ExportClientLUT test. LUT isdisplayed in a histogram window.
exportclientroi1 ExportClientROI test, 10 ROIs. The ROIsthat are sent to the
server are represented by the filled rectangles. The ROIsthat
are received back from the server by the client are drawn as
white-bordered, nonfilled rectangles. The resulting output
illustrateshow the server combined the rectanglessent to it.
exportclientroi2 Same asexportclientroi1, except using 100 rectangles.
exportclienthistogram1 ExportClientHistogram testsusing variousimages. The
through histogram isdisplayed in a window that overlapsthe image.
exportclienthistogram4
exportclienthistogramroi1 Same asthe ExportClientHistogram test, but using a ROI
through to identify the area of interest.
exportclienthistogramroi4
exportclienthistogramcplane1 Same asthe ExportClientHistogram test, but using a
through control plane to identify the area of interest.
exportclienthistogramcplane4
importlut1 Test ImportLUT element; LUT size is256.
importphoto1 ImportPhotomap -> ExportPhotomap, with source and destina-
tion equal.
importphoto2 ImportPhotomap -> ExportDrawable, window destination.
importroi1 ImportROI -> ExportROI, 10 rectangles, source and destination
ROIsequal.
importroi2 ImportROI -> ExportROI, 100 rectangles, source and destination
ROIsequal.
importdrawable1 ImportDrawable -> ExportDrawable, source ispixmap,
destination iswindow.
importdrawable2 ImportDrawable -> ExportDrawable, source and destination are
both window.
importdrawable3 ImportDrawable -> ExportDrawable, destination window
obscured by source window.
importdrawable4 ImportDrawable -> ExportDrawable, source window obscured
by destination window.
importdrawable5 ImportDrawablePlane -> ExportDrawablePlane, pixmap, source
= destination.
importdrawable6 ImportDrawablePlane -> ExportDrawablePlane, window, source
= destination.
importdrawable7 ImportDrawablePlane -> ExportDrawablePlane, window, source
obscuresdestination.
importdrawable8 ImportDrawablePlane -> ExportDrawablePlane, window,
destination obscuressource.
constrain1 Constrain HardClip technique test, drawable destination.
xieperf
Part I: User Commands
650
constrain2 Constrain ClipScale technique test, drawable destination.
constrainphoto1 Constrain HardClip technique test, photomap destination.
constrainphoto2 Constrain ClipScale technique test, photomap destination.
convolve1 Boxcar 33 convolution test. Smoothing or lowpassfilter.
convolve2 Boxcar 55 convolution test. Smoothing or lowpassfilter.
convolve3 LaPlacian 33 convolution test. Edge or highpassfilter.
convolve4 LaPlacian 55 convolution test. Edge or highpassfilter.
convolveroi1 LaPlacian 33 convolution test, with ROI.
convolveroi2 LaPlacian 55 convolution test, with ROI.
convolvecplane1 LaPlacian 33 convolution test, with control plane.
convolvecplane2 LaPlacian 55 convolution test, with control plane.
math1 through mathcplane7 Variousteststhat exercise the math element, some testsusing
ROIsand control planes.
arithmeticdyadic1 through Arithmetic element tests, using photomaps
arithmeticdyadic5 asthe operands.
arithmeticmonadic1 through Arithmetic element tests, photomap and constant operands.
arithmeticmonadic9
arithmeticdyadicroi1 Arithmetic element tests, using photomaps asthe
through operands, with ROIs.
arithmeticdyadicroi5
arithmeticmonadicroi1 Arithmetic element tests, photomap and
through constant operands, with ROIs.
arithmeticmonadicroi9
arithmeticdyadiccplane1 Arithmetic element tests, using photomapsasthe
through operands, with control planes.
arithmeticdyadiccplane5
arithmeticmonadiccplane1 Arithmetic element tests, photomap and constant
through operands, with control planes.
arithmeticmonadiccplane9
arithmeticfloatdyadic1 Arithmetic element tests, using photomaps
though asthe operands, unconstrained.
arithmeticfloatdyadic5
arithmeticfloatmonadic1 Arithmetic element tests, photomap and constant
though operands, unconstrained.
arithmeticfloatmonadic9
arithmeticroifloatdyadic1 Arithmetic element tests, photomapsasthe
to operands, ROIs, unconstrained.
arithmeticroifloatdyadic5
arithmeticroifloatmonadic1 Arithmetic element tests, photomap and
to constant operands, ROIs, unconstrained.
-rithmeticroifloatmonadic9
band1 BandSelect element test. Image input istriple band. If visual of
xieperf window isa color visual, then three Band-Select
elementsare used to extract the individual bands; they are
combined once again using BandCombine, and displayed using
ConvertToIndex. If the visual isnot color, for example,
GrayScale or StaticGray, then the flo simply usesone
BandSelect element to extract a single band for display.
651
band2 BandCombine test. Input bandsare made of three separate single
band photomaps. These are combined using a BandCombine
element, which isfollowed by a BandExtract and
ExportDrawable. CCIR 601-1 coefficients.
band3 BandExtract test. Input isa triple band photomap. CCIR
601-1 coefficients. Destination window colormap isgray ramp.
band4 BandExtract test. Input isa triple band photomap. CCIR
601-1 coefficients. Destination window colormap isRGB BEST
MAP standard colormap.
band5 BandExtract test. Input isa triple band photomap. CCIR
601-1 coefficients. Destination window colormap is
RGB_DEFAULT_MAP standard colormap.
comparedyadic1 through Test variouscompare operatorswith dyadic
comparedyadic6 photomap operands.
comparemonadic1 through Test variouscompare operatorswith photomap,
comparemonadic6 constant operands.
compareroidyadic1 through Test variouscompare operatorswith dyadic photomap
compareroidyadic6 operands, using ROIs.
compareroimonadic1 through Test variousoperatorswith photomap,
compare compareroimonadic6 constant operands, using ROIs.
comparecplanedyadic1 Test variouscompare operatorswith dyadic
through photomap operands, control planes.
comparecplanedyadic6
comparecplanemonadic1 Test variouscompare operatorswith photomap,
through constant operands, control planes.
comparecplanemonadic6
matchhistogram1 MatchHistogram element tests, using various
through imagesand histogram matching techniques.
matchhistogram18
matchhistogramroi1 A selection of MatchHistogram element
through tests, with ROIs.
matchhistogramroi6
matchhistogramcplane1 A selection of MatchHistogram element
through tests, with control planes.
matchhistogramcplane6
unconstrain1 ImportPhotomap, Unconstrain, Constrain(ClipScale),
ExportDrawable test.
pasteup1 through pasteup2 PasteUp element tests.
geometry1 through Geometry element tests, including rotations, scales,
geometry14 and mirroring. NearestNeighbor technique.
geometry15 through Geometry element tests, including rotations, scales,
geometry28 and mirroring. AntiAlias technique.
geometry29 through Geometry element tests, including rotations, scales,
geometry42 and mirroring. BilinearInterpolation technique.
geomg31dscale1 through Teststo exercise the variousFAX decodersand
geometryfaxradio1 the Geometry element.
dither1 Dither test, ErrorDiffusion dither technique, ExportDrawable.
dither2 Dither test, ErrorDiffusion dither technique,
ExportDrawablePlane.
xieperf
Part I: User Commands
652
dither3 Dither test, Ordered(4) dither technique, ExportDrawable.
dither4 Dither test, Ordered(4) dither technique, ExportDrawablePlane.
dither5 Dither test, Ordered(8) dither technique, ExportDrawable.
dither6 Dither test, Ordered(8) dither technique, ExportDrawablePlane.
dither7 Dither test, Default dither technique, ExportDrawable.
dither8 Dither test, Default dither technique, ExportDrawablePlane.
logicalmonadic1 through Logical element, photomap and a constant
logicalmonadic16 of 0 asoperands, variousoperators.
logicaldyadic1 through Logical element tests, dyadic photomapsas
logicaldyadic16 operands, variousoperators.
logicalmonadicroi1 through Logical element, photomap and constant of
logicalmonadicroi16 0 operands, variousoperators, ROIs.
logicaldyadicroi1 through Logical element, dyadic photomapsasoperands, various
logicaldyadicroi16 operators, ROIs.
logicalmonadiccplane1 Logical element, photomap and constant of 0
through operands, variousoperators, Control Planes.
logicalmonadiccplane16
logicaldyadiccplane1 Logical element, dyadic photomapsasoperands,
through variousoperators, control planes.
logicaldyadiccplane16
blend1 Blend element test. Monadic source, 0.1 source constant.
Alpha constant of 0.5.
blend2 Blend element test. Dyadic sources. Alpha constant of 0.5.
blendroi1 Blend test. Monadic source, 0.1 source constant. Alpha
constant of 0.5. ROIs.
blendroi2 Blend element test. Dyadic sources. Alpha constant of 0.5.
UsesROIs.
blendcplane1 Blend test. Monadic source, 0.1 source constant. Alpha
constant of 0.5. control plane.
blendcplane2 Blend element test. Dyadic sources. Alpha constant of 0.5.
control plane.
blendalpha1 Blend test. Monadic source, 220 source constant. Alpha plane
isa photomap.
blendalpha2 Blend test. Dyadic sources. Alpha plane isa constant 220.
blendalpharoi1 Blend test. Monadic source, 220 source constant. Alpha plane
photomap. ROIs.
blendalpharoi2 Blend test. Dyadic sources. Alpha plane isa constant 220.
ROIs.
triplepoint1 through Illustrate use of point and standard colormaps
triplepoint2 for rendering triple band images.
funnyencode1 through These testsare designed to perform limited exercising of XIEs
funnyencode8 capability of dealing with variousencodingsof flo source data.
The test init function obtainsa photomap using ICP -> EP. A
seriesof independent permanent flo pairs, one of the form IP
-> EP, and the other of the basic form IP -> ED, are con-
structed. The encoding parametersfor the ExportPhotomap (EP)
element in the first flo are derived from test configuration. The
number of flo pairscreated isalso dependent upon test
653
configuration. The testscan be configured so that the test init
function will constrain the input photomap to a specified
number of levels, on a per band basis, so that word-sized and
quad-sized pixelsare passed through the flos. Some testsbelow
take advantage of this. See tests.c for test configuration, and
hintson how to add similar tests.
point1 through point3 Simple Point element tests. Drawable destination.
pointroi1 Simple Point element test that usesROIs. Drawable destination.
pointcplane1 Simple Point element test that usesa control plane. Drawable
destination.
pointphoto1 Simple Point element test. Photomap destination.
pointroiphoto1 Simple Point element test that usesROIs. Photomap
destination.
pointcplanephoto1 Simple Point element test that usesa control plane. Photomap
destination.
redefine Two flographsare created that are the same in structure,
except for the x and y offsetsspecified for the ExportDrawable
flo elements. The test init function createsa photoflo based
upon one of the two flographs. The inner loop of the test
function usesXieRedefinePhotoflo() to alternate between each
of the flographs. Make sure that your inner loop repsare 2 or
greater in order to exercise thistest fully (see -reps).
modify1 Test XieModifyPhotoflo() by adjusting ROI offsetsand size.
modify2 Test XieModifyPhotoflo() by changing the LUT input to a
Point element.
modify3 Test XieModifyPhotoflo() by changing ExportDrawable x and y
offsets.
modify4 Thistest createsa rather long flo of arithmetic elements, each
of which doesnothing more than add 1 to a small image. The
test init function scalesthe input photomap. The
ExportDrawable x and y offset ismodified randomly during
each iteration of the test function inner loop.
modify5 Thistest createsa rather long flo of arithmetic elements, each
of which doesnothing more than add 1 to a large image. Each
rep, the Geometry and ExportDrawable elementsat the end of
the flo are modified to crop a small piece of the input into its
appropriate place in the larger image.
rgb1 through rgb16 These testsall basically take an UncompressedTriple image as
input, send it to ConvertFromRGB, which convertsthe image to
some configured colorspace, and then send the converted
image on to ConvertToRGB prior to display. The original image
isdisplayed in the left-hand window, and the image that has
passed through the flo isshown in the right-hand window.
The goal of these test isto show that ConvertFromRGB ->
ConvertToRGB islossless.
converttoindexpixel ConvertToIndex test, TripleBand BandByPixel.
converttoindexplane ConvertToIndex test, TripleBand BandByPlane.
xieperf
Part I: User Commands
654
convertfromindex The test init function usesa flo containing ConvertToIndex to
display an image in the left window. The test function uses
thisdrawable asinput to a flo that doesConvertFromIndex ->
ConvertToIndex and sendsthe resulting image to the right
window. The result should be lossless.
complex A somewhat large flo that usescontrol planes, LUTs, Point,
PasteUp, Logical, Constrain, Dither, Geometry, MatchHistogram,
BandCombine, and BandSelect elements. See the Postscript file
complex.ps for a rendition of the photoflo that isexecuted.
X DEFAULTS
There are no X defaultsused by thisprogram.
SEE ALSO
X(1), x11perf(1), x11perfcomp(1)
BUGS
There should be an IMAGES environment variable to augment the -images option.
Many testsonly scratch the surface of possible test cases. Some of the optionsavailable for certain flo elementsare either
inadequately tested, or ignored altogether. There are insufficient testsfor bitonal, large pixel, or triple band tests.
Some of the test namesare inconsistently cased, for example, -Abort and -dither1.
Some testsare hopelessly slow when run against machineswith slow FPUs.
Bitonal imagesare, for the most part, displayed using the ExportDrawable flo element; however, ExportDrawablePlane would
be a better choice.
AUTHOR
Syd Logan (AGE Logic, Inc.)
X Version 11 Release6
ximtoppm
ximtoppmConvert an XIM file into a portable pixmap
SYNOPSIS
ximtoppm [xi mf i l e]
DESCRIPTION
Readsan Xim file asinput. Producesa portable pixmap asoutput. The Xim toolkit isincluded in the contrib tree of the
X.V11R4 release.
SEE ALSO
ppm(5)
AUTHOR
Copyright (c) 1991 by Jef Poskanzer.
25 March 1990
655
xinetd
xinetdThe extended Internet servicesdaemon
SYNOPSIS
xinetd [opt i ons]
DESCRIPTION
xinetd performsthe same function asinetd: it startsprogramsthat provide Internet services. Instead of having such servers
started at system initialization time, and be dormant until a connection request arrives, xinetd isthe only daemon process
started and it listenson all service portsfor the serviceslisted in itsconfiguration file. When a request comesin, xinetd starts
the appropriate server. Because of the way it operates, xinetd (aswell asinetd) isalso referred to asa super-server.
The serviceslisted in xinetdsconfiguration file can be separated into two groups. Servicesin the first group are called
multithreaded and they require the forking of a new server processfor each new connection request. The new server then
handlesthat connection. For such services, xinetd keepslistening for new requestsso that it can spawn new servers. On the
other hand, the second group includesservicesfor which the service daemon isresponsible for handling all new connection
requests. Such servicesare called single-threaded and xinetd will stop handling new requestsfor them until the server dies.
Servicesin thisgroup are usually datagram based.
So far, the only reason for the existence of a super-server wasto conserve system resourcesby avoiding to fork a lot of
processeswho might be dormant for most of their lifetime. While fulfilling thisfunction, xinetd takesadvantage of the idea
of a super-server to provide featuressuch asaccesscontrol and logging. Furthermore, xinetd isnot limited to serviceslisted in
/etc/services. Therefore, anybody can use xinetd to start special-purpose servers.
OPTIONS
d Enablesdebug mode. Thisproducesa lot of debugging
output, and it makesit possible to use a debugger on xinetd.
syslog sysl og_f aci l i t y Thisoption enablessyslog logging of xinetd-produced
messagesusing the specified syslog facility. The following
facility namesare supported: daemon, auth, user, local[0-7]
(check syslog.conf(5) for their meanings). Thisoption is
ineffective in debug mode because all relevant messagesare
sent to the terminal.
filelog l ogf i l e xinetd-produced messageswill be placed in the specified file.
Messagesare alwaysappended to the file. If the file doesnot
exist, it will be created. Thisoption isineffective in debug
mode because all relevant messagesare sent to the terminal.
f config_file Determinesthe file that xinetd usesfor configuration. The
default is/etc/xinetd.conf.
pid The processpid iswritten to standard error. Thisoption is
ineffective in debug mode.
loop r at e Thisoption setsthe loop rate beyond which a service is
considered in error and isdeactivated. The loop rate is
specified in termsof the number of serversper second that can
be forked for a process. The speed of your machine determines
the correct value for thisoption. The default rate is10.
reuse If thisoption isused, xinetd will set the socket option
SO_REUSEADDR before binding the service socket to an Internet
address. Thisallowsbinding of the addresseven if there are
programsthat use it, which happenswhen a previousinstance
of xinetd hasstarted some serversthat are still running. This
option hasno effect on RPC services.
xinetd
Part I: User Commands
656
limit pr oc_l i mi t Thisoption placesa limit on the number of concurrently
running processesthat can be started by xinetd. Itspurpose is
to prevent processtable overflows.
logprocs l i mi t Thisoption placesa limit on the number of concurrently
running serversfor remote user ID acquisition.
shutdownprocs l i mi t Thisoption placesa limit on the number of concurrently
running serversfor service shutdown (forked when the RECORD
option isused).
The syslog and filelog optionsare mutually exclusive. If none isspecified, the default issyslog using the daemon facility.
You should not confuse xinetd messageswith messagesrelated to service logging. The latter are logged only if thisisspecified
via the configuration file.
CONFIGURATION FILE
The configuration file determinesthe servicesprovided by xinetd. Any line whose first nonwhitespace character isa # is
considered a comment line. Empty linesare ignored.
The file containsentriesof the form:
service <service_name>
{
<attribute> <assign_op><value><value> ...
...
}
The assignment operator, assign_op, can be one of =, +=, -=. The majority of attributessupport only the simple assignment
operator, =. Attributeswhose value isa set of valuessupport all assignment operators. For such attributes, += meansadding a
value to the set and -= meansremoving a value from the set. A list of these attributesisgiven after all the attributesare
described.
Each entry definesa service identified by the service_name. The following isa list of available attributes:
id Thisattribute isused to uniquely identify a service. Thisis
useful because there exist servicesthat can use different
protocolsand need to be described with different entriesin the
configuration file. By default, the service id isthe same asthe
service name.
type Possible valuesare the following:
RPC If thisisan RPC service
INTERNAL If thisisa service provided by xinetd.
UNLISTED If thisisa service not listed in /etc/services.
flags Possible flag valuesare
REUSE Set the SO_REUSEADDR flag on the service socket.
INTERCEPT Intercept packetsor accepted connectionsin
order to verify that they are coming from
acceptable locations(internal or multithreaded
servicescannot be intercepted).
NORETRY Avoid retry attemptsin case of fork failure.
socket type Possible valuesare
stream Stream-based service
dgram Datagram-based service
raw Service that requiresdirect accessto IP
seqpacket Service that requiresreliable sequential
datagram transmission
657
protocol Determinesthe protocol that isemployed by the service. The
protocol must exist in /etc/protocols. If thisattribute isnot
defined, the default protocol employed by the service will be
used.
wait Thisattribute determinesif the service issingle-threaded or
multithreaded. If itsvalue isyes, the service issingle-threaded;
thismeansthat xinetd will start the server and then it will stop
handling requestsfor the service until the server dies. If the
attribute value isno, the service ismultithreaded and xinetd
will keep handling new service requests.
user Determinesthe uid for the server process. The username must
exist in /etc/passwd. Thisattribute isineffective if the effective
user ID of xinetd isnot super-user.
group Determinesthe gid for the server process. The group name
must exist in /etc/group. If a group isnot specified, the group
of user will be used (from /etc/passwd). Thisattribute is
ineffective if the effective user ID of xinetd isnot super-user.
instances Determinesthe number of serversthat can be simultaneously
active for a service. By default, there isno limit. The value of
thisattribute can be either a number or UNLIMITED, which
meansthat there isno limit.
server Determinesthe program to execute for thisservice.
server_args Determinesthe argumentspassed to the server. In contrast to
inetd, the server name should not be included in server_args.
only_from Determinesthe remote hoststo which the particular service is
available. Itsvalue isa list of IP addressesthat can be specified
in any combination of the following ways:
a) A numeric addressin the form of %d.%d.%d.%d. If the
rightmost componentsare 0, they are treated aswildcards
(for example, 128.138.12.0 matchesall hostson the
128.138.12 subnet). 0.0.0.0 matchesall Internet addresses.
b) A factorized addressin the form of %d.%d.%d.{%d,%d,...}.
There isno need for all four components
(%d.%d.{%d,%d,...%d} isalso OK). However, the factorized
part must be at the end of the address.
c) A network name (from /etc/networks).
d) A hostname. All IP addressesof the specified hostname will
be used.
Specifying thisattribute without a value makesthe service
available to nobody.
no_access Determinesthe remote hoststo which the particular service is
unavailable. Itsvalue can be specified in the same way asthe
value of the only from attribute. These two attributes
determine the location accesscontrol enforced by xinetd. If
none of the two isspecified for a service, the service isavailable
to anyone. If both are specified for a service, the one that isthe
better match for the addressof the remote host determinesif
the service isavailable to that host (for example, if the only
from list contains128.138.209.0 and the no accesslist contains
128.138.209.10, then the host with the address128.138.209.10
can not accessthe service).
xinetd
Part I: User Commands
658
access_times Determinesthe time intervalswhen the service isavailable. An
interval hasthe form hour : mi n- hour : mi n (connectionswill be
accepted at the boundsof an interval). Hourscan range from 0
to 23 and minutesfrom 0 to 59.
log_type Determineswhere the service log output issent. There are two
formats:
SYSLOG syslog The log output issent to syslog at
facility the specified facility. If a level
[syslog level] ispresent, the messageswill be recorded at
that level instead of LOG_INFO (which isthe
default level).
FILE f i l e The log output isappended to f i l e,
[soft_limit which will be created if it does
[hard_limit]] not exist. Two limitson the size of the log
file can be optionally specified. The first
limit isa soft one; xinetd will log a message
the first time thislimit isexceeded (if xinetd
logsto syslog, the message will be sent at
the LOG_ALERT priority level). The second
limit isa hard limit; xinetd will stop logging
for the affected service (if the log file isa
common log file, then more than one service
may be affected) and will log a message
about this(if xinetd logsto syslog, the
message will be sent at the LOG_ALERT priority
level). If a hard limit isnot specified, it
defaultsto the soft limit increased by 1
percent but the extra size must be within the
parametersLOG_EXTRA_MIN and LOG_EXTRA_MAX
(defined in config.h).
log_on_success Determineswhat information islogged when a server isstarted
and when that server exits(the service ID isalwaysincluded in
the log entry). Any combination of the following valuesmay
be specified:
PID Logsthe server processID. (If the service is
implemented by xinetd without forking another
process, the logged processID will be 0.)
HOST Logsthe remote host address
TIME Logsthe time when the server wasstarted.
USERID Logsthe user ID of the remote user using the
RFC 931 identification protocol. Thisoption is
available only for multithreaded stream services.
EXIT Logsthe fact that a server exited along with the
exit statusor the termination signal (the process
ID isalso logged if the PID option isused).
DURATION Logsthe duration of a service session.
log_on_failure Determineswhat information islogged when a server cannot
be started (either because of a lack of resourcesor because of
accesscontrol restrictions). The service ID isalwaysincluded
in the log entry along with the reason for failure. Any
combination of the following valuesmay be specified:
HOST Logsthe remote host address.
659
TIME Logsthe time when the server wasstarted.
USERID Logsthe user ID of the remote user using the RFC
931 identification protocol. Thisoption isavailable
only for multithreaded stream services.
ATTEMPT Logsthe fact that a failed attempt wasmade.
RECORD Recordsinformation from the remote end in case
the server could not be started. Thisallows
monitoring of attemptsto use the service. For
example, the login service logsthe local user,
remote user, and terminal type. Currently, the
servicesthat support thisoption are logiun, shell,
exec, finger.
rpc_version Determinesthe RPC version for an RPC service. The version
can be a single number or a range in the form number-
number.
env The value of thisattribute isa list of stringsof the form
name=value. These stringswill be added to the environment
before starting a server (therefore the serversenvironment will
include xinetds environment plusthe specified strings).
passenv The value of thisattribute isa list of environment variables
from xinetdsenvironment that will be passed to the server.
port Determinesthe service port. If thisattribute isspecified for a
service listed in /etc/services, it must be equal to the port
number listed in that file.
You dont need to specify all of the preceding attributesfor each service. The necessary attributesfor a service are the
following:
socket type
user (non-unlisted servicesonly)
server (non-internal servicesonly)
wait
protocol (RPC and unlisted servicesonly)
rpc_version (RPC servicesonly)
port (unlisted servicesonly)
The following attributessupport all assignment operators, except asindicated:
only_from
no_access
log_on_success
log_on_failure
passenv
env (doesnot support the -= operator)
These attributescan also appear more than once in a service entry. The remaining attributessupport only the = operator and
can appear at most once in a service entry.
The configuration file may also contain a single defaultsentry that hasthe form:
defaults
{
<attribute> = <value><value> ...
...
}
xinetd
Part I: User Commands
660
Thisentry providesdefault attribute valuesfor service entriesthat dont specify those attributes. Possible default attributes:
log_type
log_on_success (cumulative effect)
log_on_failure (cumulative effect)
only_from (cumulative effect)
no_access (cumulative effect)
passenv (cumulative effect)
instances
disabled (cumulative effect)
Attributeswith a cumulative effect can be specified multiple timeswith the valuesspecified each time accumulating (in other
words, = doesthe same thing as+=). With the exception of disabled they all have the same meaning asif they were specified
in a service entry. disabled determinesservicesthat are disabled even if they have entriesin the configuration file. Thisallows
for quick reconfiguration by specifying disabled serviceswith the disabled attribute instead of commenting them out. The
value of thisattribute isa list of space-separated service IDs.
INTERNAL SERVICES
xinetd providesthe following servicesinternally (both stream- and datagram-based): echo, time, daytime, chargen, and
discard. These servicesare under the same accessrestrictionsasall other servicesexcept for the onesthat dont require xinetd
to fork another processfor them. Those ones(time, daytime, and the datagram-based echo, chargen,and discard) have no
limitation in the number of instances.
CONTROLLING xinetd
xinetd performscertain actionswhen it receivescertain signals. The actionsassociated with the specific signalscan be
redefined by editing config.h and recompiling.
SIGUSR1 Causesa soft reconfiguration, which meansthat xinetd rereads
the configuration file and adjustsaccordingly.
SIGUSR2 Causesa hard reconfiguration, which isthe same asa soft
reconfiguration except that serversfor servicesthat are no
longer available are terminated. Accesscontrol isperformed
again on running serversby checking the remote location,
accesstimesand server instances. If the number of server
instancesislowered, some arbitrarily picked serverswill be
killed to satisfy the limit; thiswill happen after any serversare
terminated because of failing the remote location or access
time checks. Also, if the INTERCEPT flag wasclear and isset, any
running serversfor that service will be terminated; the purpose
of thisisto ensure that after a hard reconfiguration there will
be no running serversthat can accept packetsfrom addresses
that do not meet the accesscontrol criteria.
SIGQUIT Causesprogram termination.
SIGTERM Terminatesall running serversbefore terminating xinetd.
SIGHUP Causesan internal state dump (the default dump file is/tmp/
xinetd.dump; to change the filename, edit config.h and
recompile).
SIGIOT Causesan internal consistency check to verify that the data
structuresused by the program have not been corrupted.
When the check iscompleted xinetd will generate a message
that saysif the check wassuccessful or not.
661
On reconfiguration, the log filesare closed and reopened. Thisallowsremoval of old log files. Also, the following attributes
cannot be changed on reconfiguration: socket_type, wait, protocol, type.
xinetd LOG FORMAT
Log entriesare lineswith the following format:
ent r y: ser vi c e- i d dat a
The data dependson the entry. Possible entry types:
START Generated when a server isstarted
EXIT Generated when a server exits
FAIL Generated when it isnot possible to start a server
DATA Generated when an attempt to start a server failsand the
service supportsthe RECORD log option.
USERID Generated if the USERID log option isused.
In the following formats, the information enclosed in bracketsappearsif the appropriate log option isused.
A START entry hasthe format
START: ser vi ce- i d [pid=%d] [from=%d.%d.%d.%d] [time=t i me]
Time isgiven asyear/month/day@hour:minutes:seconds.
An EXIT entry hasthe format
EXIT: ser vi ce- i d [type=%d] [pid=%d] [duration=%d(sec)]
typecan be either statusor signal. The number iseither the exit statusor the signal that caused processtermination.
A FAIL entry hasthe format:
FAIL: ser vi ce- i d r eason [from=%d.%d.%d.%d] [time=t i me]
Possible reasonsare
fork A certain number of consecutive fork attemptsfailed (this
number isa configurable parameter).
time The time check failed.
address The addresscheck failed.
service_limit The allowed number of server instancesfor thisservice would
be exceeded.
process_limit A limit on the number of forked processeswasspecified and it
would be exceeded.
A DATA entry hasthe format
DATA: ser vi ce- i d dat a
The dat a logged dependson the service.
login remote_user=%s local_user=%s tty=%s
exec remote_user=%sverify=statuscommand=%sPossible status
values:
ok The password wascorrect
failed The password wasincorrect
baduser No such user
shell remote_user=%slocal_user=%scommand=%s
finger received string or EMPTY-LINE
xinetd
Part I: User Commands
662
A USERID entry hasthe format
USERID: t ext
The t ext isthe response of the RFC 931 daemon at the remote end excluding the port numbers(which are included in the
response). Heresan example:
#
# Sample configuration file for xinetd
#
defaults
{
log_type = FILE /var/log/servicelog
log_on_success = PID
log_on_failure = HOST TIME RECORD
only_from = 128.138.193.0 128.138.204.0 128.138.209.0
only_from = 128.138.252.1
instances = 10
disabled = rstatd
}
#
# Note 1: the protocol attribute is not required
# Note 2: the instances attribute overrides the default
#
service login
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/etc/in.rlogind
instances = UNLIMITED
}
#
# Note 1: the instances attribute overrides the default
# Note 2: the log on success flags are augmented
#
service shell
{
socket_type = stream
wait = no
user = root
instances = UNLIMITED
server = /usr/etc/in.rshd
log_on_success += HOST TIME RECORD
}
service ftp
{
socket_type = stream
wait = no
user = root
server = /usr/etc/in.ftpd
server_args = -l
instances = 4
log_on_success += DURATION HOST USERID
access_times = 2:00-9:00 12:00-24:00
}
#
# This entry and the next one specify internal services. Since this
# is the same service using a different socket type, the id attribute
# is used to uniquely identify each entry
#
663
service echo
{
id = echo-stream
type = INTERNAL
socket_type = stream
user = root
wait = no
}
service echo
{
id = echo-dgram
type = INTERNAL
socket_type = dgram
user = root
wait = no
}
#
# Sample RPC service
#
service rstatd
f
type = RPC
socket_type = dgram
protocol = udp
server = /usr/etc/rpc.rstatd
wait = yes
user = root
rpc_version = 2-4
env = LD_LIBRARY_PATH=/etc/securelib
}
#
# Sample unlisted service
#
service unlisted
{
type = UNLISTED
socket_type = stream
protocol = tcp
wait = no
server = /home/user/some server
port = 20020
}
FILES
/etc/xinetd.conf Default configuration file
/tmp/xinetd.dump Default dump file
SEE ALSO
inetd(8)
Postel J., Echo Protocol, RFC 862, May 1983.
Postel J., Discard Protocol, RFC 863, May 1983.
Postel J., Character Generator Protocol , RFC 864, May 1983.
Postel J., DaytimeProtocol, RFC 867, May 1983.
Postel J., Harrenstien K., TimeProtocol, RFC 868, May 1983.
St. JohnsM., Authentication Server, RFC 931, January 1985.
xinit
Part I: User Commands
664
AUTHOR
PanosTsirigotis(CS Department, University of Colorado, Boulder)
NOTES
When the attributesonly_from and no_access are not specified for a service (either directly or via defaults), the addresscheck
isconsidered successful (that is, accesswill not be denied).
If the USERID log option isspecified and the remote RFC 931 server sendsback an ERROR reply, accesswill not be denied.
If the USERID log option isspecified and the remote host doesnot run an RFC 931 server, there will be no indication in the
log of that fact (other than the missing USERID log entry).
BUGS
Supplementary group IDsare not supported.
If the INTERCEPT flag isnot used, accesscontrol on the addressof the remote host isnot performed when wait isyes and
socket_type isstream.
If the INTERCEPT flag isnot used, accesscontrol on the addressof the remote host for serviceswhere wait isyes and
socket_type isdgram isperformed only on the first packet. The server may then accept packetsfrom hostsnot in the access
control list. Thiscan happen with RPC services.
Unlisted RPC servicesare not supported; that is, all RPC servicesmust be registered in /etc/rpc. Specifying an RPC service
by itsRPC program number isnot (yet) possible.
There isno way to put a SPACE in an environment variable.
When wait isyes and socket_type isstream, the socket passed to the server can only accept connections.
The INTERCEPT flag isnot supported for internal servicesor multithreaded services.
Interception worksby forking a processthat actsasa filter between the remote host(s) and the local server. Thisobviously
hasa performance impact which dependson the volume of information exchanged. It isup to you to make the compromise
between security and performance for each service.
PRONUNCIATION
xinetd ispronounced zy-net-d.
10 May1992
xinit
xinitX Window System initializer
SYNOPSIS
xinit [[cl i ent ] opt i ons ][ [ ser ver ][di spl ay ] opt i ons ]
DESCRIPTION
The xinit program isused to start the X Window System server and a first client program on systemsthat cannot start X
directly from /etc/init or in environmentsthat use multiple window systems. When thisfirst client exits, xinit will kill the
X server and then terminate.
If no specific client program isgiven on the command line, xinit will look for a file in the usershome directory called
.xinitrc to run asa shell script to start up client programs. If no such file exists, xinit will use the following asa default:
xterm geometry +1+1 n login display :0
665
If no specific server program isgiven on the command line, xinit will look for a file in the usershome directory called
.xserverrc to run asa shell script to start up the server. If no such file exists, xinit will use the following asa default:
X :0
Note that thisassumesthat there isa program named X in the current search path. However, serversare usually named
Xdisplaytype where displaytype isthe type of graphicsdisplay that isdriven by thisserver. The site administrator should,
therefore, make a link to the appropriate type of server on the machine, or create a shell script that runsxinit with the
appropriate server.
Note, when using a .xserverrc script be sure to mark the real X server asexec. Failing to do thiscan make the X server slow
to start and exit. For example
exec Xdisplaytype
An important point isthat programswhich are run by xinitrc should be run in the background if they do not exit right
away, so that they dont prevent other programsfrom starting up. However, the last long-lived program started (usually a
window manager or terminal emulator) should be left in the foreground so that the script wont exit (which indicatesthat
the user isdone and that xinit should exit).
An alternate client and/or server may be specified on the command line. The desired client program and itsarguments
should be given asthe first command-line argumentsto xinit.To specify a particular server command line, append two
dashes() to the xinit command line (after any client and arguments) followed by the desired server command.
Both the client program name and the server program name must begin with a slash (/) or a period (.). Otherwise, they are
treated asargumentsto be appended to their respective startup lines. Thismakesit possible to add arguments(for example,
foreground and background colors) without having to retype the whole command line.
If an explicit server name isnot given and the first argument following the double dash () isa colon followed by a digit,
xinit will use that number asthe display number instead of zero. All remaining argumentsare appended to the server
command line.
EXAMPLES
Following are several examplesof how command-line argumentsin xinit are used:
Thiswill start up a server named X and run the usersxinitrc, if it exists, or else start an xterm:
xinit
Thisishow one could start a specific type of server on an alternate display:
xinit /usr/X11R6/bin/Xqdss :1
Thiswill start up a server named X, and will append the given argumentsto the default xterm command (it will ignore
xinitrc):
xinit geometry =80x65+10+10 fn 8x13 j fg white bg navy
Thiswill use the command Xsun l c to start the server and will append the argumentse widgetsto the default xterm
command:
xinit e widgets ./Xsun l c
Thiswill start a server named X on display 1 with the argumentsa 2 t5:
xinit /usr/ucb/rsh fasthost cpupig display ws:1 :1 a 2 t 5
It will then start a remote shell on the machine fasthost in which it will run the command cpupig, telling it to display back on
the local workstation.
Following isa sample xinitrc that startsa clock, startsseveral terminals, and leavesthe window manager running asthe
last application. Assuming that the window manager hasbeen configured properly, the user then choosesthe Exit menu
item to shut down X.
xrdb load $HOME/.Xresources
xsetroot solid gray &
xinit
Part I: User Commands
666
xclock g 50x500+0 bw 0 &
xload g 50x5050+0 bw 0 &
xterm g 80x24+0+0 &
xterm g 80x24+00 &
twm
Sitesthat want to create a common startup environment could simply create a default xinitrc that referencesa site-wide
startup file:
#!/bin/sh
. /usr/local/lib/site.xinitrc
Another approach isto write a script that startsxinit with a specific shell script. Such scriptsare usually named x11, xstart,
or startx, and are a convenient way to provide a simple interface for novice users:
#!/bin/sh
xinit /usr/local/lib/site.xinitrc /usr/X11R6/bin/X bc
ENVIRONMENT VARIABLES
DISPLAY Thisvariable getsset to the name of the display to which
clientsshould connect.
XINITRC Thisvariable specifiesan init file containing shell commands
to start up the initial windows. By default, xinitrc in the
home directory will be used.
FILES
.xinitrc Default client script
xterm Client to run if .xinitrc doesnot exist
.xserverrc Default server script
X Server to run if .xserverrc doesnot exist
SEE ALSO
X(1), startx(1), Xserver(1), xterm(1)
AUTHOR
Bob Scheifler (MIT Laboratory for Computer Science)
X Version 11 Release6
xkill
xkillKill a client by itsX resource
SYNOPSIS
xkill [display di spl ayname] [id r esour ce] [button number] [frame] [all]
DESCRIPTION
xkill isa utility for forcing the X server to close connectionsto clients. Thisprogram isvery dangerous, but isuseful for
aborting programsthat have displayed undesired windowson a usersscreen. If no resource identifier isgiven with -id, xkill
will display a special cursor asa prompt for the user to select a window to be killed. If a pointer button ispressed over a
nonroot window, the server will close itsconnection to the client that created the window.
667
OPTIONS
display di spl ayname Thisoption specifiesthe name of the X server to contact.
id r esour ce Thisoption specifiesthe X identifier for the resource whose
creator isto be aborted. If no resource isspecified, xkill will
display a special cursor with which you should select a window
to be kill.
button number Thisoption specifiesthe number of pointer button that should
be used in selecting a window to kill. If the word any is
specified, any button on the pointer may be used. By default,
the first button in the pointer map (which isusually the
leftmost button) isused.
all Thisoption indicatesthat all clientswith top-level windowson
the screen should be killed. xkill will ask you to select the root
window with each of the currently defined buttonsto give you
several chancesto abort. Use of thisoption ishighly discour-
aged.
frame Thisoption indicatesthat xkill should ignore the standard
conventionsfor finding top-level client windows(which are
typically nested inside a window manager window), and
simply believe that you want to kill direct children of the root.
XDEFAULTS
Button Specifiesa specific pointer button number or the word any
to use when selecting windows.
SEE ALSO
X(1), xwininfo(1), XKillClient and XGetPointerMapping in the Xlib ProgrammersManual, KillClient in the X Protocol
Specification
AUTHOR
Jim Fulton (MIT X Consortium) and Dana Chee (Bellcore)
X Version 11 Release6
xlogo
xlogoX Window System logo
SYNOPSIS
xlogo [-t ool ki t opt i on ...]
DESCRIPTION
The xlogo program displaysthe X Window System logo.
OPTIONS
Xlogo acceptsall of the standard X Toolkit command-line options, aswell asthe following:
shape Thisoption indicatesthat the logo window should be shaped
rather than rectangular.
xlogo
Part I: User Commands
668
RESOURCES
The default width and the default height are each 100 pixels. Thisprogram usesthe Logo widget in the Athena widget set. It
understandsall of the Simple widget resource namesand classesaswell as:
foreground (class Foreground) Specifiesthe color for the logo. The default dependson
whether reverseVideo isspecified. If reverseVideo isspecified,
the default isXtDefaultForeground, otherwise the default is
XtDefaultBackground.
shapeWindow (class ShapeWindow) Specifiesthat the window isshaped to the X logo. The default
isFalse.
WIDGETS
In order to specify resources, it isuseful to know the hierarchy of the widgetsthat compose xlogo.In the following notation,
indentation indicateshierarchical structure. The widget classname isgiven first, followed by the widget instance name.
XLogo xlogo
Logo xlogo
ENVIRONMENT
DISPLAY To get the default host and display number.
XENVIRONMENT To get the name of a resource file that overridesthe global
resourcesstored in the RESOURCE_MANAGER property.
FILES
<XRoot>/lib/X11/app-defaults/XLogo Specifiesrequired resources
SEE ALSO
X(1), xrdb(1)
AUTHORS
Ollie Jonesof Apollo Computer and Jim Fulton of the MIT X Consortium wrote the logo graphicsroutine, based on a
graphic design by Danny Chong and RossChapman of Apollo Computer.
X Version 11 Release6
xlsatoms
xlsatomsList interned atomsdefined on server
SYNOPSIS
xlsatoms [-options ...]
DESCRIPTION
xlsatoms liststhe interned atoms. By default, all atomsstarting from 1 (the lowest atom value defined by the protocol) are
listed until unknown atom isfound. If an explicit range isgiven, xlsatoms will try all atomsin the range, regardlessof
whether or not any are undefined.
669
OPTIONS
display dpy Thisoption specifiesthe X server to which to connect.
format st r i ng Thisoption specifiesa printf-style string used to list each
atom <value,name> pair, printed in that order (value isan
unsigned long and name isa char *). xlsatoms will supply a
newline at the end of each line. The default is%ld\t%s.
range [l ow]-[hi gh] Thisoption specifiesthe range of atom valuesto check. If l ow
isnot given, a value of 1 isassumed. If hi gh isnot given,
xlsatoms will stop at the first undefined atom at or above l ow.
name st r i ng Thisoption specifiesthe name of an atom to list. If the atom
doesnot exist, a message will be printed on the standard error.
SEE ALSO
X(1), Xserver(1), xprop(1)
ENVIRONMENT
DISPLAY To get the default host and display to use
AUTHOR
Jim Fulton (MIT X Consortium)
X Version 11 Release6
xlsclients
xlsclientsList client applicationsrunning on a display
SYNOPSIS
xlsclients [-display di spl ayname] [-a] [-l] [-m maxcmdlen]
DESCRIPTION
xlsclients isa utility for listing information about the client applicationsrunning on a display. It may be used to generate
scriptsrepresenting a snapshot of the userscurrent session.
OPTIONS
display di spl ayname Thisoption specifiesthe X server to contact.
a Thisoption indicatesthat clientson all screensshould be
listed. By default, only those clientson the default screen are
listed.
l List in long format, giving the window name, icon name, and
classhintsin addition to the machine name and command
string shown in the default format.
m maxcmdlen Thisoption specifiesthe maximum number of charactersin a
command to print out. The default is10000.
ENVIRONMENT
DISPLAY To get the default host, display number, and screen.
xlsclients
Part I: User Commands
670
SEE ALSO
X(1), xwininfo(1), xprop(1)
AUTHOR
Jim Fulton (MIT X Consortium)
X Version 11 Release6
xlsfonts
xlsfontsServer font list displayer for X
SYNOPSIS
xlsfonts [options ...] [fn pattern]
DESCRIPTION
xlsfonts liststhe fontsthat match the given pattern. The wildcard character * may be used to match any sequence of
characters(including none), and ? to match any single character. If no pattern isgiven, * isassumed.
The * and ? charactersmust be quoted to prevent them from being expanded by the shell.
OPTIONS
display host : dpy Thisoption specifiesthe X server to contact.
l Listssome attributesof the font on one line in addition to its
name.
ll Listsfont propertiesin addition to l output.
lll Listscharacter metricsin addition to ll output.
m Thisoption indicatesthat long listingsshould also print the
minimum and maximum boundsof each font.
C Thisoption indicatesthat listingsshould use multiple
columns. Thisisthe same asn 0.
1 Thisoption indicatesthat listingsshould use a single column.
Thisisthe same asn 1.
w wi dt h Thisoption specifiesthe width in charactersthat should be
used in figuring out how many columnsto print. The default
is79.
n col umns Thisoption specifiesthe number of columnsto use in
displaying the output. By default, it will attempt to fit asmany
columnsof font namesinto the number of character specified
by w wi dt h.
u Thisoption indicatesthat the output should be left unsorted.
o Thisoption indicatesthat xlsfonts should do an OpenFont
(and QueryFont, if appropriate) rather than a ListFonts. Thisis
useful if ListFonts or ListFontsWithInfo fail to list a known
font (asisthe case with some scaled font systems).
fn pat t er n Thisoption specifiesthe font name pattern to match.
SEE ALSO
X(1), Xserver(1), xset(1), xfd(1), X Logical Font Description Conventions
671
ENVIRONMENT
DISPLAY To get the default host and display to use
BUGS
Doing xlsfonts -l can tie up your server for a very long time. Thisisreally a bug with single-threaded nonpreemptable
servers, not with thisprogram.
AUTHOR
Mark Lillibridge (MIT Project Athena), Jim Fulton (MIT X Consortium), and Phil Karlton (SGI)
X Version 11 Release6
xmag
xmagMagnify partsof the screen
SYNOPSIS
xmag [ mag magf act or ][source geom ][t ool ki t opt i on ...]
DESCRIPTION
The xmag program allowsyou to magnify portionsof an X screen. If no explicit region isspecified, a square with the pointer
in the upper-left corner isdisplayed indicating the area to be enlarged. The area can be dragged out to the desired size by
pressing Button 2. After a region hasbeen selected, a window ispopped up showing a blown-up version of the region in
which each pixel in the source image isrepresented by a small square of the same color. Pressing Button 1 in the enlargement
window showsthe position and RGB value of the pixel under the pointer until the button isreleased. Typing Q or C in the
enlargement window exitsthe program. The application hasfive buttonsacrossitstop. Close deletesthisparticular
magnification instance. Replace bringsup the rubber band selector again to select another region for thismagnification
instance. New bringsup the rubber band selector to create a new magnification instance. Cut putsthe magnification image
into the primary selection. Paste copiesthe primary selection buffer into xmag. Note that you can cut and paste between xmag
and the bitmap program. Resizing xmag resizesthe magnification area. xmag preservesthe colormap, visual, and window depth
of the source.
WIDGETS
xmag usesthe X Toolkit and the Athena Widget Set. The magnified image isdisplayed in the Scale widget. For more
information, see the Athena Widget Set documentation. Following isthe widget structure of the xmag application. Indenta-
tion indicateshierarchical structure. The widget classname isgiven first, followed by the widget instance name.
Xmag xmag
RootWindow root
TopLevelShell xmag
Paned pane1
Paned pane2
Command close
Command replace
Command new
Command select
Command paste
Label xmag label
Paned pane2
Scale scale
OverrideShell pixShell
Label pixLabel
xmag
Part I: User Commands
672
OPTIONS
source geom Thisoption specifiesthe size and/or location of the source
region on the screen. By default, a 6464 square isprovided
for the user to select an area of the screen.
mag integer Thisoption indicatesthe magnification to be used. The
default is5.
AUTHORS
Dave Sternlicht and Davor Matic (MIT X Consortium)
X Version 11 Release6
xmkmf
xmkmfCreate a Makefile from an Imakefile
SYNOPSIS
xmkmf [-a][topdir [ curdir ]]
DESCRIPTION
The xmkmf command isthe normal way to create a Makefile from an Imakefile shipped with third-party software.
When invoked with no argumentsin a directory containing an Imakefile, the imake program isrun with arguments
appropriate for your system (configured into xmkmf when X wasbuilt) and generatesa Makefile.
When invoked with the a option, xmkmf buildsthe Makefile in the current directory, and then automatically executesmake
Makefiles (in case there are subdirectories), make includes, and make depend for you. Thisisthe normal way to configure
software that isoutside the X Consortium build tree.
If working inside the X Consortium build tree (unlikely unlessyou are an X developer, and even then thisoption isnever
really used), the topdir argument should be specified asthe relative pathname from the current directory to the top of the
build tree. Optionally, curdir may be specified asa relative pathname from the top of the build tree to the current directory.
It isnecessary to supply curdir if the current directory hassubdirectories, or the Makefile will not be able to build the
subdirectories. If a topdir isgiven, xmkmf assumesnothing isinstalled on your system and looksfor filesin the build tree
instead of using the installed versions.
SEE ALSO
imake(1)
X Version 11 Release6
xmodmap
xmodmapUtility for modifying keymapsin X
SYNOPSIS
xmodmap [-options ...] [filename]
DESCRIPTION
The xmodmap program isused to edit and display the keyboard modifier map and keymap table that are used by client
applicationsto convert event keycodesinto keysyms. It isusually run from the userssession startup script to configure the
keyboard according to personal tastes.
673
OPTIONS
The following optionsmay be used with xmodmap:
display display Thisoption specifiesthe host and display to use.
help Thisoption indicatesthat a brief description of the command-
line argumentsshould be printed on the standard error
channel. Thiswill be done whenever an unhandled argument
isgiven to xmodmap.
grammar Thisoption indicatesthat a help message describing the
expression grammar used in filesand with e expressions
should be printed on the standard error.
verbose Thisoption indicatesthat xmodmap should print logging
information asit parsesitsinput.
quiet Thisoption turnsoff the verbose logging. Thisisthe default.
n Thisoption indicatesthat xmodmap should not change the
mappings, but should display what it would do, like make(1)
doeswhen given thisoption.
e expression Thisoption specifiesan expression to be executed. Any
number of expressionsmay be specified from the command
line.
pm Thisoption indicatesthat the current modifier map should be
printed on the standard output.
pk Thisoption indicatesthat the current keymap table should be
printed on the standard output.
pke Thisoption indicatesthat the current keymap table should be
printed on the standard output in the form of expressionsthat
can be fed back to xmodmap.
pp Thisoption indicatesthat the current pointer map should be
printed on the standard output.
- A lone dash meansthat the standard input should be used as
the input file.
The filename specifiesa file containing xmodmap expressionsto be executed. Thisfile isusually kept in the usershome
directory with a name like .xmodmaprc.
EXPRESSION GRAMMAR
The xmodmap program readsa list of expressionsand parsesthem all before attempting to execute any of them. Thismakesit
possible to refer to keysymsthat are being redefined in a natural way without having to worry asmuch about name conflicts.
keycode NUMBER = KEYSYMNAME ... The list of keysymsisassigned to the indicated keycode (which
may be specified in decimal, hex, or octal and can be
determined by running the xev program.
keycode any = KEYSYMNAME ... If no existing key hasthe specified list of keysymsassigned to
it, a spare key on the keyboard isselected and the keysymsare
assigned to it. The list of keysymsmay be specified in decimal,
hex, or octal.
keysym KEYSYMNAME = KEYSYMNAME ... The KEYSYMNAME on the left side istranslated into matching
keycodesused to perform the corresponding set of keycode
expressions. The list of keysym namesmay be found in the
xmodmap
Part I: User Commands
674
header file <X11/keysymdef.h (without the XK_prefix) or the
keysym database <XRoot>/lib/X11/XKeysymDB, where <XRoot>
refersto the root of the X11 install tree. Note that if the same
keysym isbound to multiple keys, the expression isexecuted
for each matching keycode.
clear MODI FI ERNAME Thisremovesall entriesin the modifier map for the given
modifier, where valid namesare Shift, Lock, Control, Mod1,
Mod2, Mod3, Mod4, and Mod5 (case doesnot matter in modifier
names, although it doesmatter for all other names). For
example, clear Lock will remove any keysthat were bound to
the shift lock modifier.
add MODI FI ERNAME = KEYSYMNAME . . . Thisaddsall keyscontaining the given keysymsto the
indicated modifier map. The keysym namesare evaluated after
all input expressionsare read to make it easy to write
expressionsto swap keys. (See the Examples subsection).
remove MODI FI ERNAME = KEYSYMNAME . . . Thisremovesall keyscontaining the given keysymsfrom the
indicated modifier map. Unlike add, the keysym namesare
evaluated asthe line isread in. Thisallowsyou to remove keys
from a modifier without having to worry about whether or not
they have been reassigned.
pointer =default Thissetsthe pointer map back to itsdefault settings(button 1
generatesa code of 1, button 2 generatesa 2, and so on).
pointer = NUMBER ... Thissetsto pointer map to contain the indicated button
codes. The list alwaysstartswith the first physical button.
Linesthat begin with an exclamation point (!) are taken ascomments.
If you want to change the binding of a modifier key, you must also remove it from the appropriate modifier map.
EXAMPLES
Many pointersare designed such that the first button ispressed using the index finger of the right hand. People who are left-
handed frequently find that it ismore comfortable to reverse the button codesthat are generated so that the primary button
ispressed using the index finger of the left hand. Thiscould be done on a 3 button pointer asfollows: % xmodmap -e pointer
=3 2 1.
Many applicationssupport the notion of Meta keys(similar to Control keysexcept that Meta isheld down instead of
Control). However, some serversdo not have a Meta keysym in the default keymap table, so one needsto be added by hand.
The following command will attach Meta to the Multilanguage key (sometimeslabeled Compose Character). It also takes
advantage of the fact that applicationsthat need a Meta key simply need to get the keycode and dont require the keysym to
be in the first column of the keymap table. Thismeansthat applicationsthat are looking for a Multi key (including the
default modifier map) wont notice any change. Example:
% xmodmap -e keysym Multi_key = Multi_key Meta_L
Similarly, some keyboardshave an Alt key but no Meta key. In that case the following may be useful:
% xmodmap -e keysym Alt L = Meta L Alt L
One of the more simple, yet convenient, usesof xmodmap isto set the keyboardsrubout key to generate an alternate
keysym. Thisfrequently involvesexchanging Backspace with Delete to be more comfortable to the user. If the ttyModes
resource in xterm isset aswell, all terminal emulator windowswill use the same key for erasing characters:
% xmodmap -e keysym BackSpace = Delete
% echo XTerm*ttyModes: erase ? | xrdb -merge
675
Some keyboardsdo not automatically generate lessthan and greater than characterswhen the comma and period keysare
shifted. Thiscan be remedied with xmodmap by resetting the bindingsfor the comma and period with the following scripts:
!
! make shift-, be $<$ and shift-. be $>$
!
keysym comma = comma less
keysym period = period greater
One of the more irritating differencesbetween keyboardsisthe location of the Control and Shift Lock keys. A common use
of xmodmap isto swap these two keysasfollows:
!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
The keycode command isuseful for assigning the same keysym to multiple keycodes. Although unportable, it also makesit
possible to write scriptsthat can reset the keyboard to a known state. The following script setsthe Backspace key to generate
Delete (asshown earlier), flushesall existing capslock bindings, makesthe CapsLock key be a control key, make F5 generate
Escape, and makesBreak/Reset be a shift lock.
!
! On the HP, the following keycodes have key caps as listed:
!
! 101 Backspace
! 55 Caps
! 14 Ctrl
! 15 Break/Reset
! 86 Stop
! 89F5
!
keycode 101 = Delete
keycode 55 = Control_R
clear Lock
add Control = Control_R
keycode 89 = Escape
keycode 15 = Caps_Lock
add Lock = Caps_Lock
ENVIRONMENT
DISPLAY To get default host and display number
SEE ALSO
X(1), xev(1), Xlib documentation on key and pointer events
BUGS
Every time a keycode expression isevaluated, the server generatesa MappingNotify event on every client. Thiscan cause some
thrashing. All of the changesshould be batched together and done at once. Clientsthat receive keyboard input and ignore
MappingNotify eventswill not notice any changesmade to keyboard mappings.
xmodmap should generate add and remove expressionsautomatically whenever a keycode that isalready bound to a modifier is
changed.
xmodmap
Part I: User Commands
676
There should be a way to have the remove expression accept keycodesaswell askeysymsfor those timeswhen you really mess
up your mappings.
AUTHOR
Jim Fulton (MIT X Consortium), rewritten from an earlier version by David Rosenthal (Sun Microsystems)
X Version 11 Release6
xon
xonStart an X program on a remote machine
SYNOPSIS
xon remote-host [-access] [-debug] [-name window-name] [-nols] [-screen screen-no] [-user user-name] [command ...]
DESCRIPTION
xon runsthe specified command (default xterm -ls) on the remote machine using rsh, remsh, or rcmd. xon passesthe DISPLAY,
XAUTHORITY, and XUSERFILESEARCHPATH environment variablesto the remote command.
When no command isspecified, xon runsxterm -ls. It additionally specifiesthe application name to be xterm-r emot e-host
and the window title to be -fIremote-host.
xon can only work when the remote host will allow you to log in without a password, by having an entry in the .rhosts file
permitting access.
OPTIONS
Note that the optionsfollow the remote hostname (asthey do with rlogin).
-access Runsxhost locally to add the remote host to the host accesslist
in the X server. Thiswont work unlessxhost isgiven
permission to modify the accesslist.
-debug Normally, xon disconnectsthe remote processfrom stdin,
stdout, and stderr to eliminate the daemon processesthat
usually connect them acrossthe network. Specifying the -debug
option leavesthem connected so that error messagesfrom the
remote execution are sent back to the originating host.
-name window-name Thisspecifiesa different application name and window title
for the default command (xterm).
-nols Normally xon passesthe -ls option to the remote xterm; this
option suspendsthat behavior.
-screen screen-no Thischangesthe screen number of the DISPLAY variable passed
to the remote command.
-user user-name By default, xon simply usesrsh/remsh/rcmd to connect to the
remote machine using the same username ason the local
machine. Thisoption causesxon to specify an alternative
username. Thiswill not work unlessyou have authorization to
accessthe remote account, by placing an appropriate entry in
the remote users.rhosts file.
BUGS
xon can get easily confused when the remote host, username, or variousenvironment variable valuescontain whitespace.
xon hasno way to send the appropriate X authorization information to the remote host.
X Version 11 Release6
677
xpmtoppm
xpmtoppmConvert an X11 pixmap into a portable pixmap
SYNOPSIS
xpmtoppm [xpmf i l e]
DESCRIPTION
Readsan X11 pixmap (XPM version 1 or 3) asinput. Producesa portable pixmap asoutput.
KNOWN BUGS
The support to XPM version 3 islimited. Commentscan only be single linesand there must be for every pixel a default
color name for a color type visual.
SEE ALSO
ppmtoxpm(1), ppm(5)
XPM Manual by Arnaud Le Hors(lehors@mirsa.inria.fr)
AUTHOR
Copyright (c) 1991 by Jef Poskanzer.
Upgraded to support XPM version 3 by Arnaud Le Hors(lehors@mirsa.inria.fr) 9 April 1991
16 August 1990
xprop
xpropProperty displayer for X
SYNOPSIS
xprop [-help] [-grammar] [-id i d] [-root] [-name name] [-frame] [-font f ont ]
[-display di spl ay] [-len n] [-notype] [-fs f i l e] [-remove pr oper t y- name]
[-spy] [-f atom format [dformat]]* [format [dformat] atom]*
SUMMARY
The xprop utility isfor displaying window and font propertiesin an X server. One window or font isselected using the
command-line argumentsor possibly in the case of a window, by clicking on the desired window. A list of propertiesisthen
given, possibly with formatting information.
OPTIONS
-help Print out a summary of command-line options.
-grammar Print out a detailed grammar for all command-line options.
-id i d Thisargument allowsthe user to select window id on the
command line rather than using the pointer to select the target
window. Thisisvery useful in debugging X applicationswhere
the target window isnot mapped to the screen or where the
use of the pointer might be impossible or interfere with the
application.
-name name Thisargument allowsthe user to specify that the window
named name isthe target window on the command line rather
than using the pointer to select the target window.
xprop
Part I: User Commands
678
-font f ont Thisargument allowsthe user to specify that the propertiesof
font f ont should be displayed.
-root Thisargument specifiesthat Xsroot window isthe target
window. Thisisuseful in situationswhere the root window is
completely obscured.
-display di spl ay Thisargument allowsyou to specify the server to connect to;
see X(1).
-len n Specifiesthat at most, n bytesof any property should be read
or displayed.
-notype Specifiesthat the type of each property should not be
displayed.
-fs f i l e Specifiesthat file f i l e should be used asa source of more
formatsfor properties.
-frame Specifiesthat when selecting a window by hand (that is, if
neither -name, -root, nor -id isgiven), look at the window
manager frame (if any) instead of looking for the client
window.
-remove pr oper t y- name Specifiesthe name of a property to be removed from the
indicated window.
-spy Examine window propertiesforever, looking for property
change events.
-f name f or mat [df or mat ] Specifiesthat the format for name should be f or mat and that
the dformat for name should be df or mat . If df or mat ismissing,
= $0+\n isassumed.
DESCRIPTION
For each of these properties, itsvalue on the selected window or font isprinted using the supplied formatting information, if
any. If no formatting information issupplied, internal defaultsare used. If a property isnot defined on the selected window
or font, not defined isprinted asthe value for that property. If no property list isgiven, all the propertiespossessed by the
selected window or font are printed.
A window may be selected in one of four ways. First, if the desired window isthe root window, the -root argument may be
used. If the desired window isnot the root window, it may be selected in two wayson the command line, either by id
number, such asmight be obtained from xwininfo, or by name if the window possessesa name. The -id argument selectsa
window by id number in either decimal or hex (must start with 0x) while the -name argument selectsa window by name.
The last way to select a window doesnot involve the command line at all. If none of -font, -id, -name, and -root are
specified, a crosshairscursor isdisplayed and the user isallowed to choose any visible window by pressing any pointer button
in the desired window. If it isdesired to display propertiesof a font asopposed to a window, the -font argument must be
used.
Other than the preceding four argumentsand the -help argument for obtaining help, and the -grammar argument for listing
the full grammar for the command line, all the other command-line argumentsare used in specifying both the format of the
propertiesto be displayed and how to display them. The -len n argument specifiesthat at most, n bytesof any given
property will be read and displayed. Thisisuseful, for example, when displaying the cut buffer on the root window, which
could run to several pagesif displayed in full.
Normally, each property name isdisplayed by printing first the property name then itstype (if it hasone) in parentheses,
followed by itsvalue. The -notype argument specifiesthat property typesshould not be displayed. The -fs argument isused
to specify a file containing a list of formatsfor properties, while the -f argument isused to specify the format for one
property.
679
The formatting information for a property actually consistsof two parts, a format and a dformat. The format specifiesthe
actual formatting of the property (that is, isit made up of words, bytes, or longs?, and so on) while the dformat specifieshow
the property should be displayed.
The following paragraphsdescribe how to construct formatsand dformats. However, for the vast majority of usersand uses,
thisshould not be necessary asthe built-in defaultscontain the formatsand dformatsnecessary to display all the standard
properties. It should only be necessary to specify formatsand dformatsif a new property isbeing dealt with or the user
dislikesthe standard display format. New usersespecially are encouraged to skip thispart.
A format consistsof a 0, 8, 16, or 32 followed by a sequence of one or more format characters. The 0, 8, 16, or 32 specifies
how many bitsper field there are in the property.
Zero isa special case that meansuse the field size information associated with the property itself. (Thisisonly needed for
special caseslike type INTEGER, which isactually three different types, depending on the size of the fieldsof the property.)
A value of 8 meansthat the property isa sequence of bytes, while a value of 16 meansthat the property isa sequence of
words. The difference between these two liesin the fact that the sequence of wordswill be byte swapped while the sequence
of byteswill not be when read by a machine of the opposite byte order of the machine that originally wrote the property. For
more information on how propertiesare formatted and stored, consult the Xlib manual.
After the size of the fieldshasbeen specified, it isnecessary to specify the type of each field (isit an integer, a string, an atom,
or what?) Thisisdone using one format character per field. If there are more fieldsin the property than format characters
supplied, the last character will be repeated asmany timesasnecessary for the extra fields. The format charactersand their
meaning are asfollows:
a The field holdsan atom number. A field of thistype should be
of size 32.
b The field isa Boolean. A 0 meansfalse while anything else
meanstrue.
c The field isan unsigned number, a cardinal.
i The field isa signed integer.
m The field isa set of bit flags, 1 meaning on.
s Thisfield and the next onesuntil either a 0 or the end of the
propertyrepresent a sequence of bytes. Thisformat character
isonly usable with a field size of 8 and ismost often used to
represent a string.
x The field isa hex number (like c but displayed in hexmost
useful for displaying window idsand the like).
An example format is32ica, which isthe format for a property of three fieldsof 32 bitseachthe first holding a signed
integer, the second an unsigned integer, and the third an atom.
The format of a dformat, unlike that of a format, isnot so rigid. The only limitationson a dformat isthat one may not start
with a letter or a dash. Thisisso that it can be distinguished from a property name or an argument. A dformat isa text string
containing special charactersinstructing that variousfieldsbe printed at variouspointsin a manner similar to the formatting
string used by printf. For example, the dformat is ( $0, $1 \)\n would render the POINT 3, -4, which hasa format of 32ii as
is ( 3, -4 )\n.
Any character other than a $, ?, \, or a ( in a dformat printsasitself. To print out a $, ?, \, or (, precede it with a \. For
example, to print out a $, use \$. Several special backslash sequencesare provided asshortcuts. \n will cause a newline to be
displayed, while \t will cause a tab to be displayed. \o, where o isan octal number, will display character number o.
A $ followed by a number n causesfield number n to be displayed. The format of the displayed field dependson the
formatting character used to describe it in the corresponding format. In other words, if a cardinal isdescribed by c, it will
print in decimal, while if it isdescribed by an x, it isdisplayed in hex.
xprop
Part I: User Commands
680
If the field isnot present in the property (thisispossible with some properties), <field not available> isdisplayed instead.
$n+ will display field number n, then a comma, then field number n+1, then another comma, then ... until the last field
defined. If field n isnot defined, nothing isdisplayed. Thisisuseful for a property that isa list of values.
A ? isused to start a conditional expression, a kind of if-then statement. ?exp(t ext ) will display text if and only if exp
evaluatesto non-zero. Thisisuseful for two things. First, it allowsfieldsto be displayed if and only if a flag isset. And
second, it allowsa value such asa state number to be displayed asa name rather than asjust a number. The syntax of exp isas
follows:
exp ::= t er m | t er m=exp | !exp
t er m ::= n j $n j mn
The ! operator isa logical NOT, changing 0 to 1 and any non-zero value to 0. = isan equality operator. Note that internally, all
expressionsare evaluated as32-bit numbers, so -1 isnot equal to 65535. = returns1 if the two valuesare equal and 0 if not. n
representsthe constant value n while $n representsthe value of field number n. mn is1 if flag number n in the first field
having format character m in the corresponding format is1; 0 otherwise.
Examples: ?m3(count: $3\n) displaysfield 3 with a label of count if and only if flag number 3 (count startsat 0!) ison.
?$2=0(True)?!$2=0(False) displaysthe inverted value of field 2 asa Boolean.
In order to display a property, xprop needsboth a format and a dformat. Before xprop usesitsdefault valuesof a format of 32x
and a dformat of = { $0+ }\n, it searchesseveral placesin an attempt to find more specific formats. First, a search ismade
using the name of the property. If thisfails, a search ismade using the type of the property. Thisallowstype STRING to be
defined with one set of formatswhile allowing property WM_NAME, which isof type STRING to be defined with a different
format. In thisway, the display formatsfor a given type can be overridden for specific properties.
The locationssearched are in order: the format, if any, specified with the property name (asin 8x WM_NAME), the formats
defined by -f optionsin last to first order, the contentsof the file specified by the -fs option if any, the contentsof the file
specified by the environmental variable XPROPFORMATS if any, and finally xpropsbuilt-in file of formats.
The format of the filesreferred to by the -fs argument and the XPROPFORMATS variable isone or more linesof the following
form:
name f or mat [df or mat ]
Where name iseither the name of a property or the name of a type, f or mat isthe format to be used with name, and df or mat is
the dformat to be used with name. If df or mat isnot present,=$0+\n isassumed.
EXAMPLES
To display the name of the root window: xprop -root WM_NAME
To display the window manager hintsfor the clock: xprop -name xclock WM_HINTS
To display the start of the cut buffer: xprop -root -len 100 CUT_BUFFER0
To display the point size of the fixed font: xprop -font fixed POINT_SIZE
To display all the propertiesof window # 0x200007: xprop -id 0x200007
ENVIRONMENT
DISPLAY To get default display.
XPROPFORMATS Specifiesthe name of a file from which additional formatsare
to be obtained.
SEE ALSO
X(1), xwininfo(1)
681
AUTHOR
Mark Lillibridge (MIT Project Athena)
X Version 11 Release6
xrdb
xrdbX server resource database utility
SYNOPSIS
xrdb [-option ...] [f i l ename]
DESCRIPTION
xrdb isused to get or set the contentsof the RESOURCE_MANAGER property on the root window of screen 0, or the
SCREEN_RESOURCES property on the root window of any or all screens, or everything combined. You would normally run this
program from your X startup file.
Most X clientsuse the RESOURCE_MANAGER and SCREEN_RESOURCES propertiesto get user preferencesabout color, fonts, and so on
for applications. Having thisinformation in the server (where it isavailable to all clients) instead of on disk solvesthe
problem in previousversionsof X that required you to maintain defaultsfileson every machine that you might use. It also
allowsfor dynamic changing of defaultswithout editing files.
The RESOURCE_MANAGER property isused for resourcesthat apply to all screensof the display. The SCREEN_RESOURCES property
on each screen specifiesadditional (or overriding) resourcesto be used for that screen. (When there isonly one screen,
SCREEN_RESOURCES isnormally not used; all resourcesare just placed in the RESOURCE_MANAGER property.)
The file specified by filename (or the contentsfrom standard input if - or no filename isgiven) isoptionally passed through
the C preprocessor with the following symbolsdefined, based on the capabilitiesof the server being used:
SERVERHOST=host name The host name portion of the display to which you are
connected.
SRVR_name The SERVERHOSThostnamestring turned into a legal identifier.
For example, my-dpy.lcs.mit.edu becomesSRVR my dpy lcs
mit edu.
HOST=host name The same asSERVERHOST.
DISPLAY_NUM=num The number of the display on the server host.
CLIENTHOST=host name The name of the host on which xrdb isrunning.
CLNT_name The CLIENTHOST hostname string turned into a legal identifier.
For example, expo.lcs.mit.edu becomesCLNT expo lcs mit
edu.
RELEASE=num The vendor release number for the server. The interpretation
of thisnumber will vary depending on VENDOR.
REVISION=num The X protocol minor version supported by thisserver
(currently 0).
VERSION=num The X protocol major version supported by thisserver (should
alwaysbe 11).
VENDOR= vendor A string literal specifying the vendor of the server.
VNDR_name The VENDOR name string turned into a legal identifier. For
example, MIT X Consortium becomesVNDR_MIT_X Consortium.
EXT_name A symbol isdefined for each protocol extension supported by
the server. Each extension string name isturned into a legal
identifier. For example, X3D-PEX becomesEXT_X3D_PEX.
xrdb
Part I: User Commands
682
NUM_SCREENS=num The total number of screens.
SCREEN_NUM=num The number of the current screen (from zero).
BITS_PER_RGB=num The number of significant bitsin an RGB color specification.
Thisisthe log base 2 of the number of distinct shadesof each
primary that the hardware can generate. Note that it usually is
not related to PLANES.
CLASS=vi sual cl ass One of StaticGray, GrayScale, StaticColor, PseudoColor,
TrueColor, DirectColor. Thisisthe visual classof the root
window.
CLASS_vi sual cl ass=vi sual i d The visual classof the root window in a form you can #ifdef
on. The value isthe numeric id of the visual.
COLOR Defined only if CLASS isone of StaticColor, PseudoColor,
TrueColor, or DirectColor.
CLASS_visualclass_depth=num A symbol isdefined for each visual supported for the screen.
The symbol includesthe classof the visual and itsdepth; the
value isthe numeric id of the visual. (If more than one visual
hasthe same classand depth, the numeric id of the first one
reported by the server isused.)
HEIGHT=num The height of the root window in pixels.
WIDTH=num The width of the root window in pixels.
PLANES=num The number of bit planes(the depth) of the root window.
X_RESOLUTION=num The x resolution of the screen in pixelsper meter.
Y_RESOLUTION=num The y resolution of the screen in pixelsper meter.
SRVR_name, CLNT_name, VNDR_name, and EXT_name identifiersare formed by changing all charactersother than lettersand digits
into underscores.
Linesthat begin with an exclamation mark (!) are ignored and may be used ascomments.
Note that since xrdb can read from standard input, it can be used to change the contentsof propertiesdirectly from a
terminal or from a shell script.
OPTIONS
xrdb program acceptsthe following options:
help Thisoption (or any unsupported option) will cause a brief
description of the allowable optionsand parametersto be
printed.
display di spl ay Thisoption specifiesthe X server to be used; see X(1). It also
specifiesthe screen to use for the -screen option, and it
specifiesthe screen from which preprocessor symbolsare
derived for the -global option.
all Thisoption indicatesthat operation should be performed on
the screen-independent resource property (RESOURCE_MANAGER),
aswell asthe screen-specific property (SCREEN_RESOURCES) on
every screen of the display. For example, when used in
conjunction with -query, the contentsof all propertiesare
output. For -load, -override, and -merge, the input file is
processed once for each screen. The resourcesthat occur in
common in the output for every screen are collected, and these
are applied asthe screen-independent resources. The
remaining resourcesare applied for each individual per-screen
property. Thisthe default mode of operation.
683
global Thisoption indicatesthat the operation should only be
performed on the screen-independent RESOURCE_MANAGER
property.
screen Thisoption indicatesthat the operation should only be
performed on the SCREEN_RESOURCES property of the default
screen of the display.
screens Thisoption indicatesthat the operation should be performed
on the SCREEN_RESOURCES property of each screen of the display.
For -load, -override, and -merge, the input file isprocessed for
each screen.
n Thisoption indicatesthat changesto the specified properties
(when used with -load, -override, or -merge) or to the resource
file (when used with -edit) should be shown on the standard
output, but should not be performed.
quiet Thisoption indicatesthat warning about duplicate entries
should not be displayed.
-cpp filename Thisoption specifiesthe pathname of the C preprocessor
program to be used. Although xrdb wasdesigned to use CPP,
any program that actsasa filter and acceptsthe -D, -I, and -U
optionsmay be used.
-nocpp Thisoption indicatesthat xrdb should not run the input file
through a preprocessor before loading it into properties.
symbols Thisoption indicatesthat the symbolsthat are defined for the
preprocessor should be printed onto the standard output.
query Thisoption indicatesthat the current contentsof the specified
propertiesshould be printed onto the standard output. Note
that since preprocessor commandsin the input resource file are
part of the input file, not part of the property, they wont
appear in the output from thisoption. The edit option can
be used to merge the contentsof propertiesback into the input
resource file without damaging preprocessor commands.
load Thisoption indicatesthat the input should be loaded asthe
new value of the specified properties, replacing whatever was
there; that is, the old contentsare removed. Thisisthe default
action.
override Thisoption indicatesthat the input should be added to,
instead of replacing, the current contentsof the specified
properties. New entriesoverride previousentries.
merge Thisoption indicatesthat the input should be merged and
lexicographically sorted with, instead of replacing, the current
contentsof the specified properties.
remove Thisoption indicatesthat the specified propertiesshould be
removed from the server.
retain Thisoption indicatesthat the server should be instructed not
to reset if xrdb isthe first client. Thisshould never be necessary
under normal conditions, since xdm and xinit alwaysact asthe
first client.
edit f i l ename Thisoption indicatesthat the contentsof the specified
propertiesshould be edited into the given file, replacing any
valuesalready listed there. Thisallowsyou to put changesthat
you have made to your defaultsback into your resource file,
preserving any commentsor preprocessor lines.
xrdb
Part I: User Commands
684
backup st r i ng Thisoption specifiesa suffix to be appended to the filename
used with edit to generate a backup file.
Dname[=val ue] Thisoption ispassed through to the preprocessor and isused
to define symbolsfor use with conditionalssuch as#ifdef.
Uname Thisoption ispassed through to the preprocessor and isused
to remove any definitionsof thissymbol.
Idi r ect or y Thisoption ispassed through to the preprocessor and isused
to specify a directory to search for filesthat are referenced with
#include.
FILES
Generalizes~/.Xdefaults files
SEE ALSO
X(1), Xlib Resource Manager documentation, Xt resource documentation
ENVIRONMENT
DISPLAY To figure out which display to use.
BUGS
The default for no argumentsshould be to query, not to overwrite, so that it isconsistent with other programs.
AUTHORS
Bob Scheifler and Phil Karlton, rewritten from the original by Jim Gettys
X Version 11 Release6
xrefresh
xrefreshRefresh all or part of an X screen
SYNOPSIS
xrefresh [-option ...]
DESCRIPTION
xrefresh isa simple X program that causesall or part of your screen to be repainted. Thisisuseful when system messages
have messed up your screen. xrefresh mapsa window on top of the desired area of the screen and then immediately unmaps
it, causing refresh eventsto be sent to all applications. By default, a window with no background isused, causing all
applicationsto repaint smoothly. However, the variousoptionscan be used to indicate that a solid background (of any color)
or the root window background should be used instead.
ARGUMENTS
white Use a white background. The screen just appearsto flash
quickly, and then repaint.
black Use a black background (in effect, turning off all of the
electron gunsto the tube). Thiscan be somewhat disorienting
aseverything goesblack for a moment.
solid col or Use a solid background of the specified color. Try green.
root Use the root window background.
685
none Thisisthe default. All of the windowssimply repaint.
geometry WxH+X+Y Specifiesthe portion of the screen to be repainted; see X(1).
display di spl ay Thisargument allowsyou to specify the server and screen to
refresh; see X(1).
X DEFAULTS
The xrefresh program usesthe routine XGetDefault(3X) to read defaults, so itsresource namesare all capitalized.
Black, White, Solid, None, Root Determineswhat sort of window background to use
Geometry Determinesthe area to refresh. Not very useful.
ENVIRONMENT
DISPLAY To get default host and display number.
SEE ALSO
X(1)
BUGS
It should have just one default type for the background.
AUTHORS
Jim Gettys(Digital Equipment Corporation, MIT Project Athena)
X Version 11 Release6
Xserver
XserverX Window System display server
SYNOPSIS
X [option ...]
DESCRIPTION
X isthe generic name for the X Window System display server. It isfrequently a link or a copy of the appropriate server
binary for driving the most frequently used server on a given machine.
STARTING THE SERVER
The X server isusually started from the X Display Manager program xdm(1). Thisutility isrun from the system boot filesand
takescare of keeping the server running, prompting for usernamesand passwords, and starting up the user sessions.
Installationsthat run more than one window system may need to use the xinit(1) utility instead of xdm. However, xinit isto
be considered a tool for building startup scriptsand isnot intended for use by end users. Site administratorsare strongly
urged to use xdm, or build other interfacesfor novice users.
The X server may also be started directly by the user, though thismethod isusually reserved for testing and isnot recom-
mended for normal operation. On some platforms, the user must have special permission to start the X server, often because
accessto certain devices. (For example, /dev/mouse isrestricted.)
When the X server startsup, it typically takesover the display. If you are running on a workstation whose console isthe
display, you may not be able to log into the console while the server isrunning.
xserver
Part I: User Commands
686
OPTIONS
All of the X serversaccept the following command-line options:
: di spl aynumber The X server runsasthe given di spl aynumber , which by default
is0. If multiple X serversare to run simultaneously on a host,
each must have a unique display number. See the Display
Names subsection of the X(1) manual page to learn how to
specify which display number clientsshould try to use.
a number Setspointer acceleration (that is, the ratio of how much is
reported to how much the user actually moved the pointer).
ac Disableshost-based accesscontrol mechanisms. Enablesaccess
by any host, and permitsany host to modify the accesscontrol
list. Use with extreme caution. Thisoption existsprimarily for
running test suitesremotely.
audit l evel Setsthe audit trail level. The default level is1, meaning only
connection rejectionsare reported. Level 2 additionally reports
all successful connectionsand disconnects. Level 0 turnsoff
the audit trail. Audit linesare sent asstandard error output.
auth aut hor i zat i on- f i l e Specifiesa file which containsa collection of authorization
recordsused to authenticate access. See also the xdm and
Xsecurity manual pages.
bc Disablescertain kindsof error checking, for bug compatibility
with previousreleases(for example, to work around bugsin
R2 and R3 xterms and toolkits). Deprecated.
bs Disablesbacking store support on all screens.
c Turnsoff key-click.
c vol ume Setskey-click volume (allowable range: 0100).
cc cl ass Setsthe visual classfor the root window of color screens. The
classnumbersare asspecified in the X protocol. Not obeyed by
all servers.
co f i l ename Setsname of RGB color database. The default is<XRoot>/lib/
X11/rgb, where <Xroot> refersto the root of the X11 install
tree.
config f i l ename Readsmore optionsfrom the given file. Optionsin the file
may be separated by newlinesif desired. If a # character
appearson a line, all charactersbetween it and the next
newline are ignored, providing a simple commenting facility.
The config option itself may appear in the file.
core Causesthe server to generate a core dump on fatal errors.
dpi r esol ut i on Setsthe resolution of the screen, in dotsper inch. To be used
when the server cannot determine the screen size from the
hardware.
deferglyphs whi chf ont s Specifiesthe typesof fontsfor which the server should attempt
to use deferred glyph loading. whi chf ont s can be all (all fonts),
none (no fonts), or 16 (16-bit fontsonly).
f vol ume Setsfeep (bell) volume (allowable range: 0100).
fc cur sor Font Setsdefault cursor font.
fn f ont Setsthe default font.
687
fp f ont Pat h Setsthe search path for fonts. Thispath isa comma-separated
list of directoriesthat the X server searchesfor font databases.
help printsa usage message.
I Causesall remaining command-line argumentsto be ignored.
kb Disablesthe XKEYBOARD extension if present.
p mi nut es Setsscreen saver pattern cycle time in minutes.
pn Permitsthe server to continue running if it failsto establish all
of itswell-known sockets(connection pointsfor clients), but
establishesat least one.
r Turnsoff auto-repeat.
r Turnson auto-repeat.
s mi nut es Setsscreen saver time-out time in minutes.
su Disablessave under support on all screens.
t number Setspointer acceleration threshold in pixels(that is, setsafter
how many pixelspointer acceleration should take effect).
terminate Causesthe server to terminate at server reset, instead of
continuing to run.
to seconds Setsdefault connection time-out in seconds.
tst Disablesall testing extensions(for example, XTEST, XTrap,
XTestExtension1).
ttyxx Ignored, for serversstarted the ancient way (from init).
v Setsvideo-off screen saver preference.
v Setsvideo-on screen saver preference.
wm Forcesthe default backing-store of all windowsto be When-
Mapped. Thisisa backdoor way of getting backing-store to
apply to all windows. Although all mapped windowswill have
backing-store, the backing-store attribute value reported by the
server for a window will be the last value established by a
client. If it hasnever been set by a client, the server will report
the default value, NotUseful. Thisbehavior isrequired by the
X protocol, which allowsthe server to exceed the clients
backing-store expectationsbut doesnot provide a way to tell
the client that it isdoing so.
x ext ensi on Loadsthe specified extension at init. Thisisa no-op for most
implementations.
SERVER DEPENDENT OPTIONS
Some X serversaccept the following options:
ld ki l obyt es Setsthe data space limit of the server to the specified number
of kilobytes. A value of zero makesthe data size aslarge as
possible. The default value of 1 leavesthe data space limit
unchanged.
lf f i l es Setsthe number-of-open-fileslimit of the server to the
specified number. A value of zero makesthe limit aslarge as
possible. The default value of 1 leavesthe limit unchanged.
ls ki l obyt es Setsthe stack space limit of the server to the specified number
of kilobytes. A value of zero makesthe stack size aslarge as
possible. The default value of 1 leavesthe stack space limit
unchanged.
xserver
Part I: User Commands
688
logo Turnson the X Window System logo display in the screen
saver. There iscurrently no way to change thisfrom a client.
nologo Turnsoff the X Window System logo display in the screen
saver. There iscurrently no way to change thisfrom a client.
XDMCP OPTIONS
X serversthat support XDMCP have the following options. (See the X Display Manager Control Protocol specification for
more information.)
query host - name Enable XDMCP and send Query packetsto the specified host.
broadcast Enable XDMCP and broadcast BroadcastQuery packetsto the
network. The first responding display manager will be chosen
for the session.
indirect host - name Enable XDMCP and send IndirectQuery packetsto the
specified host.
port por t - num Use an alternate port number for XDMCP packets. Must be
specified before any query, broadcast, or indirect options.
class di spl ay- cl ass XDMCP hasan additional display qualifier used in resource
lookup for display-specific options. Thisoption setsthat value;
by default it isMIT-Unspecified (not a very useful value).
cookie xdm-auth-bits When testing XDM-AUTHENTICATION-1, a private key isshared
between the server and the manager. Thisoption setsthe value
of that private data (not that it isvery private, being on the
command line!).
displayID display-id Yet another XDMCP-specific value, thisone allowsthe display
manager to identify each display so that it can locate the
shared key.
XKEYBOARD OPTIONS
X serversthat support the XKEYBOARD extension accept the following options:
xkbdir di r ect or y Base directory for keyboard layout files
xkbmap f i l ename Keyboard description to load on startup
[+-]accessx Enable(+) or disable(-) AccessX key sequences
ar1 mi l l i seconds Setsthe length of time in millisecondsthat a key must be
depressed before auto-repeat starts
ar2 mi l l i seconds Setsthe length of time in millisecondsthat should elapse
between auto-repeatgenerated keystrokes
Many serversalso have device-specific command-line options. See the manual pagesfor the individual serversfor more
details.
NETWORK CONNECTIONS
The X server supportsclient connectionsvia a platform-dependent subset of the following transport types: TCPIP, UNIX
Domain sockets, DECnet, and several varietiesof SVR4 local connections. See the Display Names subsection of the X(1)
manual page to learn how to specify which transport type clientsshould try to use.
SECURITY
The X server implementsa platform-dependent subset of the following authorization protocols: -MIT-MAGICCOOKIE-1, XDM-
AUTHORIZATION-1, SUN-DES-1, and MIT-KERBEROS-5. See the Xsecurity(1) manual page for information on the operation of these
protocols.
689
Authorization data required by the preceding protocolsispassed to the server in a private file named with the auth
command-line option. Each time the server isabout to accept the first connection after a reset (or when the server is
starting), it readsthisfile. If thisfile containsany authorization records, the local host isnot automatically allowed accessto
the server, and only clientsthat send one of the authorization recordscontained in the file in the connection setup informa-
tion will be allowed access. See the xau manual page for a description of the binary format of thisfile. See xauth(1) for
maintenance of thisfile, and distribution of itscontentsto remote hosts.
The X server also usesa host-based accesscontrol list for deciding whether or not to accept connectionsfrom clientson a
particular machine. If no other authorization mechanism isbeing used, thislist initially consistsof the host on which the
server isrunning aswell asany machineslisted in the file /etc/Xn.hosts, where n isthe display number of the server. Each
line of the file should contain either an Internet hostname (for example expo.lcs.mit.edu) or a DECnet hostname in double
colon format (for example, hydra::). There should be no leading or trailing spaceson any lines. For example,
joesworkstation
corporate.company.com
star::
bigcpu::
Userscan add or remove hostsfrom thislist and enable or disable accesscontrol using the xhost command from the same
machine asthe server.
The X protocol intrinsically doesnot have any notion of window operation permissionsor place any restrictionson what a
client can do; if a program can connect to a display, it hasfull run of the screen. Sitesthat have better authentication and
authorization systemsmight wish to make use of the hooksin the librariesand the server to provide additional security
models.
SIGNALS
The X server attachesspecial meaning to the following signals:
SIGHUP Thissignal causesthe server to close all existing connections,
free all resources, and restore all defaults. It issent by the
display manager whenever the main usersmain application
(usually an xterm or window manager) exitsto force the server
to clean up and prepare for the next user.
SIGTERM Thissignal causesthe server to exit cleanly.
SIGUSR1 Thissignal isused quite differently from either of the above.
When the server starts, it checksto see if it hasinherited
SIGUSR1 asSIG_IGN instead of the usual SIG_DFL. In thiscase,
the server sendsa SIGUSR1 to itsparent processafter it hasset
up the variousconnection schemes. xdm usesthisfeature to
recognize when connecting to the server ispossible.
FONTS
The X server can obtain fontsfrom directoriesor from font servers. The list of directoriesand font serversthe X server uses
when trying to open a font iscontrolled by the font path.
The default font path is
<XRoot>/lib/X11/fonts/misc/,
<XRoot>/lib/X11/fonts/Speedo/,
<XRoot>/lib/X11/fonts/Type1/,
<XRoot>/lib/X11/fonts/75dpi/,
<XRoot>/lib/X11/fonts/100dpi/
where <XRoot> refersto the root of the X11 install tree.
The font path can be set with the fp option or by xset(1) after the server hasstarted.
xserver
Part I: User Commands
690
FILES
/etc/Xn.hosts Initial accesscontrol list for display number n
<XRoot>/lib/X11/fonts/misc
<XRoot>/lib/X11/fonts/75dpi
<XRoot>/lib/X11/fonts/100dpi Bitmap font directories
<XRoot>/lib/X11/fonts/Speedo
<XRoot>/lib/X11/fonts/Type1 Outline font directories
<XRoot>/lib/X11/fonts/PEX PEX font directories
<XRoot>/lib/X11/rgb.txt Color database
/tmp/.X11-unix/Xn UNIX domain socket for display number n
/tmp/rcXn Kerberos5 replay cache for display number n
/usr/adm/Xnmsgs Error log file for display number n if run from init(8)
<XRoot>/lib/X11/xdm/xdm-errors Default error log file if the server isrun from xdm(1)
Note: <XRoot> refersto the root of the X11 install tree.
SEE ALSO
General information: X(1)
Protocols: X Window System Protocol, The X Font Service Protocol, X Display Manager Control Protocol
Fonts: bdftopcf(1), mkfontdir(1), xfs(1), xlsfonts(1), xfontsel(1), xfd(1), X Logical Font Description Conventions
Security: Xsecurity(1), xauth(1), xau(1), xdm(1), xhost(1)
Starting the server: xdm(1), xinit(1)
Controlling the server once started: xset(1), xsetroot(1), xhost(1)
Server-specific man pages: Xdec(1), XmacII(1), Xsun(1), Xnest(1), Xvfb(1), XF86 Accel(1), XF86 Mono(1), XF86 SVGA(1), XF86
VGA16(1), XFree86(1)
Server internal documentation: Definition of the Porting Layer for the X v11 Sample Server, Strategiesfor Porting the X
v11 Sample Server, GodzillasGuide to Porting the X v11 Sample Server
AUTHORS
The sample server wasoriginally written by Susan Angebranndt, Raymond Drewry, Philip Karlton, and Todd Newman,
from Digital Equipment Corporation, with support from a large cast. It hassince been extensively rewritten by Keith
Packard and Bob Scheifler, from MIT.
X Version 11 Release6
xset
xsetUser preference utility for X
SYNOPSIS
xset [-display di spl ay ] [-b] [b on/off] [b [vol ume [pi t ch [dur at i on]]] [[-]bc]
[-c] [c on/off] [c [vol ume]] [[-+]fp[-+=] pat h[,pat h[,...]]] [fp default]
[fp rehash] [[-]led [i nt eger ]] [led on/off] [m[ouse] [accel _mul t [/accel _di v]
[t hr eshol d]]] [m[ouse] default] [p pi xel col or ] [[-]r [keycode]] [r on/off]
[s [l engt h [per i od]]] [s blank/noblank] [s expose/noexpose] [s on/off]
[s default] [s activate] [s reset] [q]
691
DESCRIPTION
Thisprogram isused to set varioususer preference optionsof the display.
OPTIONS
display di spl ay Thisoption specifiesthe server to use; see X(1).
b The b option controlsbell volume, pitch, and duration. This
option acceptsup to three numerical parameters, a preceding
dash (-), or an on/off flag. If no parametersare given, or the on
flag isused, the system defaultswill be used. If the dash or off
isgiven, the bell will be turned off. If only one numerical
parameter isgiven, the bell volume will be set to that value, as
a percentage of itsmaximum. Likewise, the second numerical
parameter specifiesthe bell pitch, in hertz, and the third
numerical parameter specifiesthe duration in milliseconds.
Note that not all hardware can vary the bell characteristics.
The X server will set the characteristicsof the bell asclosely as
it can to the usersspecifications.
bc The bc option controlsbug compatibility mode in the server,
if possible; a preceding dash (-) disablesthe mode; otherwise,
the mode isenabled. Variouspre-R4 clientspassillegal values
in some protocol requests, and pre-R4 serversdid not correctly
generate errorsin these cases. Such clients, when run against
an R4 server, will terminate abnormally or otherwise fail to
operate correctly. Bug compatibility mode explicitly reintro-
ducescertain bugsinto the X server, so that many such clients
can still be run. Thismode should be used with care; new
application development should be done with thismode
disabled. The server must support the MIT-SUNDRY-NONSTANDARD
protocol extension in order for thisoption to work.
c The c option controlskey click. Thisoption can take an
optional value, a preceding dash (-), or an on/off flag. If no
parameter or the on flag isgiven, the system defaultswill be
used. If the dash or off flag isused, key click will be disabled.
If a value from 0 to 100 isgiven, it isused to indicate volume,
asa percentage of the maximum. The X server will set the
volume to the nearest value that the hardware can support.
fp= pat h,... The fp= setsthe font path to the entriesgiven in the path
argument. The entriesare interpreted by the server, not by the
client. Typically, they are directory namesor font server
names, but the interpretation isserver-dependent.
fp default The default argument causesthe font path to be reset to the
serversdefault.
fp rehash The rehash argument resetsthe font path to itscurrent value,
causing the server to reread the font databasesin the current
font path. Thisisgenerally only used when adding new fonts
to a font directory (after running mkfontdir to re-create the
font database).
fp or fp The fp and fp optionsremove elementsfrom the current
font path. They must be followed by a comma-separated list of
entries.
xset
Part I: User Commands
692
fp or fp Thisfp and fp optionsprepend and append elementsto the
current font path, respectively. They must be followed by a
comma-separated list of entries.
led The led option controlsthe keyboard LEDs. Thiscontrolsthe
turning on or off of one or all of the LEDs. It acceptsan
optional integer, a preceding dash (-) or an on/off flag. If no
parameter or the on flag isgiven, all LEDsare turned on. If a
preceding dash or the flag off isgiven, all LEDsare turned off.
If a value between 1 and 32 isgiven, that LED will be turned
on or off depending on the existence of a preceding dash. A
common LED that can be controlled isthe Caps Lock LED. xset
led 3 would turn led #3 on. xset -led 3 would turn it off.
The particular LED valuesmay refer to different LEDson
different hardware.
m The m option controlsthe mouse parameters. The parameters
for the mouse are acceleration and threshold. The accelera-
tion can be specified asan integer, or asa simple fraction. The
mouse, or whatever pointer the machine isconnected to, will
go acceleration timesasfast when it travelsmore than
threshold pixelsin a short time. Thisway, the mouse can be
used for precise alignment when it ismoved slowly, yet it can
be set to travel acrossthe screen in a flick of the wrist when
desired. One or both parametersfor the m option can be
omitted, but if only one isgiven, it will be interpreted asthe
acceleration. If no parametersor the flag default isused, the
system defaultswill be set.
p The p option controlspixel color values. The parametersare
the color map entry number in decimal, and a color specifica-
tion. The root background colorsmay be changed on some
serversby altering the entriesfor BlackPixel and WhitePixel.
Although these are often 0 and 1, they need not be. Also, a
server may choose to allocate those colorsprivately, in which
case an error will be generated. The map entry must not be a
read-only color, or an error will result.
r The r option controlsthe auto-repeat. If a preceding dash
or the off flag isused, auto-repeat will be disabled. If no
parametersor the on flag isused, auto-repeat will be enabled.
If a specific keycode isspecified asa parameter, auto-repeat
for that keycode isenabled or disabled.
s The s option letsyou set the screen saver parameters. This
option acceptsup to two numerical parameters, a blank/
noblank flag, an expose/noexpose flag, an on/off flag, an
activate/reset flag, or the default flag. If no parametersor
the default flag isused, the system will be set to itsdefault
screen saver characteristics. The on/off flagssimply turn the
screen saver functionson or off. The activate flag forces
activation of screen saver even if the screen saver had been
turned off. The reset flag forcesdeactivation of screen saver
if it isactive. The blank flag setsthe preference to blank the
video (if the hardware can do so) rather than display a
background pattern, while noblank setsthe preference to
display a pattern rather than blank the video. The expose flag
setsthe preference to allow window exposures(the server can
693
freely discard window contents), while noexpose setsthe
preference to disable screen saver unlessthe server can
regenerate the screenswithout causing exposure events. The
length and period parametersfor the screen saver function
determineshow long the server must be inactive for screen
saving to activate, and the period to change the background
pattern to avoid burn in. The argumentsare specified in
seconds. If only one numerical parameter isgiven, it will be
used for the length.
q The q option givesyou information on the current settings.
These settingswill be reset to default valueswhen you log out.
Note that not all X implementationsare guaranteed to honor all of these options.
SEE ALSO
X(1), Xserver(1), xmodmap(1), xrdb(1), xsetroot(1)
AUTHOR
Bob Scheifler (MIT Laboratory for Computer Science), David Krikorian (MIT Project Athena; X11 version)
X Version 11 Release6
xsetroot
xsetrootRoot window parameter setting utility for X
SYNOPSIS
xsetroot [-help] [-def] [-display di spl ay] [-cursor cur sor f i l e maskf i l e]
[-cursor_name cur sor name] [-bitmap f i l ename] [-mod x y] [-gray] [-grey]
[-fg col or ] [-bg col or ] [-rv] [-solid col or ] [-name st r i ng]
DESCRIPTION
The setroot program allowsyou to tailor the appearance of the background (root) window on a workstation display running
X. Normally, you experiment with xsetroot until you find a personalized look that you like, then put the xsetroot command
that producesit into your X startup file. If no optionsare specified, or if -def isspecified, the window isreset to itsdefault
state. The -def option can be specified along with other optionsand only the nonspecified characteristicswill be reset to the
default state.
Only one of the background color/tiling changing options(-solid, -gray, -grey, -bitmap, and -mod) may be specified at a
time.
OPTIONS
The variousoptionsare asfollows:
-help Print a usage message and exit.
-def Reset unspecified attributesto the default values. (Restoresthe
background to the familiar gray mesh and the cursor to the
hollow x shape.)
-cursor cur sor f i l e maskf i l e Thisletsyou change the pointer cursor to whatever you want
when the pointer cursor isoutside of any window. Cursor and
mask filesare bitmaps(little pictures), and can be made with
the bitmap(1) program. You probably want the mask file to be
all black until you get used to the way maskswork.
xsetroot
Part I: User Commands
694
-cursor_name cur sor name Thisletsyou change the pointer cursor to one of the standard
cursorsfrom the cursor font. Refer to Appendix B of the X
protocol for the names(except that the XC prefix iselided for
thisoption).
-bitmap f i l ename Use the bitmap specified in the file to set the window pattern.
You can make your own bitmap files(little pictures) using the
bitmap(1) program. The entire background will be made up of
repeated tiles of the bitmap.
-mod x y Thisisused if you want a plaid-like grid pattern on your
screen. x and y are integersranging from 1 to 16. Try the
different combinations. Zero and negative numbersare taken
as1.
-gray Make the entire background gray. (Easier on the eyes.)
-grey Make the entire background grey.
-fg col or Use col or asthe foreground color. Foreground and back-
ground colorsare meaningful only in combination with
-cursor, -bitmap, or -mod.
-bg col or Use col or asthe background color.
-rv Thisexchangesthe foreground and background colors.
Normally the foreground color isblack and the background
color iswhite.
-solid col or Thissetsthe background of the root window to the specified
color. Thisoption isonly useful on color servers.
-name st r i ng Set the name of the root window to st r i ng. There isno default
value. Usually a name isassigned to a window so that the
window manager can use a text representation when the
window isiconified. Thisoption isunused because you cant
iconify the background.
-display di spl ay Specifiesthe server to connect to; see X(1).
SEE ALSO
X(1), xset(1), xrdb(1)
AUTHOR
Mark Lillibridge (MIT Project Athena)
X Version 11 Release6
xsm
xsmX Session Manager
SYNOPSIS
xsm [-display di spl ay ] [-session sessi onName] [-verbose]
DESCRIPTION
xsm isa session manager. A session isa group of applications, each of which hasa particular state. xsm allowsyou to create
arbitrary sessions. For example, you might have a light session, a development session, or an xterminal session. Each session
can have itsown set of applications. Within a session, you can perform a checkpoint to save application state, or a shutdown
to save state and exit the session. When you log back in to the system, you can load a specific session, and you can delete
sessionsyou no longer want to keep.
695
Some session managerssimply allow you to manually specify a list of applicationsto be started in a session. xsm ismore
powerful because it letsyou run applicationsand have them automatically become part of the session. On a simple level, xsm
isuseful because it givesyou thisability to easily define which applicationsare in a session. The true power of xsm, however,
can be taken advantage of when more and more applicationslearn to save and restore their state.
OPTIONS
display di spl ay Causesxsm to connect to the specified X display.
session sessi onName Causesxsm to load the specified session, bypassing the session
menu.
verbose Turnson debugging information.
SETUP
.xsession FILE
Using xsm requiresa change to your .xsession file:
The last program executed by your .xsession file should be xsm. With thisconfiguration, when the user choosesto shut
down the session using xsm, the session will truly be over.
Because the goal of the session manager isto restart clientswhen logging into a session, your .xsession file, in general, should
not directly start up applications. Rather, the applicationsshould be started within a session. When xsm shutsdown the
session, xsm will know to restart these applications. Note, however, that there are some typesof applicationsthat are not
session aware. xsm enablesyou to manually add these applicationsto your session. (See the subsection titled Client List.)
SM_SAVE_DIR ENVIRONMENT VARIABLE
If the SM_SAVE_DIR environment variable isdefined, xsm will save all configuration filesin thisdirectory. Otherwise, they will
be stored in the usershome directory. Session-aware applicationsare also encouraged to save their checkpoint filesin the
SM_SAVE_DIR directory, although the user should not depend on thisconvention.
DEFAULT STARTUP APPLICATIONS
The first time xsm isstarted, it will need to locate a list of applicationsto start up. For example, thislist might include a
window manager, a session management proxy, and an xterm. xsm will first look for the file .xsmstartup in the usershome
directory. If that file doesnot exist, it will look for the system.xsm file that wasset up at installation time. Note that xsm
providesa failsafe option when the user choosesa session to start up. The failsafe option simply loadsthe default
applicationsdescribed above.
Each line in the startup file should contain a command to start an application. A sample startup file might look this:
<start of file>
twm
smproxy
xterm
<end of file>
STARTING A SESSION
When xsm startsup, it first checksto see if the user previously saved any sessions. If no saved sessionsexist, xsm startsup a set
of default applications(asdescribed above in the subsection titled Default Startup Applications). If at least one session
exists, a Session menu ispresented. The [-session sessionName] option forcesthe specified session to be loaded, bypassing
the session menu.
THE SESSION MENU
The Session menu presentsthe user with a list of sessionsto choose from. The user can change the currently selected session
with the mouse, or by using the up and down arrowson the keyboard. Note that sessionsthat are locked (that is, running on
a different display) cannot be loaded or deleted.
xsm
Part I: User Commands
696
The following operationscan be performed from the Session menu:
Load Session Pressing thisbutton will load the currently selected session.
Alternatively, hitting the Return key will also load the
currently selected session, or the user can double-click a session
from the list.
Delete Session Thisoperation will delete the currently selected session, along
with all of the application checkpoint filesassociated with the
session. After pressing thisbutton, the user will be asked to
pressthe button a second time in order to confirm the
operation.
Default/Fail Safe xsm will start up a set of default applications(asdescribed
earlier in the section titled Default Startup Applications).
Thisisuseful when the user wantsto start a fresh session, or if
the session configuration fileswere corrupted and the user
wantsa failsafe session.
Cancel Pressing thisbutton will cause xsm to exit. It can also be used
to cancel a Delete Session operation.
CONTROLLING A SESSION
After xsm determineswhich session to load, it bringsup itsmain window, then startsup all applicationsthat are part of the
session. The title bar for the session managersmain window will contain the name of the session that wasloaded.
The following optionsare available from xsmsmain window:
Client List Pressing thisbutton bringsup a window containing a list of all
clientsthat are in the current session. For each client, the host
machine that the client isrunning on ispresented. Asclients
are added and removed from the session, thislist isupdated
to reflect the changes. The user isable to control how these
clientsare restarted.
By pressing the View Propertiesbutton, the user can view the
session management propertiesassociated with the currently
selected client.
By pressing the Clone button, the user can start a copy of the
selected application.
By pressing the Kill Client button, the user can remove a client
from the session. By selecting a restart hint from the Restart
Hint menu, the user can control the restarting of a client. The
following hintsare available:
I The Restart If Running hint indicatesthat the client
should be restarted in the next session if it isconnected to
the session manager at the end of the current session.
I The Restart Anyway hint indicatesthat the client should
be restarted in the next session even if it exitsbefore the
current session isterminated.
I The Restart Immediately hint issimilar to the Restart
Anyway hint, but in addition, the client ismeant to run
continuously. If the client exits, the session manager will
try to restart it in the current session.
I The Restart Never hint indicatesthat the client should not
be restarted in the next session.
697
Note that all X applicationsmay not be session aware.
Applicationsthat are not session aware are onesthat do not
support the X Session Management Protocol or they cannot
be detected by the Session Management Proxy. (See the
subsection titled The Proxy.). xsm allowsthe user to
manually add such applicationsto the session. The bottom of
the Client List window containsa text entry field into which
application commandscan be typed. Each command should
go on itsown line. Thisinformation will be saved with the
session at checkpoint or shutdown time. When the session is
restarted, xsm will restart these applicationsin addition to the
regular session aware applications. Pressing the Done button
removesthe Client List window.
Session Log The Session Log window presentsuseful information about
the session. For example, when a session isrestarted, all of the
restart commandswill be displayed in the log window.
Checkpoint By performing a checkpoint, all applicationsthat are in the
session are asked to save their state. Not every application will
save itscomplete state, but at a minimum, the session manager
isguaranteed that it will receive the command required to
restart the application (along with all command-line options).
A window manager participating in the session should
guarantee that the applicationswill come back up with the
same window configurations.
If the session being checkpointed wasnever assigned a name,
the user will be required to specify a session name. Otherwise,
the user can perform the checkpoint using the current session
name, or a new session name can be specified. If the session
name specified already exists, the user will be given the
opportunity to specify a different name or to overwrite the
already existing session. Note that a session that islocked can
not be overwritten.
When performing a checkpoint, the user must specify a Save
Type that informsthe applicationsin the session how much
state they should save.
The Local type indicatesthat the application should save
enough information to restore the state asseen by the user. It
should not affect the state asseen by other users. For example,
an editor would create a temporary file containing the contents
of itsediting buffer, the location of the cursor, and so on.
The Global type indicatesthat the application should commit
all of itsdata to permanent, globally accessible storage. For
example, the editor would simply save the edited file.
The Both type indicatesthat the application should do both of
these. For example, the editor would save the edited file, then
create a temporary file with information such asthe location of
the cursor, and so on.
In addition to the Save Type, the user must specify an Interact
Style.
The None type indicatesthat the application should not
interact with the user while saving state.
xsm
Part I: User Commands
698
The Errors type indicatesthat the application may interact
with the user only if an error condition arises.
The Any type indicatesthat the application may interact with
the user for any purpose. Note that xsm will only allow one
application to interact with the user at a time.
After the checkpoint iscompleted, xsm will, if necessary,
display a window containing the list of applicationsthat did
not report a successful save of state.
Shutdown A shutdown providesall of the optionsfound in a checkpoint,
but, in addition, can cause the session to exit. Note that if the
interaction style isErrors or Any, the user may cancel the
shutdown. The user may also cancel the shutdown if any of
the applicationsreport an unsuccessful save of state. The user
may choose to shut down the session with or without
performing a checkpoint.
THE PROXY
Because not all applicationshave been ported to support the X Session Management Protocol, a proxy service existsto enable
old clientsto work with the session manager. In order for the proxy to detect an application joining a session, one of the
following must be true:
I The application mapsa top-level window containing the WM_CLIENT_LEADER property. Thisproperty providesa pointer to
the client leader window that containsthe WM_CLASS, WM_NAME, WM_COMMAND, and WM_CLIENT_MACHINE properties.
or
I The application mapsa top-level window that doesnot contain the WM_CLIENT_LEADER property. However, thistop-level
window containsthe WM_CLASS, WM_NAME, WM_COMMAND, and WM_CLIENT_MACHINE properties.
An application that supportsthe WM_SAVE_YOURSELF protocol will receive a WM_SAVE_YOURSELF client message each time the
session manager issuesa checkpoint or shutdown. Thisallowsthe application to save state. If an application doesnot support
the WM_SAVE_YOURSELF protocol, then the proxy will provide enough information to the session manager to restart the
application (using WM_COMMAND), but no state will be restored.
REMOTE APPLICATIONS
xsm requiresa remote execution protocol in order to restart applicationson remote machines. Currently, xsm supportsthe
rstart protocol. In order to restart an application on remote machine X, machine X must have rstart installed. In the
future, additional remote execution protocolsmay be supported.
SEE ALSO
smproxy(1), rstart(1)
AUTHORS
Ralph Mor (X Consortium), Jordan Brown (Quarterdeck Office Systems)
X Version 11 Release6
xsmclient
xsmclientX session manager tester
SYNOPSIS
xsmclient [ TBD ]
699
DESCRIPTION
The xsmclient program isused to test the session manager
AUTHOR
Ralph Mor (X Consortium)
X Version 11 Release6
xstdcmap
xstdcmapX standard colormap utility
SYNOPSIS
xstdcmap [-all] [-best] [-blue] [-default] [-delete map] [-display di spl ay]
[-gray] [-green] [-help] [-red] [-verbose]
DESCRIPTION
The xstdcmap utility can be used to selectively define standard colormap properties. It isintended to be run from a usersX
startup script to create standard colormap definitionsin order to facilitate sharing of scarce colormap resourcesamong
clients. Where at all possible, colormapsare created with read-only allocations.
OPTIONS
The following optionsmay be used with xstdcmap:
all Thisoption indicatesthat all six standard colormap properties
should be defined on each screen of the display. Not all screens
will support visualsunder which all six standard colormap
propertiesare meaningful. xst-dcmap will determine the best
allocationsand visualsfor the colormap propertiesof a screen.
Any previously existing standard colormap propertieswill be
replaced.
best Thisoption indicatesthat the RGB_BEST_MAP should be defined.
blue Thisoption indicatesthat the RGB_BLUE_MAP should be defined.
default Thisoption indicatesthat the RGB_DEFAULT_MAP should be
defined.
delete map Thisoption specifiesthat a specific standard colormap
property, or all such properties, should be removed. map may
be one of: default, best, red, green, blue, gray, or all.
display di spl ay Thisoption specifiesthe host and display to use; see X(1).
gray Thisoption indicatesthat the RGB_GRAY_MAP should be defined.
green Thisoption indicatesthat the RGB_GREEN_MAP should be
defined.
help Thisoption indicatesthat a brief description of the command-
line argumentsshould be printed on the standard error. This
will be done whenever an unhandled argument isgiven to
xstdcmap.
red Thisoption indicatesthat the RGB_RED_MAP should be defined.
verbose Thisoption indicatesthat xstdcmap should print logging
information asit parsesitsinput and definesthe standard
colormap properties.
xstdcmap
Part I: User Commands
700
ENVIRONMENT
DISPLAY To get default host and display number
SEE ALSO
X(1)
AUTHOR
Donna Converse (MIT X Consortium)
X Version 11 Release6
xterm
xtermTerminal emulator for X
SYNOPSIS
xterm [t ool ki t opt i on ...] [option ...]
DESCRIPTION
The xterm program isa terminal emulator for the X Window System. It providesDEC VT102- and Tektronix 4014-
compatible terminalsfor programsthat cant use the window system directly. If the underlying operating system supports
terminal resizing capabilities(for example, the SIGWINCH signal in systemsderived from 4.3bsd), xterm will use the facilitiesto
notify programsrunning in the window whenever it isresized.
The VT102 and Tektronix 4014 terminalsall have their own windowsso that you can edit text in one and look at graphics
in the other at the same time. To maintain the correct aspect ratio (height/width), Tektronix graphicswill be restricted to the
largest box with a 4014saspect ratio that will fit in the window. Thisbox islocated in the upper-left area of the window.
Although both windowsmay be displayed at the same time, one of them isconsidered the active window for receiving
keyboard input and terminal output. Thisisthe window that containsthe text cursor. The active window can be chosen
through escape sequences, the VT Optionsmenu in the VT102 window, and the Tek Optionsmenu in the 4014 window.
EMULATIONS
The VT102 emulation isfairly complete, but doesnot support smooth scrolling, VT52 mode, the blinking character
attribute nor the double-wide and double-size character sets. termcap(5) entriesthat work with xterm include xterm, vt102,
vt100, and ansi, and xterm automatically searchesthe termcap file in thisorder for these entriesand then setsthe TERM and the
TERMCAP environment variables.
Many of the special xterm featuresmay be modified under program control through a set of escape sequencesdifferent from
the standard VT102 escape sequences. (See the Xterm Control Sequences document.)
The Tektronix 4014 emulation isalso fairly good. It supports12-bit graphicsaddressing, scaled to the window size. Four
different font sizesand five different linestypesare supported. There isno write-through or defocused mode support. The
Tektronix text and graphicscommandsare recorded internally by xterm and may be written to a file by sending the COPY
escape sequence (or through the Tektronix menu, discussed later in thissection). The name of the file will be COPYyyMM
dd. hh: mm: ss , where yy, MM, dd, hh, mm, and ssare the year, month, day, hour, minute, and second when the COPY was
performed (the file iscreated in the directory xterm isstarted in, or the home directory for a login xterm).
OTHER FEATURES
xterm automatically highlightsthe text cursor when the pointer entersthe window (selected) and unhighlightsit when the
pointer leavesthe window (unselected). If the window isthe focuswindow, then the text cursor ishighlighted no matter
where the pointer is. In VT102 mode, there are escape sequencesto activate and deactivate an alternate screen buffer, which
701
isthe same size asthe display area of the window. When activated, the current screen issaved and replaced with the alternate
screen. Saving of linesscrolled off the top of the window isdisabled until the normal screen isrestored. The termcap(5) entry
for xterm allowsthe visual editor vi(1) to switch to the alternate screen for editing and to restore the screen on exit.
In either VT102 or Tektronix mode, there are escape sequencesto change the name of the windows. See xterm Control
Sequencesfor details.
OPTIONS
The xterm terminal emulator acceptsall of the standard X Toolkit command-line optionsaswell asthe following (if the
option beginswith a + instead of a , the option isrestored to itsdefault value):
help Thiscausesxterm to print out a verbose message describing its
options.
132 Normally, the VT102 DECCOLM escape sequence that switches
between 80 and 132 column mode isignored. Thisoption
causesthe DECCOLM escape sequence to be recognized, and the
xterm window will resize appropriately.
ah Thisoption indicatesthat xterm should alwayshighlight the
text cursor. By default, xterm will display a hollow text cursor
whenever the focusislost or the pointer leavesthe window.
ah Thisoption indicatesthat xterm should do text cursor
highlighting based on focus.
b number Thisoption specifiesthe size of the inner border (the distance
between the outer edge of the charactersand the window
border) in pixels. The default is2.
cb Set the vt100 resource cutToBeginningOfLine to False.
cb Set the vt100 resource cutToBeginningOfLine to True.
cc char act er cl as sr ange: Thissetsclassesindicated by the given rangesto use in
val ue[,...] selecting by words. See the subsection Character Classes.
cn Thisoption indicatesthat newlinesshould not be cut in line-
mode selections.
cn Thisoption indicatesthat newlinesshould be cut in line-mode
selections.
cr col or Thisoption specifiesthe color to use for text cursor. The
default isto use the same foreground color that isused for text.
cu Thisoption indicatesthat xterm should work around a bug in
the more(1) program that causesit to incorrectly display lines
that are exactly the width of the window and are followed by a
line beginning with a tab (the leading tabsare not displayed).
Thisoption isso named because it wasoriginally thought to
be a bug in the curses(3x) cursor motion package.
cu Thisoption indicatesthat xterm should not work around the
more(3x) bug mentioned in the preceding paragraph.
e pr ogr am Thisoption specifiesthe program (and itscommand-line
[ ar gument s . . . ] arguments) to be run in the xterm window. It also setsthe
window title and icon name to be the basename of the
program being executed if neither T nor n are given on
the command line. Thismust be the last option on the
command line.
fb f ont Thisoption specifiesa font to be used when displaying bold
text. Thisfont must be the same height and width asthe
normal font. If only one of the normal or bold fontsis
xterm
Part I: User Commands
702
specified, it will be used asthe normal font and the bold font
will be produced by overstriking thisfont. The default isto do
overstriking of the normal font.
im Turn on the useInsertMode resource.
+im Turn off the useInsertMode resource.
j Thisoption indicatesthat xterm should do jump scrolling.
Normally, text isscrolled one line at a time; thisoption allows
xterm to move multiple linesat a time so that it doesnt fall as
far behind. Itsuse isstrongly recommended because it makes
xterm much faster when scanning through large amountsof
text. The VT100 escape sequencesfor enabling and disabling
smooth scroll aswell asthe VT Optionsmenu can be used to
turn thisfeature on or off.
j Thisoption indicatesthat xterm should not do jump scrolling.
ls Thisoption indicatesthat the shell that isstarted in the xterm
window will be a login shell (that is, the first character of
argv[0] will be a dash, indicating to the shell that it should
read the users.login or .profile).
ls Thisoption indicatesthat the shell that isstarted should not
be a login shell (that is, it will be a normal subshell).
mb Thisoption indicatesthat xterm should ring a margin bell
when the user typesnear the right end of a line. Thisoption
can be turned on and off from the VT Optionsmenu.
mb Thisoption indicatesthat margin bell should not be rung.
mcmi l l i seconds Thisoption specifiesthe maximum time between multiclick
selections.
ms col or Thisoption specifiesthe color to be used for the pointer
cursor. The default isto use the foreground color.
nb number Thisoption specifiesthe number of charactersfrom the right
end of a line at which the margin bell, if enabled, will ring.
The default is10.
rw Thisoption indicatesthat reverse-wraparound should be
allowed. Thisallowsthe cursor to back up from the leftmost
column of one line to the rightmost column of the previous
line. Thisisvery useful for editing long shell command lines
and isencouraged. Thisoption can be turned on and off from
the VT Optionsmenu.
rw Thisoption indicatesthat reverse-wraparound should not be
allowed.
aw Thisoption indicatesthat auto-wraparound should be
allowed. Thisallowsthe cursor to automatically wrap to the
beginning of the next line when it isat the rightmost position
of a line and text isoutput.
aw Thisoption indicatesthat auto-wraparound should not be
allowed.
s Thisoption indicatesthat xterm may scroll asynchronously,
meaning that the screen doesnot have to be kept completely
up to date while scrolling. Thisallowsxterm to run faster when
network latenciesare very high and istypically useful when
running acrossa very large Internet or many gateways.
703
s Thisoption indicatesthat xterm should scroll synchronously.
sb Thisoption indicatesthat some number of linesthat are
scrolled off the top of the window should be saved and that a
scrollbar should be displayed so that those linescan be viewed.
Thisoption may be turned on and off from the VT Options
menu.
sb Thisoption indicatesthat a scrollbar should not be displayed.
sf Thisoption indicatesthat Sun Function Key escape codes
should be generated for function keys.
sf Thisoption indicatesthat the standard escape codesshould be
generated for function keys.
si Thisoption indicatesthat output to a window should not
automatically reposition the screen to the bottom of the
scrolling region. Thisoption can be turned on and off from
the VT Optionsmenu.
si Thisoption indicatesthat output to a window should cause it
to scroll to the bottom.
sk Thisoption indicatesthat pressing a key while using the
scrollbar to review previouslinesof text should cause the
window to be repositioned automatically in the normal
position at the bottom of the scroll region.
sk Thisoption indicatesthat pressing a key while using the
scrollbar should not cause the window to be repositioned.
sl number Thisoption specifiesthe number of linesto save that have
been scrolled off the top of the screen. The default is64.
t Thisoption indicatesthat xterm should start in Tektronix
mode, rather than in VT102 mode. Switching between the
two windowsisdone using the Optionsmenus.
t Thisoption indicatesthat xterm should start in VT102 mode.
tm st r i ng Thisoption specifiesa seriesof terminal setting keywords
followed by the charactersthat should be bound to those
functions, similar to the stty program. Allowable keywords
include: intr, quit, erase, kill, eof, eol, swtch, start, stop,
brk, susp, dsusp, rprnt, flush, weras, and lnext. Control
charactersmay be specified as^char (for example, ^c or ^u) and
^? may be used to indicate delete.
tn name Thisoption specifiesthe name of the terminal type to be set in
the TERM environment variable. Thisterminal type must exist
in the termcap(5) database and should have li# and co# entries.
ut Thisoption indicatesthat xterm shouldnt write a record into
the system log file /etc/utmp.
ut Thisoption indicatesthat xterm should write a record into the
system log file /etc/utmp.
vb Thisoption indicatesthat a visual bell ispreferred over an
audible one. Instead of ringing the terminal bell whenever a
Ctrl+G isreceived, the window will be flashed.
vb Thisoption indicatesthat a visual bell should not be used.
wf Thisoption indicatesthat xterm should wait for the window to
be mapped the first time before starting the subprocessso that
the initial terminal size settingsand environment variablesare
xterm
Part I: User Commands
704
correct. It isthe applicationsresponsibility to catch subse-
quent terminal size changes.
wf Thisoption indicatesthat xterm show not wait before starting
the subprocess.
C Thisoption indicatesthat thiswindow should receive console
output. Thisisnot supported on all systems. To obtain
console output, you must be the owner of the console device,
and you must have read and write permission for it. If you are
running X under xdm on the console screen, you may need to
have the session startup and reset programsexplicitly change
the ownership of the console device in order to get thisoption
to work.
Sccn Thisoption specifiesthe last two lettersof the name of a
pseudo-terminal to use in slave mode, plusthe number of the
inherited file descriptor. The option isparsed %c%c%d. This
allowsxterm to be used asan input and output channel for an
existing program and issometimesused in specialized
applications.
The following command-line argumentsare provided for compatibility with older versions. They may not be supported in
the next release asthe X Toolkit providesstandard optionsthat accomplish the same task.
%geom Thisoption specifiesthe preferred size and position of the
Tektronix window. It isshorthand for specifying the
*tekGeometry resource.
geom Thisoption specifiesthe preferred position of the icon
window. It isshorthand for specifying the *iconGeometry
resource.
T st r i ng Thisoption specifiesthe title for xtermswindows. It is
equivalent to title.
n st r i ng Thisoption specifiesthe icon name for xtermswindows. It is
shorthand for specifying the *iconName resource. Note that this
isnot the same asthe toolkit option name (see below). The
default icon name isthe application name.
r Thisoption indicatesthat reverse video should be simulated by
swapping the foreground and background colors. It is
equivalent to rv.
w number Thisoption specifiesthe width in pixelsof the border
surrounding the window. It isequivalent to borderwidth or
bw.
The following standard X Toolkit command-line argumentsare commonly used with xterm:
bg col or Thisoption specifiesthe color to use for the background of the
window. The default iswhite.
bd col or Thisoption specifiesthe color to use for the border of the
window. The default isblack.
bw number Thisoption specifiesthe width in pixelsof the border
surrounding the window.
fg col or Thisoption specifiesthe color to use for displaying text. The
default isblack.
fn f ont Thisoption specifiesthe font to be used for displaying normal
text. The default isfixed.
705
name name Thisoption specifiesthe application name under which
resourcesare to be obtained, rather than the default executable
filename. Name should not contain . or * characters.
title st r i ng Thisoption specifiesthe window title string, which may be
displayed by window managersif the user so chooses. The
default title isthe command line specified after the e option,
if any; otherwise, the application name.
rv Thisoption indicatesthat reverse video should be simulated by
swapping the foreground and background colors.
geometry geomet r y Thisoption specifiesthe preferred size and position of the
VT102 window; see X(1).
display di spl ay Thisoption specifiesthe X server to contact; see X(1).
xrm r esour cest r i ng Thisoption specifiesa resource string to be used. Thisis
especially useful for setting resourcesthat do not have separate
command-line options.
iconic Thisoption indicatesthat xterm should ask the window
manager to start it asan icon rather than asthe normal
window.
RESOURCES
The program understandsall of the core X Toolkit resource namesand classesaswell asthe following:
iconGeometry (class IconGeometry) Specifiesthe preferred size and position of the application
when iconified. It isnot necessarily obeyed by all window
managers.
iconName (class IconName) Specifiesthe icon name. The default isthe application name.
termName (class TermName) Specifiesthe terminal type name to be set in the TERM
environment variable.
title (class Title) Specifiesa string that may be used by the window manager
when displaying thisapplication.
ttyModes (class TtyModes) Specifiesa string containing terminal setting keywordsand the
charactersto which they may be bound. Allowable keywords
include intr, quit, erase, kill, eof, eol, swtch, start, stop,
brk, susp, dsusp, rprnt, flush, weras, and lnext. Control
charactersmay be specified aschar (for example, c or u) and
? may be used to indicate delete. Thisisvery useful for
overriding the default terminal settingswithout having to do
an stty every time an xterm isstarted.
useInsertMode Force use of insert mode by adding appropriate entriesto the
(class UseInsertMode) TERMCAP environment variable. Thisisuseful if the system
termcap isbroken. The default isFalse.
utmpInhibit (class UtmpInhibit) Specifieswhether or not xterm should try to record the users
terminal in /etc/utmp.
sunFunctionKeys Specifieswhether or not Sun Function Key escape codes
(class SunFunctionKeys) should be generated for function keysinstead of standard
escape sequences.
waitForMap (class WaitForMap) Specifieswhether or not xterm should wait for the initial
window map before starting the subprocess. The default is
false.
xterm
Part I: User Commands
706
The following resourcesare specified aspart of the vt100 widget (classVT100):
allowSendEvents Specifieswhether or not synthetic key and button
(class AllowSendEvents) events(generated using the X protocol SendEvent request)
should be interpreted or discarded. The default isFalse,
meaning they are discarded. Note that allowing such events
createsa very large security hole.
alwaysHighlight Specifieswhether or not xterm should alwaysdisplay
(class AlwaysHighlight) a highlighted text cursor. By default, a hollow text cursor is
displayed whenever the pointer movesout of the window or
the window losesthe input focus.
appcursorDefault If true, the cursor keysare initially in application mode.
(class AppcursorDefault) The default isfalse.
appkeypadDefault If true, the keypad keysare initially in application mode.
(class AppkeypadDefault) The default isfalse.
autoWrap (class AutoWrap) Specifieswhether or not auto-wraparound should be enabled.
The default istrue.
bellSuppressTime Number of millisecondsafter a bell command issent during
(class BellSuppressTime) which additional bellswill be suppressed. Default is200. If set
non-zero, additional bellswill also be suppressed until the
server reportsthat processing of the first bell hasbeen com-
pleted; thisfeature ismost useful with the visible bell.
boldFont (class BoldFont) Specifiesthe name of the bold font to use instead of
overstriking.
c132 (class C132) Specifieswhether or not the VT102 DECCOLM escape sequence
should be honored. The default isfalse.
cutNewline If false, triple-clicking to select a line doesnot
(class CutNewline) include the Newline at the end of the line. If true, the Newline
isselected. The default istrue.
cutToBeginningOfLine If false, triple-clicking to select a line selectsonly from
(class CutToBeginningOfLine) the current word forward. If true, the entire line isselected.
The default istrue.
charClass (class CharClass) Specifiescomma-separated listsof character classbindingsof
the form [low]high:value. These are used in determining
which setsof charactersshould be treated the same when
doing cut and paste. See the section on specifying character
classes.
curses (class Curses) Specifieswhether or not the last column bug in more(1) should
be worked around. See the cu option for details. The default
isfalse.
background Specifiesthe color to use for the background of the window.
(class Background) The default iswhite.
foreground Specifiesthe color to use for displaying text in the window.
(class Foreground) Setting the classname instead of the instance name isan easy
way to have everything that would normally appear in the text
color change color. The default isblack.
cursorColor Specifiesthe color to use for the text cursor. The
(class Foreground) default isblack.
eightBitInput If true, metacharactersinput from the keyboard are presented
(class EightBitInput) asa single character with the eighth bit turned on. If false,
metacharactersare converted into a two-character sequence
with the character itself preceded by ESC. The default istrue.
707
eightBitOutput Specifieswhether or not eight-bit characterssent from the
(class EightBitOutput) host should be accepted asisor stripped when printed. The
default istrue.
font (class Font) Specifiesthe name of the normal font. The default isfixed.
font1 (class Font1) Specifiesthe name of the first alternative font.
font2 (class Font2) Specifiesthe name of the second alternative font.
font3 (class Font3) Specifiesthe name of the third alternative font.
font4 (class Font4) Specifiesthe name of the fourth alternative font.
font5 (class Font5) Specifiesthe name of the fifth alternative font.
font6 (class Font6) Specifiesthe name of the sixth alternative font.
geometry (class Geometry) Specifiesthe preferred size and position of the VT102
window.
hpLowerleftBugCompat Specifieswhether to work around a bug in HPsxdb, which
(class HpLowerleftBugCompat) ignorestermcap and alwayssendsESC F to move to the lower-
left corner. true causesxterm to interpret ESC F asa request
to move to the lower-left corner of the screen. The default is
false.
internalBorder Specifiesthe number of pixelsbetween the charactersand the
(class BorderWidth) window border. The default is2.
jumpScroll Specifieswhether or not jump scroll should be used. The
(class JumpScroll) default istrue.
loginShell Specifieswhether or not the shell to be run in the window
(class LoginShell) should be started asa login shell. The default isfalse.
marginBell Specifieswhether or not the bell should be run when the user
(class MarginBell) typesnear the right margin. The default isfalse.
multiClickTime Specifiesthe maximum time in millisecondsbetween
(class MultiClickTime) multiclick select events. The default is250 milliseconds.
multiScroll Specifieswhether or not scrolling should be done asynchro-
(class MultiScroll) nously. The default isfalse.
nMarginBell (class Column) Specifiesthe number of charactersfrom the right margin at
which the margin bell should be rung, when enabled.
pointerColor Specifiesthe foreground color of the pointer. The default is
(class Foreground) XtDefaultForeground.
pointerColorBackground Specifiesthe background color of the pointer. The default is
(class Background) XtDefaultBackground.
pointerShape Specifiesthe name of the shape of the pointer. The default is
(class Cursor) xterm.
resizeGravity Affectsthe behavior when the window isresized to be taller or
(class ResizeGravity) shorter. NorthWest specifiesthat the top line of text on the
screen stay fixed. If the window ismade shorter, linesare
dropped from the bottom; if the window ismade taller, blank
linesare added at the bottom. Thisiscompatible with the
behavior in R4. SouthWest (the default) specifiesthat the
bottom line of text on the screen stay fixed. If the window is
made taller, additional saved lineswill be scrolled down onto
the screen; if the window ismade shorter, lineswill be scrolled
off the top of the screen, and the top saved lineswill be
dropped.
reverseVideo Specifieswhether reverse video should be simulated. The
(class ReverseVideo) default isfalse.
xterm
Part I: User Commands
708
reverseWrap Specifieswhether or not reverse-wraparound should be
(class ReverseWrap) enabled. The default isfalse.
saveLines Specifiesthe number of linesto save beyond the top of the
(class SaveLines) screen when a scrollbar isturned on. The default is64.
scrollBar Specifieswhether or not the scrollbar should be displayed.
(class ScrollBar) The default isfalse.
scrollTtyOutput Specifieswhether or not output to the terminal should
(class ScrollCond) automatically cause the scrollbar to go to the bottom of the
scrolling region. The default istrue.
scrollKey Specifieswhether or not pressing a key should automatically
(class ScrollCond) cause the scrollbar to go to the bottom of the scrolling region.
The default isfalse.
scrollLines Specifiesthe number of linesthat the scroll-back and scroll-
(class ScrollLines) forw actionsshould use asa default. The default value is1.
signalInhibit Specifieswhether or not the entriesin the Main Optionsmenu
(class SignalInhibit) for sending signalsto xterm should be disallowed. The default
isfalse.
tekGeometry Specifiesthe preferred size and position of the Tektronix
(class Geometry) window.
tekInhibit Specifieswhether or not the escape sequence to enter
(class TekInhibit) Tektronix mode should be ignored. The default isfalse.
tekSmall (class TekSmall) Specifieswhether or not the Tektronix mode window should
start in itssmallest size if no explicit geometry isgiven. Thisis
useful when running xterm on displayswith small screens. The
default isfalse.
tekStartup Specifieswhether or not xterm should start up in Tektronix
(class TekStartup) mode. The default isfalse.
titeInhibit Specifieswhether or not xterm should remove ti and te
(class TiteInhibit) termcap entries(used to switch between alternate screenson
startup of many screen-oriented programs) from the TERMCAP
string. If set, xterm also ignoresthe escape sequence to switch
to the alternate screen.
translations Specifiesthe key and button bindingsfor menus, selections,
(class Translations) programmed strings, and so on. See the ACTIONS
subsection, later in thissection.
visualBell Specifieswhether or not a visible bell (that is, flashing) should
(class VisualBell) be used instead of an audible bell when Control-G isreceived.
The default isfalse.
The following resourcesare specified aspart of the tek4014 widget (classTek4014):
width (class Width) Specifiesthe width of the Tektronix window in pixels.
height (class Height) Specifiesthe height of the Tektronix window in pixels.
fontLarge (class Font) Specifiesthe large font to use in the Tektronix window.
font2 (class Font) Specifiesfont number 2 to use in the Tektronix window.
font3 (class Font) Specifiesfont number 3 to use in the Tektronix window.
fontSmall (class Font) Specifiesthe small font to use in the Tektronix window.
initialFont (class InitialFont) Specifieswhich of the four Tektronix fontsto use initially.
Valuesare the same asfor the set-tek-text action. The default
islarge.
709
ginTerminator Specifieswhat character(s) should follow a GIN
(class GinTerminator) report or statusreport. The possibilitiesare none, which sends
no terminating characters, CRonly, which sendsCR, and CR&EOT,
which sendsboth CR and EOT. The default isnone.
The resourcesthat may be specified for the variousmenusare described in the documentation for the Athena SimpleMenu
widget. The name and classesof the entriesin each of the menusare listed next.
The mainMenu hasthe following entries:
securekbd (class SmeBSB) Thisentry invokesthe secure() action.
allowsends (class SmeBSB) Thisentry invokesthe allow-send-events(toggle) action.
redraw (class SmeBSB) Thisentry invokesthe redraw() action.
line1 (class SmeLine) Thisisa separator.
suspend (class SmeBSB) Thisentry invokesthe send-signal(tstp) action on systems
that support job control.
continue (class SmeBSB) Thisentry invokesthe send-signal(cont) action on systems
that support job control.
interrupt (class SmeBSB) Thisentry invokesthe send-signal(int) action.
hangup (class SmeBSB) Thisentry invokesthe send-signal(hup) action.
terminate (class SmeBSB) Thisentry invokesthe send-signal(term) action.
kill (class SmeBSB) Thisentry invokesthe send-signal(kill) action.
line2 (class SmeLine) Thisisa separator.
quit (class SmeBSB) Thisentry invokesthe quit() action.
The vtMenu hasthe following entries:
scrollbar (class SmeBSB) Thisentry invokesthe set-scrollbar(toggle) action.
jumpscroll (class SmeBSB) Thisentry invokesthe set-jumpscroll(toggle) action.
reversevideo (class SmeBSB) Thisentry invokesthe set-reverse-video(toggle) action.
autowrap (class SmeBSB) Thisentry invokesthe set-autowrap(toggle) action.
reversewrap (class SmeBSB) Thisentry invokesthe set-reversewrap(toggle) action.
autolinefeed (class SmeBSB) Thisentry invokesthe set-autolinefeed(toggle) action.
appcursor (class SmeBSB) Thisentry invokesthe set-appcursor(toggle) action.
appkeypad (class SmeBSB) Thisentry invokesthe set-appkeypad(toggle) action.
scrollkey (class SmeBSB) Thisentry invokesthe set-scroll-on-key(toggle) action.
scrollttyoutput Thisentry invokesthe set-scroll-on-tty-output(toggle)
(class SmeBSB) action.
allow132 (class SmeBSB) Thisentry invokesthe set-allow132(toggle) action.
cursesemul (class SmeBSB) Thisentry invokesthe set-cursesemul(toggle) action.
visualbell (class SmeBSB) Thisentry invokesthe set-visualbell(toggle) action.
marginbell (class SmeBSB) Thisentry invokesthe set-marginbell(toggle) action.
altscreen (class SmeBSB) Thisentry iscurrently disabled.
line1 (class SmeLine) Thisisa separator.
softreset (class SmeBSB) Thisentry invokesthe soft-reset() action.
hardreset (class SmeBSB) Thisentry invokesthe hard-reset() action.
clearsavedlines (class SmeBSB) Thisentry invokesthe clear-saved-lines() action.
line2 (class SmeLine) Thisisa separator.
tekshow (class SmeBSB) Thisentry invokesthe set-visibility(tek,toggle) action.
tekmode (class SmeBSB) Thisentry invokesthe set-terminal-type(tek) action.
xterm
Part I: User Commands
710
vthide (class SmeBSB) Thisentry invokesthe set-visibility(vt,off) action.
The fontMenu hasthe following entries:
fontdefault (class SmeBSB) Thisentry invokesthe set-vt-font(d) action.
font1 (class SmeBSB) Thisentry invokesthe set-vt-font(1) action.
font2 (class SmeBSB) Thisentry invokesthe set-vt-font(2) action.
font3 (class SmeBSB) Thisentry invokesthe set-vt-font(3) action.
font4 (class SmeBSB) Thisentry invokesthe set-vt-font(4) action.
font5 (class SmeBSB) Thisentry invokesthe set-vt-font(5) action.
font6 (class SmeBSB) Thisentry invokesthe set-vt-font(6) action.
fontescape (class SmeBSB) Thisentry invokesthe set-vt-font(e) action.
fontsel (class SmeBSB) Thisentry invokesthe set-vt-font(s) action.
The tekMenu hasthe following entries:
tektextlarge (class SmeBSB) Thisentry invokesthe set-tek-text(l) action.
tektext2 (class SmeBSB) Thisentry invokesthe set-tek-text(2) action.
tektext3 (class SmeBSB) Thisentry invokesthe set-tek-text(3) action.
tektextsmall (class SmeBSB) Thisentry invokesthe set-tek-text(s) action.
line1 (class SmeLine) Thisisa separator.
tekpage (class SmeBSB) Thisentry invokesthe tek-page() action.
tekreset (class SmeBSB) Thisentry invokesthe tek-reset() action.
tekcopy (class SmeBSB) Thisentry invokesthe tek-copy() action.
line2 (class SmeLine) Thisisa separator.
vtshow (class SmeBSB) Thisentry invokesthe set-visibility(vt,toggle) action.
vtmode (class SmeBSB) Thisentry invokesthe set-terminal-type(vt) action.
tekhide (class SmeBSB) Thisentry invokesthe set-visibility(tek,toggle) action.
The following resourcesare useful when specified for the Athena Scrollbar widget:
thickness (class Thickness) Specifiesthe width in pixelsof the scrollbar.
background (class Background) Specifiesthe color to use for the background of the scrollbar.
foreground (class Foreground) Specifiesthe color to use for the foreground of the scrollbar.
The thumb of the scrollbar isa simple checkerboard pattern
alternating pixelsfor foreground and background color.
POINTER USAGE
Once the VT102 window iscreated, xterm allowsyou to select text and copy it within the same or other windows.
The selection functionsare invoked when the pointer buttonsare used with no modifiers, and when they are used with the
Shift key. The assignment of the functionsdescribed in thissubsection to keysand buttonsmay be changed through the
resource database; see the Actions subsection later in thissection.
Pointer button one (usually left) isused to save text into the cut buffer. Move the cursor to the beginning of the text, and
then hold the button down while moving the cursor to the end of the region and releasing the button. The selected text is
highlighted and issaved in the global cut buffer and made the PRIMARY selection when the button isreleased. Double-clicking
selectsby words. Triple-clicking selectsby lines. Quadruple-clicking goesback to characters, and so on. Multiple-click is
determined by the time from button up to button down, so you can change the selection unit in the middle of a selection. If
the key/button bindingsspecify that an X selection isto be made, xterm will leave the selected text highlighted for aslong as
it isthe selection owner.
711
Pointer button two (usually middle) types (pastes) the text from the PRIMARY selection, if any, otherwise from the cut
buffer, inserting it askeyboard input.
Pointer button three (usually right) extendsthe current selection. (Without lossof generality, you can swap right and left
everywhere in the rest of thisparagraph.) If pressed while closer to the right edge of the selection than the left, it extends/
contractsthe right edge of the selection. If you contract the selection past the left edge of the selection, xterm assumesyou
really meant the left edge, restoresthe original selection, then extends/contractsthe left edge of the selection. Extension starts
in the selection unit mode that the last selection or extension wasperformed in; you can multiple-click to cycle through
them.
By cutting and pasting piecesof text without trailing new lines, you can take text from several placesin different windows
and form a command to the shell, for example, or take output from a program and insert it into your favorite editor. Since
the cut buffer isglobally shared among different applications, you should regard it asa file whose contentsyou know. The
terminal emulator and other text programsshould be treating it asif it were a text file; that is, the text isdelimited by new
lines.
The scroll region displaysthe position and amount of text currently showing in the window (highlighted) relative to the
amount of text actually saved. Asmore text issaved (up to the maximum), the size of the highlighted area decreases.
Clicking button one with the pointer in the scroll region movesthe adjacent line to the top of the display window.
Clicking button three movesthe top line of the display window down to the pointer position.
Clicking button two movesthe display to a position in the saved text that correspondsto the pointersposition in the
scrollbar.
Unlike the VT102 window, the Tektronix window doesnot allow the copying of text. It doesallow Tektronix GIN mode,
and in thismode the cursor will change from an arrow to a cross. Pressing any key will send that key and the current
coordinate of the crosscursor. Pressing button one, two, or three will return the lettersl, m, and r, respectively. If the Shift
key ispressed when a pointer button ispressed, the corresponding uppercase letter issent. To distinguish a pointer button
from a key, the high bit of the character isset (but thisisbit isnormally stripped unlessthe terminal mode isRAW; see
tty(4) for details).
MENUS
Xterm hasfour menus: mainMenu, vtMenu, fontMenu, and tekMenu. Each menu popsup under the correct combinationsof key
and button presses. Most menusare divided into two sections, separated by a horizontal line. The top portion contains
variousmodesthat can be altered. A check mark appearsnext to a mode that iscurrently active. Selecting one of these modes
togglesitsstate. The bottom portion of the menu consistsof command entries; selecting one of these performsthe indicated
function.
The xterm menu popsup when the Control key and pointer button one are pressed in a window. The mainMenu contains
itemsthat apply to both the VT102 and Tektronix windows. The Secure Keyboard mode isused when typing in passwords
or other sensitive data in an unsecured environment. (See the SECURITY subsection.) Notable entriesin the command
section of the menu are the Continue, Suspend, Interrupt, Hangup, Terminate, and Kill, which send the SIGCONT, SIGTSTP,
SIGINT, SIGHUP, SIGTERM, and SIGKILL signals, respectively, to the processgroup of the processrunning under xterm (usually
the shell). The Continue function isespecially useful if the user hasaccidentally typed CTRL-Z, suspending the process.
The vtMenu setsvariousmodesin the VT102 emulation, and ispopped up when the Control key and pointer button two are
pressed in the VT102 window. In the command section of thismenu, the Soft Reset entry will reset scroll regions. Thiscan
be convenient when some program hasleft the scroll regionsset incorrectly (often a problem when using VMS or TOPS-20).
The Full Reset entry will clear the screen, reset tabsto every eight columns, and reset the terminal modes(such aswrap and
smooth scroll) to their initial statesjust after xterm hasfinished processing the command-line options.
The fontMenu setsthe font used in the VT102 window. In addition to the default font and a number of alternativesthat are
set with resources, the menu offersthe font last specified by the Set Font escape sequence (see the document Xterm Control
Sequences) and the current selection asa font name (if the PRIMARY selection isowned).
xterm
Part I: User Commands
712
The tekMenu setsvariousmodesin the Tektronix emulation, and ispopped up when the Control key and pointer button two
are pressed in the Tektronix window. The current font size ischecked in the Modessection of the menu. The PAGE entry in
the Command section clearsthe Tektronix window.
SECURITY
X environmentsdiffer in their security consciousness. Most servers, run under xdm, are capable of using a magic cookie
authorization scheme that can provide a reasonable level of security for many people. If your server isonly using a host-based
mechanism to control accessto the server (see xhost(1)), then if you enable accessfor a host and other usersare also
permitted to run clientson that same host, there isevery possibility that someone can run an application that will use the
basic servicesof the X protocol to snoop on your activities, potentially capturing a transcript of everything you type at the
keyboard. Thisisof particular concern when you want to type in a password or other sensitive data. The best solution to this
problem isto use a better authorization mechanism that host-based control, but a simple mechanism existsfor protecting
keyboard input in xterm.
The xterm menu (see Menus, earlier in thissection) containsa Secure Keyboard entry which, when enabled, ensuresthat all
keyboard input isdirected only to xterm (using the GrabKeyboard protocol request). When an application promptsyou for a
password (or other sensitive data), you can enable Secure Keyboard using the menu, type in the data, and then disable Secure
Keyboard using the menu again. Only one X client at a time can secure the keyboard, so when you attempt to enable Secure
Keyboard, it may fail. In thiscase, the bell will sound. If the Secure Keyboard succeeds, the foreground and background colors
will be exchanged (asif you selected the Reverse Video entry in the Modesmenu); they will be exchanged again when you
exit secure mode. If the colorsdo not switch, then you should be very suspiciousthat you are being spoofed. If the applica-
tion you are running displaysa prompt before asking for the password, it issafest to enter secure mode before the prompt
getsdisplayed, and to make sure that the prompt getsdisplayed correctly (in the new colors), to minimize the probability of
spoofing. You can also bring up the menu again and make sure that a check mark appearsnext to the entry.
Secure Keyboard mode will be disabled automatically if your xterm window becomesiconified (or otherwise unmapped), or
if you start up a reparenting window manager (that placesa title bar or other decoration around the window) while in Secure
Keyboard mode. (Thisisa feature of the X protocol that isnt easily overcome.) When thishappens, the foreground and
background colorswill be switched back and the bell will sound in warning.
CHARACTER CLASSES
Clicking the middle mouse button twice in rapid succession will cause all charactersof the same class(for example, letters,
whitespace, punctuation) to be selected. Since different people have different preferencesfor what should be selected (for
example, should filenamesbe selected asa whole or only the separate subnames?), the default mapping can be overridden
through the use of the charClass (class CharClass) resource.
Thisresource isa seriesof comma-separated r ange: val ue pairs. The range iseither a single number or low-high in the range
of 0 to 127, corresponding to the ASCII code for the character or charactersto be set. The value isarbitrary, although the
default table usesthe character number of the first character occurring in the set.
The default table is
static int charClass[128] = {
/* NUL SOH STX ETX EOT ENQ ACK BEL */
32, 1, 1, 1, 1, 1, 1, 1,
/* BS HT NL VT NP CR SO SI */
1, 32, 1, 1, 1, 1, 1, 1,
/* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
1, 1, 1, 1, 1, 1, 1, 1,
/* CAN EM SUB ESC FS GS RS US */
1, 1, 1, 1, 1, 1, 1, 1,
/*SP!#$%&*/
32, 33, 34, 35, 36, 37, 38, 39,
/*()*+,./*/
40, 41, 42, 43, 44, 45, 46, 47,
/*0 1 2 3 4 5 6 7 */
713
48, 48, 48, 48, 48, 48, 48, 48,
/*8 9 :;< => ?*/
48, 48, 58, 59, 60, 61, 62, 63,
/*@ABC D E F G*/
64, 48, 48, 48, 48, 48, 48, 48,
/* H I J K L M N O */
48, 48, 48, 48, 48, 48, 48, 48,
/*P QR S T UVW*/
48, 48, 48, 48, 48, 48, 48, 48,
/*XY Z [\] */
48, 48, 48, 91, 92, 93, 94, 48,
/*ab c d e fg */
96, 48, 48, 48, 48, 48, 48, 48,
/*h ijklm n o */
48, 48, 48, 48, 48, 48, 48, 48,
/*p q rs tu v w */
48, 48, 48, 48, 48, 48, 48, 48,
/*x y zf jg DEL */
48, 48, 48, 123, 124, 125, 126, 1};
For example, the string 33:48,37:48,45-47:48,64:48 indicatesthat the exclamation mark, percent sign, dash, period, slash,
and ampersand charactersshould be treated the same way ascharactersand numbers. Thisisuseful for cutting and pasting
electronic mailing addressesand filenames.
ACTIONS
It ispossible to rebind keys(or sequencesof keys) to arbitrary stringsfor input by changing the translationsfor the vt100 or
tek4014 widgets. Changing the translationsfor eventsother than key and button eventsisnot expected, and will cause
unpredictable behavior. The following actionsare provided for using within the vt100 or tek4014 translationsresources:
bell([per cent ]) Thisaction ringsthe keyboard bell at the specified percentage
above or below the base volume.
ignore() Thisaction ignoresthe event but checksfor special pointer
position escape sequences.
insert() Thisaction insertsthe character or string associated with the
key that waspressed.
insert-seven-bit() Thisaction isa synonym for insert().
insert-eight-bit() Thisaction insertsan eight-bit (Meta) version of the character
or string associated with the key that waspressed. The exact
action dependson the value of the eightBitInput resource.
insert-selection Thisaction insertsthe string found in the selection or cut
(sour cename [, ...]) buffer indicated by sourcename. Sourcesare checked in
the order given (case issignificant) until one isfound.
Commonly used selectionsinclude PRIMARY, SECONDARY, and
CLIPBOARD. Cut buffersare typically named CUT_BUFFER0
through CUT_BUFFER7.
keymap(name) Thisaction dynamically definesa new translation table whose
resource name isname with the suffix Keymap (case issignifi-
cant). The name None restoresthe original translation table.
popup-menu(menuname) Thisaction displaysthe specified pop-up menu. Valid names
(case issignificant) include mainMenu, vtMenu, fontMenu, and
tekMenu.
secure() Thisaction togglesthe Secure Keyboard mode described in the
Security subsection, and isinvoked from the securekbd entry
in mainMenu.
xterm
Part I: User Commands
714
select-start() Thisaction beginstext selection at the current pointer
location. See the subsection on Pointer Usage for informa-
tion on making selections.
select-extend() Thisaction tracksthe pointer and extendsthe selection. It
should only be bound to Motion events.
select-end Thisaction putsthe currently selected text into all of the
(dest name [, ...]) selectionsor cut buffersspecified by dest name.
select-cursor-start() Thisaction issimilar to select-start except that it beginsthe
selection at the current text cursor position.
select-cursor-end Thisaction issimilar to select-end except that it should
(dest name [, ...]) be used with select-cursor-start.
set-vt-font Thisaction setsthe font or fontscurrently being
(d/ 1/ 2/ 3/ 4/ 5/ 6/ e/ s used in the VT102 window. The first argument isa
[, nor mal f ont [ , bol df ont ]]) single character that specifiesthe font to be used: d or D
indicate the default font (the font initially used when xterm
wasstarted), 1 through 6 indicate the fontsspecified by the
font1 through font6 resources, e or E indicate the normal and
bold fontsthat have been set through escape codes(or
specified asthe second and third action arguments, respec-
tively), and s or S indicate the font selection (asmade by
programssuch asxfontsel(1)) indicated by the second action
argument.
start-extend() Thisaction issimilar to select-start except that the selection
isextended to the current pointer location.
start-cursor-extend() Thisaction issimilar to select-extend except that the selection
isextended to the current text cursor position.
string(st r i ng) Thisaction insertsthe specified text string asif it had been
typed. Quotation isnecessary if the string containswhitespace
or nonalphanumeric characters. If the string argument begins
with the characters0x, it isinterpreted asa hex character
constant.
scroll-back(count [,units]) Thisaction scrollsthe text window backward so that text that
had previously scrolled off the top of the screen isnow visible.
The count argument indicatesthe number of units(which
may be page, half page, pixel, or line) by which to scroll.
scroll-forw(count [,uni t s]) Thisaction scroll issimilar to scroll-back except that it scrolls
the other direction.
allow-send-events Thisaction set or togglesthe allowSendEvents resource and is
(on/ of f / t oggl e) also invoked by the allowsends entry in mainMenu.
redraw() Thisaction redrawsthe window and isalso invoked by the
redraw entry in mainMenu.
send-signal(si gname) Thisaction sendsthe signal named by si gname to the xterm
subprocess(the shell or program specified with the e
command-line option) and isalso invoked by the suspend,
continue, interrupt, hangup, terminate, and kill entriesin
mainMenu. Allowable signal namesare (case isnot significant)
tstp (if supported by the operating system), suspend (same as
tstp), cont (if supported by the operating system), int, hup,
term, quit, alrm, alarm (same asalrm), and kill.
quit() Thisaction sendsa SIGHUP to the subprogram and exits. It is
also invoked by the quit entry in mainMenu.
715
set-scrollbar(on/ of f / t oggl e) Thisaction togglesthe scrollbar resource and isalso invoked
by the scrollbar entry in vtMenu.
set-jumpscroll(on/ of f / t oggl e) Thisaction togglesthe jumpscroll resource and isalso invoked
by the jumpscroll entry in vtMenu.
set-reverse-video(on/ of f / t oggl e) Thisaction togglesthe reverseVideo resource and isalso
invoked by the reversevideo entry in vtMenu.
set-autowrap(on/ of f / t oggl e) Thisaction togglesautomatic wrapping of long linesand is
also invoked by the autowrap entry in vtMenu.
set-reversewrap(on/ of f / t oggl e) Thisaction togglesthe reverseWrap resource and isalso
invoked by the reversewrap entry in vtMenu.
set-autolinefeed(on/ of f / t oggl e) Thisaction togglesautomatic insertion of line-feedsand isalso
invoked by the autolinefeed entry in vtMenu.
set-appcursor(on/ of f / t oggl e) Thisaction togglesthe handling Application Cursor Key mode
and isalso invoked by the appcursor entry in vtMenu.
set-appkeypad(on/ of f / t oggl e) Thisaction togglesthe handling of Application Key-pad mode
and isalso invoked by the appkeypad entry in vtMenu.
set-scroll-on-key(on/ of f / t oggl e) Thisaction togglesthe scrollKey resource and isalso
invoked from the scrollkey entry in vtMenu.
set-scroll-on-tty-output(on/ of f / t oggl e) Thisaction togglesthe scrollTtyOutput resource and isalso
invoked from the scrollttyoutput entry in vtMenu.
set-allow132(on/ of f / t oggl e) Thisaction togglesthe c132 resource and isalso invoked from
the allow132 entry in vtMenu.
set-cursesemul(on/ of f / t oggl e) Thisaction togglesthe curses resource and isalso invoked
from the cursesemul entry in vtMenu.
set-visual-bell(on/ of f / t oggl e) Thisaction togglesthe visualBell resource and isalso invoked
by the visualbell entry in vtMenu.
set-marginbell(on/ of f / t oggl e) Thisaction togglesthe marginBell resource and isalso invoked
from the marginbell entry in vtMenu.
set-altscreen(on/ of f / t oggl e) Thisaction togglesbetween the alternate and current screens.
soft-reset() Thisaction resetsthe scrolling region and isalso invoked from
the softreset entry in vtMenu.
hard-reset() Thisaction resetsthe scrolling region, tabs, window size, and
cursor keys, and clearsthe screen. It isalso invoked from the
hardreset entry in vtMenu.
clear-saved-lines() Thisaction doeshard-reset() and also clearsthe history of
linessaved off the top of the screen. It isalso invoked from the
clearsavedlines entry in vtMenu.
set-terminal-type(t ype) Thisaction directsoutput to either the vt or tek windows,
according to the t ype string. It isalso invoked by the tekmode
entry in vtMenu and the vtmode entry in tekMenu.
set-visibility(vt / t ek, on/ of f / t oggl e) Thisaction controlswhether or not the vt or tek windows
are visible. It isalso invoked from the tekshow and vthide
entriesin vtMenu and the vtshow and tekhide entriesin tekMenu.
set-tek-text(l ar ge/ 2/ 3/ smal l ) Thisaction setsfont used in the Tektronix window to
the value of the resourcestektextlarge, tektext2, tektext3,
and tektextsmall according to the argument. It isalso
by the entriesof the same namesasthe resourcesin tekMenu.
tek-page() Thisaction clearsthe Tektronix window and isalso invoked
by the tekpage entry in tekMenu.
xterm
Part I: User Commands
716
tek-reset() Thisaction resetsthe Tektronix window and isalso invoked
by the tekreset entry in tekMenu.
tek-copy() Thisaction copiesthe escape codesused to generate the
current window contentsto a file in the current directory
beginning with the name COPY. It isalso invoked from the
tekcopy entry in tekMenu.
visual-bell() Thisaction flashesthe window quickly.
The Tektronix window also hasthe following action:
gin-press(l / L/ m/ M/ r / R) Thisaction sendsthe indicated graphicsinput code.
The default bindingsin the VT102 window are
Shift <KeyPress> Prior: scroll-back(1,halfpage) \n\
Shift <KeyPress> Next: scroll-forw(1,halfpage) \n\
Shift <KeyPress> Select: select-cursor-start() \
select-cursor-end(PRIMARY, CUT_BUFFER0) \n\
Shift <KeyPress> Insert: insert-selection(PRIMARY, CUT_BUFFER0) \n\
Meta<KeyPress>: insert-seven-bit() \n\
Meta<KeyPress>: insert-eight-bit() \n\
!Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
!Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
!Mod2 Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
!Mod2 Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
Meta <Btn1Down>: select-start() \n\
Meta <Btn1Motion>: select-extend() \n\
!Ctrl <Btn2Down>: popup-menu(vtMenu) \n\
!Lock Ctrl <Btn2Down>: popup-m
The default bindingsin the Tektronix window are
Meta<KeyPress>: insert-seven-bit() \n\
Meta<KeyPress>: insert-eight-bit() \n\
!Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
!Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
!Mod2 Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
!Mod2 Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
!Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
!Lock Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
!Mod2 Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
!Mod2 Lock Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
Shift Meta<Btn1Down>: gin-press(L) \n\
Meta<Btn1Down>: gin-press(l) \n\
Shift Meta<Btn2Down>: gin-press(M) \n\
Meta<Btn2Down>: gin-press(m) \n\
Shift Meta<Btn3Down>: gin-press(R) \n\
Meta<Btn3Down>: gin-press(r)
Below isa sample how of the keymap() action isused to add special keysfor entering commonly typed works:
*VT100.Translations: #override <Key>F13: keymap(dbx)
VT100.dbxKeymap.translations: \
<Key>F14: keymap(None) \n\
<Key>F17: string(next) string(0x0d) \n\
<Key>F18: string(step) string(0x0d) \n\
<Key>F19: string(continue) string(0x0d) \n\
<Key>F20: string(print ) insert-selection(PRIMARY, CUT_BUFFER0)
717
ENVIRONMENT
xterm setsthe environment variablesTERM and TERMCAP properly for the size window you have created. It also usesand setsthe
environment variable DISPLAY to specify which bit map display terminal to use. The environment variable WINDOWID isset to
the X window id number of the xterm window.
SEE ALSO
resize(1), X(1), pty(4), tty(4)
Xterm Control Sequences
BUGS
Large pastesdo not work on some systems. Thisisnot a bug in xterm; it isa bug in the pseudo-terminal driver of those
systems. xterm feedslarge pastesto the pty only asfast asthe pty will accept data, but some pty driversdo not return enough
information to know if the write hassucceeded.
Many of the optionsare not resettable after xterm starts.
Only fixed-width, character-cell fontsare supported.
Thisprogram still needsto be rewritten. It should be split into very modular sections, with the variousemulatorsbeing
completely separate widgetsthat dont know about each other. Ideally, youd like to be able to pick and choose emulator
widgetsand stick them into a single control widget.
There needsto be a dialog box to allow entry of the Tek COPY filename.
AUTHORS
Far too many people, including Loretta Guarino Reid (DEC-UEG-WSL), Joel McCormack (DEC-UEG-WSL), Terry
Weissman (DEC-UEG-WSL), Edward Moy (Berkeley), Ralph R. Swick (MIT-Athena), Mark Vandevoorde (MIT-Athena),
Bob McNamara (DEC-MAD), Jim Gettys(MIT-Athena), Bob Scheifler (MIT X Consortium), Doug Mink (SAO), Steve
Pitschke (Stellar), Ron Newman (MIT-Athena), Jim Fulton (MIT X Consortium), Dave Serisky (HP), Jonathan Kamens
(MIT-Athena)
X Version 11 Release6
Xvfb
XvfbVirtual framebuffer X server for X Version 11
SYNOPSIS
Xvfb [ option ] ...
DESCRIPTION
Xvfb isan X server that can run on machineswith no display hardware and no physical input devices. It emulatesa dumb
framebuffer using virtual memory.
The primary use of thisserver isintended to be server testing. The mfb or cfb code for any depth can be exercised with this
server without the need for real hardware that supportsthe desired depths.
A secondary use istesting clientsagainst unusual depthsand screen configurations.
xvfb
Part I: User Commands
718
OPTIONS
In addition to the normal server optionsdescribed in the Xserver(1) manual page, Xvfb acceptsthe following command-line
switches:
screen scr eennum Wx HxD Thisoption createsscreen scr eennum and setsitswidth, height,
and depth to W, H, and D, respectively. By default, only screen 0
existsand hasthe dimensions128010248.
pixdepths l i st - of - dept hs Thisoption specifiesa list of pixmap depthsthat the server
should support in addition to the depthsimplied by the
supported screens. list-of-depths isa space-separated list of
integersthat can have valuesfrom 1 to 32.
fbdir f r amebuf f er - di r ect or y Thisoption specifiesthe directory in which the memory-
mapped filescontaining the framebuffer memory should be
created. (See Files.) Thisoption only existson machinesthat
have the mmap and msync system calls.
shmem Thisoption specifiesthat the framebuffer should be put in
shared memory. The shared memory ID for each screen will be
printed by the server. The shared memory isin xwd format.
Thisoption only existson machinesthat support the System V
shared memory interface.
If neither shmem nor fbdir isspecified, the framebuffer memory will be allocated with malloc().
FILES
The following file iscreated if the fbdir option isgiven:
f r amebuf f er - di r ect or y Memory-mapped file containing screen nsframebuffer
/Xvfb_screen<n> memory, one file per screen. The file isin xwd format.
EXAMPLES
Xvfb :1 -screen 0 1600x1200x32 The server will listen for connectionsasserver number 1, and
screen 0 will be depth 32 16001200.
Xvfb :1 -screen 1 1600x1200x16 The server will listen for connectionsasserver number 1, will
have the default screen configuration (one screen,
128010248), and screen 1 will be depth 16 16001200.
Xvfb -pixdepths 3 27 The server will listen for connectionsasserver number 0,
-fbdir /usr/tmp will have the default screen configuration (one screen,
128010248), will also support pixmap depthsof 3 and 27,
and will use memory-mapped filesin /usr/tmp for the
framebuffer.
xwud -in /usr/tmp/Xvfb screen0 Displaysscreen 0 of the server started by the preceding
example.
SEE ALSO
X(1), Xserver(1), xwd(1), xwud(1), XWDFile.h
AUTHORS
David P. Wiggins(X Consortium, Inc.)
X Version 11 Release6
719
xvidtune
xvidtuneVideo mode tuner for XFree86
SYNOPSIS
xvidtune [ -prev j -next j -unlock j -query j -saver suspendt i me [ of f t i me ]][t ool ki t opt i on ... ]
DESCRIPTION
Xvidtune isa client interface to the XFree86 X server video mode extension (XFree86-VidModeExtension).
When given one of the nontoolkit options, xvidtune providesa command-line interface to either switch the video mode or
get/set monitor powersaver time-outs.
Without any options(or with only toolkit options) it presentsthe user with variousbuttonsand slidersthat can be used to
interactively adjust existing video modes. It will also print the settingsin a format suitable for inclusion in an XF86Config file.
NOTE
The original mode settingscan be restored by pressing the R key, and thiscan be used to restore a stable screen in situa-
tionswhere the screen becomesunreadable.
The available buttonsare
Left
Right
Up
Down
Adjust the video mode so that the display will be moved in the appropriate direction:
Wider
Narrower
Shorter
Taller
Adjust the video mode so that the display size isaltered appropriately:
Quit Exit the program.
Apply Adjust the current video mode to match the selected settings.
Auto Cause the Up/Down/Right/Left, Wider/Narrower/Shorter/
Taller, Restore, and the special S3 buttonsto be applied
immediately. Thisbutton can be toggled.
Test Temporarily switch to the selected settings.
Restore Return the settingsto their original values.
Fetch Query the server for itscurrent settings.
Show Print the currently selected settingsto stdout in XF86Config
Modeline format. The primary selection issimilarly set.
Next Switch the Xserver to the next video mode.
Prev Switch the Xserver to the previousvideo mode.
For some S3-based cards(964 and 968) the following are also available:
InvertVCLK Change the VCLK invert/noninvert state.
EarlySC Change the Early SC state. Thisaffectsscreen wrapping.
xvidtune
Part I: User Commands
720
BlankDelay1, BlankDelay2 Set the blank delay values. Thisaffectsscreen wrapping.
Acceptable valuesare in the range 07. The valuesmay be
incremented or decremented with the + and - buttons, or by
pressing the + or - keysin the text field.
For S3-864/868 based cards, InvertVCLK and BlankDelay1 may be useful. For S3 Trio32/Trio64 cards, only InvertVCLK is
available. At the moment there are no default settingsavailable for these chipsin the video mode extension and thusthis
feature isdisabled in xvidtune. It can be enabled by setting any of the optional S3 commandsin the screen section of
XF86Config, for example, using
blank delay 0
OPTIONS
xvidtune acceptsthe standard X Toolkit command-line optionsaswell asthe following:
prev Switch the Xserver to the previousvideo mode.
next Switch the Xserver to the next video mode.
unlock Normally, xvidtune will disable the switching of video modes
via hot keyswhile it isrunning. If for some reason the program
did not exit cleanly and they are still disabled, the program can
be rerun with thisoption to reenable the mode switching key
combinations.
saver suspendt i me [of f t i me] Set the suspend and off screen saver inactivity time-outs. The
valuesare in seconds.
query Display the monitor parametersand extended screen saver
time-outs.
SEE ALSO
XF86Config(4/5)
AUTHORS
Kaleb S. Keithley (X Consortium), additionsand modificationsby Jon Tombs, David Dawes, and Joe Moss
X Version 11 Release6
xvminitoppm
xvminitoppmConvert an XV thumbnail picture to PPM
SYNOPSIS
xvminitoppm [xvmi ni pi c]
DESCRIPTION
Readsan XV thumbnail picture (a miniature picture generated by the VisualSchnauzer browser) asinput. Producesa
portable pixmap asoutput.
SEE ALSO
ppm(5), xv(1)
AUTHOR
Copyright (c) 1993 by Ingo Wilken
14 December 1993
721
xwd
xwdDump an image of an X window
SYNOPSIS
xwd [-debug] [-help] [-nobdrs] [-out f i l e] [-xy] [-frame] [-add val ue]
[-root j -id i d j -name name ] [-icmap] [-screen] [-display di spl ay]
DESCRIPTION
xwd isan X Window System window dumping utility. xwd allowsX usersto store window imagesin a specially formatted
dump file. Thisfile can then be read by variousother X utilitiesfor redisplay, printing, editing, formatting, archiving, image
processing, and so on. The target window isselected by clicking the pointer in the desired window. The keyboard bell is
rung once at the beginning of the dump and twice when the dump iscompleted.
OPTIONS
-display di spl ay Thisargument allowsyou to specify the server to connect to;
see X(1).
-help Print out the Usage: command syntax summary.
-nobdrs Thisargument specifiesthat the window dump should not
include the pixelsthat compose the X window border. Thisis
useful in situationsin which you may wish to include the
window contentsin a document asan illustration.
-out f i l e Thisargument allowsthe user to explicitly specify the output
file on the command line. The default isto output to standard
out.
-xy Thisoption appliesto color displaysonly. It selectsXY format
dumping instead of the default Z format.
-add val ue Thisoption specifiesa signed value to be added to every pixel.
-frame Thisoption indicatesthat the window manager frame should
be included when manually selecting a window.
-root Thisoption indicatesthat the root window should be selected
for the window dump, without requiring the user to select a
window with the pointer.
-id i d Thisoption indicatesthat the window with the specified
resource i d should be selected for the window dump, without
requiring the user to select a window with the pointer.
-name name Thisoption indicatesthat the window with the specified
WM_NAME property should be selected for the window dump,
without requiring the user to select a window with the pointer.
-icmap Normally, the colormap of the chosen window isused to
obtain RGB values. Thisoption forcesthe first installed
colormap of the screen to be used instead.
-screen Thisoption indicatesthat the GetImage request used to obtain
the image should be done on the root window, rather than
directly on the specified window. In thisway, you can obtain
piecesof other windowsthat overlap the specified window,
and more importantly, you can capture menusor other
popupsthat are independent windowsbut that appear over the
specified window.
xwd
Part I: User Commands
722
ENVIRONMENT
DISPLAY To get default host and display number
FILES
XWDFile.h X Window dump file format definition file.
SEE ALSO
xwud(1), xpr(1), X(1)
AUTHORS
Tony Della Fera (Digital Equipment Corporation, MIT Project Athena) and William F. Wyatt (Smithsonian Astrophysical
Observatory)
X Version 11 Release6
xwdtopnm
xwdtopnmConvert an X11 or X10 window dump file into a portable anymap
SYNOPSIS
xwdtopnm [xwdf i l e]
DESCRIPTION
Readsan X11 or X10 window dump file asinput. Producesa portable anymap asoutput. The type of the output file
dependson the input file. If itsblack and white, a pbm file iswritten; if itsgrayscale, a pgm file, else a ppm file. The program
tellsyou which type it iswriting.
Using thisprogram, you can convert anything on an X workstationsscreen into an anymap. Just display whatever youre
interested in, do an xwd, run it through xwdtopnm, and then use pnmcut to select the part you want.
BUGS
I havent tested thistool with very many configurations, so there are probably bugs. Please let me know if you find any.
SEE ALSO
pnmtoxwd(1), pnm(5), xwd(1)
AUTHOR
Copyright (c) 1989, 1991 by Jef Poskanzer.
11 January1991
xwininfo
xwininfoWindow information utility for X
SYNOPSIS
xwininfo [help] [id i d] [root] [name name] [int] [children] [tree]
[stats] [bits] [events] [size] [wm] [shape] [frame] [all] [english]
[metric] [display di spl ay]
723
DESCRIPTION
xwininfo isa utility for displaying information about windows. Variousinformation isdisplayed depending on which options
are selected. If no optionsare chosen, stats isassumed.
The user hasthe option of selecting the target window with the mouse (by clicking any mouse button in the desired
window) or by specifying itswindow id on the command line with the id option. Or instead of specifying the window by
itsid number, the name option may be used to specify which window isdesired by name. There isalso a special root
option to quickly obtain information on the screensroot window.
OPTIONS
help Print out the Usage: command syntax summary.
id i d Thisoption allowsthe user to specify a target window id on
the command line rather than using the mouse to select the
target window. Thisisvery useful in debugging X applications
where the target window isnot mapped to the screen or where
the use of the mouse might be impossible or interfere with the
application.
name name Thisoption allowsthe user to specify that the window name is
the target window on the command line rather than using the
mouse to select the target window.
root Thisoption specifiesthat Xsroot window isthe target
window. Thisisuseful in situationswhere the root window is
completely obscured.
int Thisoption specifiesthat all X window idsshould be
displayed asinteger values. The default isto display them as
hexadecimal values.
children Thisoption causesthe root, parent, and children windows ids
and namesof the selected window to be displayed.
tree Thisoption islike children but displaysall children
recursively.
stats Thisoption causesthe display of variousattributespertaining
to the location and appearance of the selected window.
Information displayed includesthe location of the window, its
width and height, itsdepth, border width, class, colormap id if
any, map state, backing-store hint, and location of the corners.
bits Thisoption causesthe display of variousattributespertaining
to the selected windowsraw bitsand how the selected window
isto be stored. Displayed information includesthe selected
windowsbit gravity, window gravity, backing-store hint,
backing-planesvalue, backing pixel, and whether or not the
window hassave-under set.
events Thisoption causesthe selected windowsevent masksto be
displayed. Both the event mask of eventswanted by some
client and the event mask of eventsnot to propagate are
displayed.
size Thisoption causesthe selected windowssizing hintsto be
displayed. Displayed information includesthe following: for
both the normal size hintsand the zoom size hints, the user
supplied location, if any; the program supplied location, if any;
the user supplied size, if any; the program supplied size, if any;
xwininfo
Part I: User Commands
724
the minimum size, if any; the maximum size, if any; the resize
increments, if any; and the minimum and maximum aspect
ratios, if any.
wm Thisoption causesthe selected windowswindow manager
hintsto be displayed. Information displayed may include
whether or not the application acceptsinput, what the
windowsicon window # and name is, where the windows
icon should go, and what the windowsinitial state should be.
shape Thisoption causesthe selected windowswindow and border
shape extentsto be displayed.
frame Thisoption causeswindow manager framesto be considered
when manually selecting windows.
metric Thisoption causesall individual height, width, and x and y
positionsto be displayed in millimetersaswell asnumber of
pixels, based on what the server thinksthe resolution is.
Geometry specificationsthat are in +x+y form are not changed.
english Thisoption causesall individual height, width, and x and y
positionsto be displayed in inches(and feet, yards, and milesif
necessary) aswell asnumber of pixels. metric and english
may both be enabled at the same time.
all Thisoption isa quick way to ask for all information possible.
display di spl ay Thisoption allowsyou to specify the server to connect to; see
X(1).
EXAMPLE
The following isa sample summary taken with no optionsspecified:
xwininfo: Window id: 0x60000f xterm Absolute upper-left X: 2
Absolute upper-left Y: 85 Relative upper-left X: 0 Relative upper-left Y: 25
Width: 579 Height: 316 Depth: 8 Visual Class: PseudoColor Border width: 0
Class: InputOutput Colormap: 0x27 (installed) Bit Gravity State:
NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State:
NotUseful Save Under State: no Map State: IsViewable Override Redirect State:
no Corners: +2+85 -699+85 -699-623 +2-623 -geometry 80x24+0+58
ENVIRONMENT
DISPLAY To get the default host and display number
SEE ALSO
X(1), xprop(1)
BUGS
Using stats bits showssome redundant information.
The -geometry string displayed must make assumptionsabout the windowsborder width and the behavior of the application
and the window manager. Asa result, the location given isnot alwayscorrect.
AUTHOR
Mark Lillibridge (MIT Project Athena)
X Version 11 Release6
725
xwud
xwudImage displayer for X
SYNOPSIS
xwud [-in f i l e] [-noclick] [-geometry geom] [-display di spl ay ]
[-new] [-std <maptype>] [-raw] [-vis <vis-type-or-id>] [-help] [-rv]
[-plane number ] [-fg col or ] [-bg col or ]
DESCRIPTION
xwud isan X Window System image undumping utility. xwud allowsX usersto display in a window an image saved in a
specially formatted dump file, such asproduced by xwd(1).
OPTIONS
-bg col or If a bitmap image (or a single plane of an image) isdisplayed,
thisoption can be used to specify the color to display for the 0
bitsin the image.
-display di spl ay Thisoption allowsyou to specify the server to connect to; see
X(1).
-fg col or If a bitmap image (or a single plane of an image) isdisplayed,
thisoption can be used to specify the color to display for the 1
bitsin the image.
-geometry geom Thisoption allowsyou to specify the size and position of the
window. Typically, you will only want to specify the position,
and let the size default to the actual size of the image.
-help Print out a short description of the allowable options.
-in f i l e Thisoption enablesthe user to explicitly specify the input file
on the command line. If no input file isgiven, the standard
input isassumed.
-new Thisoption forcescreation of a new colormap for displaying
the image. If the image characteristicshappen to match those
of the display, thiscan get the image on the screen faster, but
at the cost of using a new colormap (which on most displays
will cause other windowsto go Technicolor).
-noclick Clicking any button in the window will terminate the
application, unlessthisoption isspecified. Termination can
alwaysbe achieved by typing q, Q, or Ctrl+C.
-plane number You can select a single bit plane of the image to display with
thisoption. Planesare numbered with zero being the least
significant bit. Thisoption can be used to figure out which
plane to passto xpr(1) for printing.
-raw Thisoption forcesthe image to be displayed with whatever
color valueshappen to currently exist on the screen. This
option ismostly useful when undumping an image back onto
the same screen that the image originally came from, while the
original windowsare still on the screen, and resultsin getting
the image on the screen faster.
-rv If a bitmap image (or a single plane of an image) isdisplayed,
thisoption forcesthe foreground and background colorsto be
swapped. Thismay be needed when displaying a bitmap image
that hasthe color sense of pixel values0 and 1 reversed from
what they are on your display.
xwud
Part I: User Commands
726
-std mapt ype Thisoption causesthe image to be displayed using the
specified standard colormap. The property name isobtained
by converting the type to uppercase, prepending RGB, and
appending MAP. Typical typesare best, default, and gray. See
xstd-cmap(1) for one way of creating standard colormaps.
-vis vi s- t ype- or - i d Thisoption allowsyou to specify a particular visual or visual
class. The default isto pick the best one. A particular class
can be specified: StaticGray, GrayScale, StaticColor,
PseudoColor, DirectColor, or TrueColor. Or Match can be
specified, meaning use the same classasthe source image.
Alternatively, an exact visual id (specific to the server) can be
specified, either asa hexadecimal number (prefixed with 0x) or
asa decimal number. Finally, default can be specified,
meaning to use the same classasthe colormap of the root
window. Case isnot significant in any of these strings.
ENVIRONMENT
DISPLAY To get default display
FILES
XWDFile.h X Window dump file format definition file
SEE ALSO
xwd(1), xpr(1), xstdcmap(1), X(1)
AUTHOR
Bob Scheifler (MIT X Consortium)
X Version 11 Release6
ybmtopbm
ybmtopbmConvert a Bennet Yee face file into a portable bitmap
SYNOPSIS
ybmtopbm [f acef i l e]
DESCRIPTION
Readsa file acceptable to the face and xbm programsby Bennet Yee (bsy+@cs.cmu.edu). Writesa portable bitmap asoutput.
SEE ALSO
pbmtoybm(1), pbm(5), face(1), face(5), xbm(1)
AUTHOR
Copyright (c) 1991 by Jamie Zawinski and Jef Poskanzer.
6 March 1990
727
ytalk
ytalkA multiuser chat program.
SYNOPSIS
ytalk [-x] username...
DESCRIPTION
ytalk (V3.0 Patch Level 1) isin essence a multiuser chat program. It worksalmost exactly like the UNIX talk program and
even communicateswith the same talk daemon(s), but YTalk allowsfor multiple connections.
The username field may be formatted in several different ways:
name Some user on your machine
name@host Some user on a different machine
name#tty Some user on a particular terminal
name#tty@host Some user on a particular tty on a different machine
name@host#tty Same asname#tty@host
You can specify multiple usernameson the command line, for example,
ytalk george fred@hissun.edu marc@grumpy.cc
The -x option disablesthe X11 interface (described below).
For each user on the command line, ytalk will attempt to connect to the talk daemon on the specified usershost and
determine if that user hasleft an invitation for you to call. If not, ytalk leavesan invitation for him and tellshistalk daemon
to send an announcement to hisscreen. There isnot yet a dedicated ytalk daemon, but there will be. Right now, ytalk is
able to communicate with both existing versionsof UNIX talk daemons. For any particular host, ytalk will attempt to
communicate with a talk daemon the callershost also supports. If the two hostshave no daemon in common, then UNIX
talk will not function at all, but a connection ispossible through (and only through) ytalk.
After a connection hasbeen established between two users, they can chat back and forth to their hearts content. The
connection isterminated when one of them hitsControl-C or selectsQuit from the main menu.
ytalk isperfectly compatible with UNIX talk and they can even converse with each other without any problems. However,
many of the featuresof ytalk can only operate when you are connected to a user who isalso using ytalk. For the rest of this
document, it will be assumed that all connected usersare using ytalk unlessotherwise stated.
If you specified more than one user on the ytalk command line, then ytalk will processand add each user to the conversa-
tion asthey respond to your invitation. Aseach new user entersthe conversation, the screen isfurther subdivided into
smaller and smaller windows, one for each connected user. Right now, the number of connected usersislimited by the
number of lineson your terminal (or window), for each connected user needsat least three lines.
ytalk doesimplement primitive support of the X11 Windowing System. If the environment variable DISPLAY isset, then
ytalk attemptsto connect to that X server. Further detailsabout the X11 interface (and how to turn it off) are given later in
thissection.
Aseach new user isadded to the conversation, ytalk will transmit information about that user to all other connected ytalk
usersso that their screenswill also subdivide and incorporate the new user. If the new user isusing UNIX talk, then
information about him will NOT be transmitted, ashisscreen would be unable to accept multiple connections. I have given
brief thought to allowing at least the output of UNIX talk usersto be transmitted to all connected ytalk users, but I have not
written any code to do so. Note that even though UNIX talk cannot handle multiple connections, it isstill possible for ytalk
to handle multiple UNIX talk connections. For example, george (using ytalk) could communicate with fred and joe (both
using UNIX talk), but fred and joe would be unaware of each other. The best way to understand the limitationsthat UNIX
talk placeson ytalk isto test variousconnectionsbetween the two and see how thingswork.
ytalk
Part I: User Commands
728
ESCAPE MENU
Whenever you are using ytalk, you can hit the Escape key to bring up a menu that at thismoment hasthese options:
a Add a user
d Delete a user
o Options
s Shell
u User list
w Output user to file
q Quit
By choosing option a, you are given the opportunity to type the name of any user you wish to include into the conversation.
Again, YTALK will accept an invitation from that user if an invitation exists, or will leave an invitation and ring the given user.
By choosing option d, you can select the name of a connection to terminate.
By choosing option o, you can view and/or modify any of the ytalk options. (See the Options subsection for a list of ytalk
options.)
By choosing option s, you can invoke a shell in your ytalk window. All other userswill see what happensin your shell. ytalk
will automatically resize your window down to the size of the smallest window you are connected to, in order to ensure that
all usersalwayssee the same thing.
The u option displaysa list of connected and unconnected users, aswell astheir window sizesand what version of talk
software they are running.
By choosing option w, you can select any connected user and type the name of a file, and all further output from that user
will be dumped to the specified file. The file, if it exists, will be overwritten. If you choose w and the same user again, further
output to the file will be terminated.
Oh, one other thing: when user A attemptsto ytalk to user B, but user B isalready ytalking with user C, user Asytalk
program will realize that user B isalready using ytalk, and will communicate with user Bsytalk program directly in order to
initialize the conversation. User B will see a nice windowed message such as
Do you wish to talk with user A?
and he will be prompted for a yes/no answer. This, in my opinion, ismuch preferable to blitting the announcement message
and messing up user Bsscreen.
RUNTIME OPTIONS
When you select Optionsfrom the main menu, you are given the opportunity to edit the ytalk options. The current options
are
s Turn scrolling [off/on]
w Turn word-wrap [off/on]
i Turn auto-import [off/on]
v Turn auto-invite [off/on]
r Turn auto-rering [off/on]
a Turn asides [off/on]
If scrolling isturned on, then a userswindow will scroll when he reachesthe bottom, instead of wrapping back around to
the top.
If word-wrap isturned on, then any word that would overextend the right margin will be automatically moved to the next line
on your screen.
729
If auto-import isturned on, then ytalk will assume that you wish to talk to any usersthat connect to other ytalk usersthat
are connected to you. That last sentence doesmake sense; try again. ytalk will add these usersto your session automatically,
without asking you for verification.
If auto-invite isturned on, then ytalk will automatically accept any connection requested by another user and add the user
to your session. You will not be asked for verification.
If auto-rering isturned on, then ytalk will automatically re-ring any user who doesnot respond to your invitation within 30
seconds. You will not be asked for verification.
If asides isturned on (it may not be available), then keyboard input received while the input focusisin a specific users
window will only be sent to that user. (See the X11 Interface subsection.)
Any of these optionscan be set to your preference in your .ytalkrc file, asdescribed in the next subsection.
YTALK STARTUP FILE
If your home directory containsa file named .ytalkrc, then ytalk will read thisfile while starting up. All ytalk runtime
options, aswell assome startup options, can be set in thisfile.
SETTING BOOLEAN OPTIONS
Boolean optionscan be preset with the following syntax:
turn opt i on [off | on]
where opt i on isone of scrolling, word-wrap, auto-import, auto-invite, auto-rering, asides, or X. Setting these optionsworks
just like described earlier in thissection. Turning X on or off will enable or disable the X11 Interface. For example, one could
enable word-wrap with the line:
turn word-wrap on
SETTING READDRESS MODES
The purpose of readdressing isto allow ytalk connectionsacrosspoint-to-point network gatewayswhere the local machines
know themselvesby a different address(and typically hostname) than the remote machines. The basic syntax of a readdress
command isthis:
readdress f r om- addr ess t o- addr ess domai n
The readdress statement simply makesa claim that the machine(s) in domai n communicate with the machine(s) at f r om-
addr ess by sending a packet to t o- addr ess. Because most usershave no use for thiswhatsoever, Ill describe it only briefly.
THIS IS NOT ROUTING. For example, my machine at home isconnected via PPP to the network at my office. My
machine at home thinksitsEthernet addressis192.188.253.1 and itshostname istalisman.com. The network at my office
hasthe address192.67.141.0. When Im connected via PPP, my home machine isplaced into the office network asaddress
192.67.141.9 with hostname talisman.austin.eds.com.
ytalk needsto know that if it isrunning on domain 192.67.141.0 and receivespacketsfrom 192.188.253.1 that it should
respond to 192.67.141.9, not 192.188.253.1. Right?Right. Okay, okay, okay. I put thisline into my .ytalkrc on both ends:
readdress talisman talisman.austin.eds.com 192.67.141.0
On my home end, thistranslatesto
readdress 192.188.253.1 192.67.141.9 192.67.141.0
which tellsmy home machine to advertise itself as192.67.141.9 instead of 192.188.253.1 when ytalking to machineson the
network 192.67.141.0. On the office end, the readdress command translatesto
readdress 192.67.141.9 192.67.141.9 192.67.141.0
which the office machinesbasically ignore.
Enough. For more information on how to use this, consult the source code or send me a letter. :-)
ytalk
Part I: User Commands
730
X11 INTERFACE
If the DISPLAY environment variable isdefined when ytalk startsup, then ytalk will attempt to communicate with that X
server. A window will be created for you and each user you are connected to. The X11 Interface can be disabled either by
specifying -x on the command line or by putting thisline into your .ytalkrc file:
turn X off
A window iscreated for each individual user in the conversation. If the input focusisin the main window (the one with
ytalk in the title bar) then anything typed will be sent to all connected users. If the input focusisin one of the users
windows, then anything typed will be sent asan aside to only that user. If the aside option isturned off, then ytalk will beep
and not accept anything typed when the input focusisnot in the main window.
ytalk consultsthe X11 Resource Database for these user-definable configuration options:
ytalk.display: X server to connect to, defaulting to the DISPLAY environment variable.
ytalk.reverse: Reverse black/white pixels.
ytalk.font: Font to use, defaulting to 9x15.
ytalk.geometry: Window size, defaulting to 80x24.
FUTURE WORK
Work isbeing done on the following ideas:
I Private conversationsthat do not get interrupted or transmitted to all ytalk connections
I A dedicated ytalk daemon
FILES
/usr/local/etc/ytalkrc Systemwide defaultsfile.
$HOME/.ytalkrc Userslocal configuration file. Thisfile overridesoptionsset in
the system ytalkrc file.
AUTHOR
Britt Yenne (yenne@austin.eds.com)
CONTRIBUTORS
Special thanksto Carl Edman for numerouscode patches, beta testing, and comments. I think thisguy spendsasmuch time
on ytalk asI do. Special thanksto TobiasHahn and Geoff W. for beta testing and suggestions. Thanksto Sitaram
Ramaswamy for the original ytalk man page. Thanksto MagnusHammerin for Solaris2.* support. Thanksto Jonas
Yngvesson for aside messagesin X. Thanksto AndreasStolcke for fixing the X resource database calls. Thanksto John
Vanderpool, Shih-Chen Huang, Andrew Myers, Duncan Sinclair, Evan McLean, and Larry Schwimmer for commentsand
ideas. The README file shipped with ytalk givesdetailed attributions.
BUGS
If you have any ideas, comments, or questions, Id be happy to hear from you at ytalk@austin.eds.com.
24 June1993
yuvplittoppm
yuvplittoppmConvert a Y-, a U-, and a V- file into a portable pixmap.
SYNOPSIS
yuvsplittoppm basename width height [-ccir601]
731
DESCRIPTION
Readsthree files, containing the YUV components, asinput. These filesare basename.Y, basename.U and basename.V. Produces
a portable pixmap on stdout.
Since the YUV filesare raw files, the dimensionswidth and height must be specified on the command line.
OPTIONS
-ccir601 Assumesthat the YUV tripletsare scaled into the smaller range
of the CCIR 601 (MPEG) standard. Otherwise, the JFIF
(JPEG) standard isassumed.
SEE ALSO
ppmtoyuvsplit(1), yuvtoppm(1), ppm(5)
AUTHOR
Marcel Wijkstra (<wijkstra@fwi.uva.nl>), based on ppmtoyuvsplit
26 August 1993
yuvtoppm
yuvtoppmConvert AbekasYUV bytesinto a portable pixmap
SYNOPSIS
yuvtoppm wi dt h height [i magedat a]
DESCRIPTION
Readsraw AbekasYUV bytesasinput. Producesa portable pixmap asoutput. The input file isjust YUV bytes. You have to
specify the width and height on the command line, since the program obviously cant get them from the file. The maxval is
assumed to be 255.
SEE ALSO
ppmtoyuv(1), ppm(5)
AUTHOR
Marc Boucher (<marc@PostImage.COM>)), based on Example Conversion Program, A60/A64 Digital Video InterfaceManual,
page 69. Copyright (c) 1991 by DHD PostImage, Inc. Copyright (c) 1987 by AbekasVideo Systems, Inc.
25 March 1991
zcmp, zdiff
zcmp, zdiffCompare compressed files
SYNOPSIS
zcmp [ cmp_options ] file1 [ file2 ]
zdiff [diff_options ] file1 [ file2 ]
zcmp, zdiff
Part I: User Commands
732
DESCRIPTION
Zcmp and zdiff are used to invoke the cmp or the diff program on compressed files. All optionsspecified are passed directly to
cmp or diff. If only one file isspecified, then the filescompared are file1 and an uncompressed file1.gz. If two filesare
specified, then they are uncompressed if necessary and fed to cmp or diff. The exit statusfrom cmp or diff ispreserved.
SEE ALSO
cmp(1), diff(1), zmore(1), zgrep(1), znew(1), zforce(1), gzip(1), gzexe(1)
BUGS
Messagesfrom the cmp or diff programsrefer to temporary filenamesinstead of those specified.
zeisstopnm
zeisstopnmConvert a Zeissconfocal file into a portable anymap
SYNOPSIS
zeisstopnm [-pgm j -ppm][zei ssf i l e]
DESCRIPTION
Readsa Zeissconfocal file asinput. Producesa portable anymap asoutput. The type of the output file dependson the input
fileif itsgrayscale, a pgm file will be produced; otherwise, it will be a ppm file. The program tellsyou which type it is
writing.
OPTIONS
-pgm Force the output to be a pgm file
-ppm Force the output to be a ppm file
SEE ALSO
pnm(5)
AUTHOR
Copyright (c) 1993 by Oliver Trepte.
15 June1993
zforce
zforceForce a .gz extension on all gzip files
SYNOPSIS
zforce [ name ... ]
DESCRIPTION
zforce forcesa .gz extension on all gzip filesso that gzip will not compressthem twice. Thiscan be useful for fileswith
namestruncated after a file transfer. On systemswith a 14-character limitation on filenames, the original name istruncated
to make room for the .gz suffix. For example, 12345678901234 isrenamed to 12345678901.gz. A filename such asfoo.tgz isleft
intact.
733
SEE ALSO
gzip(1), znew(1), zmore(1), zgrep(1), zdiff(1), gzexe(1)
zgrep
zgrepSearch possibly compressed filesfor a regular expression
SYNOPSIS
zgrep [ grep_options ] [- e] pat t er n f i l ename...
DESCRIPTION
zgrep isused to invoke the grep on compressed or gziped files. All optionsspecified are passed directly to grep. If no file is
specified, then the standard input isdecompressed if necessary and fed to grep. Otherwise, the given filesare uncompressed if
necessary and fed to grep.
If zgrep isinvoked aszegrep or zfgrep, then egrep or fgrep isused instead of grep. If the GREP environment variable isset,
zgrep usesit asthe grep program to be invoked. For example,
for sh: GREP=fgrep zgrep string files for csh: (setenv GREP fgrep; zgrep string files)
AUTHOR
CharlesLevert (charles@comm.polymtl.ca)
SEE ALSO
grep(1), egrep(1), fgrep(1), zdiff(1), zmore(1), znew(1), zforce(1), gzip(1), gzexe(1)
zmore
zmoreFile perusal filter for crt viewing of compressed text
SYNOPSIS
zmore [ name ... ]
DESCRIPTION
zmore isa filter that allowsexamination of compressed or plain text filesone screenful at a time on a soft-copy terminal. zmore
workson filescompressed with compress, pack, or gzip, and also on uncompressed files. If a file doesnot exist, zmore looksfor
a file of the same name with the addition of a .gz, .z, or .Z suffix.
zmore normally pausesafter each screenful, printing More at the bottom of the screen. If the user then typesa carriage
return, one more line isdisplayed. If the user hitsa space, another screenful isdisplayed. Other possibilitiesare enumerated
later.
zmore looksin the file /etc/termcap to determine terminal characteristics, and to determine the default window size. On a
terminal capable of displaying 24 lines, the default window size is22 lines. To use a pager other than the default more, set
environment variable PAGER to the name of the desired program, such asless.
Other sequencesthat may be typed when zmore pauses, and their effects, are asfollows(i isan optional integer argument,
defaulting to 1) :
i <space> Display i more lines, (or another screenful if no argument is
given).
D Display 11 more lines(a scroll). If i isgiven, then the scroll
size isset to i.
d Same asD (control-D)
zmore
Part I: User Commands
734
i z Same astyping a space except that i, if present, becomesthe
new window size. Note that the window size revertsback to
the default at the end of the current file.
i s Skip i linesand print a screenful of lines.
i f Skip i screenfulsand print a screenful of lines.
q or Q Quit reading the current file; go on to the next (if any).
e or q When the prompt More(Next file: f i l e) isprinted, this
command causeszmore to exit.
s When the prompt More(Next file: f i l e) isprinted, this
command causeszmore to skip the next file and continue.
= Display the current line number.
i /expr Search for the i th occurrence of the regular expression expr. If
the pattern isnot found, zmore goeson to the next file (if any).
Otherwise, a screenful isdisplayed, starting two linesbefore
the place where the expression wasfound. The userserase and
kill charactersmay be used to edit the regular expression.
Erasing back past the first column cancelsthe search
command.
i n Search for the i th occurrence of the last regular expression
entered.
!command Invoke a shell with command. The character ! in command is
replaced with the previousshell command. The sequence \! is
replaced by !.
:q or :Q Quit reading the current file; go on to the next (if any) (same
asq or Q).
. (dot) Repeat the previouscommand.
The commandstake effect immediately; that is, it isnot necessary to type a carriage return. Up to the time when the
command character itself isgiven, the user may hit the line kill character to cancel the numerical argument being formed. In
addition, the user may hit the erase character to redisplay the More message.
At any time when output isbeing sent to the terminal, the user can hit the quit key (normally Controln). zmore will stop
sending output, and will display the usual More prompt. The user may then enter one of the preceding commandsin the
normal manner. Unfortunately, some output islost when thisisdone because any characterswaiting in the terminalsoutput
queue are flushed when the quit signal occurs.
The terminal isset to noecho mode by thisprogram so that the output can be continuous. What you type will thusnot show
on your terminal, except for the / and ! commands.
If the standard output isnot a teletype, then zmore actsjust like zcat, except that a header isprinted before each file.
FILES
/etc/termcap Terminal database
SEE ALSO
more(1), gzip(1), zdiff(1), zgrep(1), znew(1), zforce(1), gzexe(1)
znew
znewRecompressZ filesto GZ files
SYNOPSIS
znew [ -ftv9PK] [ name.Z ... ]
735
DESCRIPTION
znew recompressesfilesfrom Z (compress) format to GZ (gzip) format. If you want to recompressa file already in gzip
format, rename the file to force a .Z extension, then apply znew.
OPTIONS
-f Force recompression from Z to GZ format even if a GZ file
already exists.
-t Test the new filesbefore deleting originals.
-v Verbose. Display the name and percentage reduction for each
file compressed.
-9 Use the slowest compression method (optimal compression).
-P Use pipesfor the conversion to reduce disk space usage.
-K Keep a Z file when it issmaller than the GZ file.
SEE ALSO
gzip(1), zmore(1), zdiff(1), zgrep(1), zforce(1), gzexe(1), compress(1)
BUGS
znew doesnot maintain the timestamp with the -P option if cpmod(1) isnot available and touch(1) doesnot support the -r
option.
znew
Part I: User Commands
736
737
System Calls
Part II:
Part II: SystemCalls
738
intro
introIntroduction to system calls
DESCRIPTION
Thischapter describesthe Linux system calls.
CALLING DIRECTLY
In most cases, it isunnecessary to invoke a system call directly, but there are timeswhen the standard C library doesnot
implement a nice function call for you.
SYNOPSIS
#include <linux/unistd.h>
A _syscall macro
Desired system call
SETUP
The important thing to know about a system call isitsprototype. You need to know how many arguments, their types, and
the function return type. Six macrosmake the actual call into the system easier. They have the form
syscallX(t ype,name,t ype1,ar g1,t ype2,ar g2,...)
where
X 05, which are the number of argumentstaken by the system call
t ype The return type of the system call
name The name of the system call
t ypeN The Nth argumentstype
ar gN The name of the Nth argument
These macroscreate a function called name with the argumentsyou specify. Once you include _syscall() in your source file,
you call the system call by name.
EXAMPLE
{
struct sysinfo s_info;
int error;
error = sysinfo(&s_info);
printf(code error = %d\n, error);
printf(Uptime = %ds\nLoad: 1 min %d / 5 min %d / 15 min %d\n
RAM: total %d / free %d / shared %d\n
Memory in buffers = %d\nSwap: total %d / free %d\n
Number of processes = %d\n,
s_info.uptime, s_info.loads[0],
s_info.loads[1], s_info.loads[2],
s_info.totalram, s_info.freeram,
s_info.sharedram, s_info.bufferram,
s_info.totalswap, s_info.freeswap,
s_info.procs);
return(0);
}
739
SAMPLE OUTPUT
code error = 0
uptime = 502034s
Load: 1 min 13376 / 5 min 5504 / 15 min 1152
RAM: total 15343616 / free 827392 / shared 8237056
Memory in buffers = 5066752
Swap: total 27881472 / free 24698880
Number of processes = 40
NOTES
The _syscall() macrosdo not produce a prototype. You might have to create one, especially for C++ users.
System callsare not required to return only positive or negative error codes. You need to read the source to be sure how it
will return errors. Usually, it isthe negative of a standard error code, for example, EPERM. The _syscall() macroswill return
the result r of the system call when r isnonnegative, but will return 1 and set the variable errno to r when r isnegative.
Some system calls, such asmmap, require more than five arguments. These are handled by pushing the argumentson the stack
and passing a pointer to the block of arguments.
When defining a system call, the argument typesmust be passed by value or by pointer (for aggregatessuch asstructs).
FILES
/usr/include/linux/unistd.h
AUTHORS
Look at the header of the manual page for the author(s) and copyright conditions. Note that these can be different from page
to page.
Linux 1.2.13, 22 May1996
exit
exitTerminate the current process
SYNOPSIS
#include <unistd.h>
void exit(int st at us );
DESCRIPTION
exit terminatesthe calling processimmediately. Any open file descriptorsbelonging to the processare closed; any children of
the processare inherited by process1, init, and the processsparent issent a SIGCHLD signal.
st at us isreturned to the parent processasthe processsexit statusand can be collected using one of the wait family of calls.
RETURN VALUE
exit never returns.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
NOTES
exit doesnot call any functionsregistered with the ANSI C atexit function and doesnot flush standard I/O buffers. To do
these things, use exit(3).
exit
Part II: SystemCalls
740
SEE ALSO
fork(2), execve(2), waitpid(2), wait4(2), kill(2), wait(3), exit(3)
Linux, 21 July1993
accept
acceptAccept a connection on a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int accept(int s, struct sockaddr *addr ,int*addr l en);
DESCRIPTION
The argument s isa socket that hasbeen created with socket(2), bound to an addresswith bind(2), and islistening for
connectionsafter a listen(2). The accept function extractsthe first connection request on the queue of pending connec-
tions, createsa new socket with the same propertiesof s, and allocatesa new file descriptor for the socket. If no pending
connectionsare present on the queue and the socket isnot marked asnonblocking, accept blocksthe caller until a connec-
tion ispresent. If the socket ismarked nonblocking and no pending connectionsare present on the queue, accept returnsan
error asdescribed below. The accepted socket may not be used to accept more connections. The original socket s remains
open.
The argument addr isa result parameter that isfilled in with the addressof the connecting entity, asknown to the communi-
cationslayer. The exact format of the addr parameter isdetermined by the domain in which the communication isoccurring.
The addr l en isa value-result parameter; it should initially contain the amount of space pointed to by addr ; on return it will
contain the actual length (in bytes) of the addressreturned. Thiscall isused with connection-based socket types, currently
with SOCK_STREAM.
It ispossible to select(2) a socket for the purposesof doing an accept by selecting it for read.
For certain protocolsthat require an explicit confirmation, such asISO and DATAKIT, accept can be thought of asmerely
dequeuing the next connection request and not implying confirmation. Confirmation can be implied by a normal read or
write on the new file descriptor, and rejection can be implied by closing the new socket.
One can obtain user connection request data without confirming the connection by issuing a recvmsg(2) call with a msg
iovlen of 0 and a nonzero msg controllen, or by issuing a getsockopt(2) request. Similarly, one can provide user connection
rejection information by issuing a sendmsg(2) call providing only the control information, or by calling setsockopt(2).
RETURN VALUES
The call returns1 on error. If it succeeds, it returnsa nonnegative integer that isa descriptor for the accepted socket.
ERRORS
EBADF The descriptor isinvalid.
ENOTSOCK The descriptor referencesa file, not a socket.
EOPNOTSUPP The referenced socket isnot of type SOCK_STREAM.
EFAULT The addr parameter isnot in a writable part of the user addressspace.
EWOULDBLOCK The socket ismarked nonblocking and no connectionsare present to be accepted.
HISTORY
The accept function appeared in BSD 4.2.
741
SEE ALSO
bind(2), connect(2), listen(2), select(2), socket(2)
BSD Man Page, 24 July1993
access
accessChecksuserspermissionsfor a file
SYNOPSIS
#include <unistd.h>
int access(const char *pat hname,intmode);
DESCRIPTION
access checkswhether the processwould be allowed to read, write, or test for existence of the file (or other file system object)
whose name ispat hname. If pat hname isa symbolic link, permissionsof the file referred by thissymbolic link are tested.
mode isa mask consisting of one or more of R_OK, W_OK, X_OK, and F_OK.
R_OK, W_OK, and X_OK request checking whether the file existsand hasread, write, and execute permissions, respectively. F_OK
just requestschecking for the existence of the file.
The testsdepend on the permissionsof the directoriesoccurring in the path to the file, asgiven in pat hname, and on the
permissionsof directoriesand filesreferred by symbolic linksencountered on the way.
The check isdone with the processsreal UID and GID, rather than with the effective IDsasisdone when actually
attempting an operation. Thisisto allow set-UID programsto easily determine the invoking usersauthority.
Only accessbitsare checked, not the file type or contents. Therefore, if a directory isfound to be writable, it probably
meansthat filescan be created in the directory, and not that the directory can be written asa file. Similarly, a DOS file may
be found to be executable, but the execve(2) call will still fail.
RETURN VALUE
On success(all requested permissionsgranted), 0 isreturned. On error (at least 1 bit in mode asked for a permission that is
denied, or some other error occurred), 1 isreturned and errno isset appropriately.
ERRORS
EACCES The requested accesswould be denied, either to the file itself or one of the directoriesin
pat hname.
EFAULT pat hname pointsoutside your accessible addressspace.
EINVAL mode wasincorrectly specified.
ENAMETOOLONG pat hname istoo long.
ENOENT A directory component in pat hname would have been accessible but doesnot exist or wasa
dangling symbolic link.
ENOTDIR A component used asa directory in pathnameisnot, in fact, a directory.
ENOMEM Insufficient kernel memory wasavailable.
ELOOP pat hname containsa reference to a circular symbolic link, that is, a symbolic link containing
a reference to itself.
RESTRICTIONS
access returnsan error if any of the accesstypesin the requested call fails, even if other typesmight be successful. access may
not work correctly on NFS file systemswith UID mapping enabled because UID mapping isdone on the server and hidden
from the client, which checkspermissions.
access
Part II: SystemCalls
742
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
stat(2), open(2), chmod(2), chown(2), setuid(2), setgid(2)
Linux 1.2.13, 17 March 1996
acct
acctSwitchesprocessaccounting on or off
SYNOPSIS
#include <unistd.h>
int acct(const char *f i l ename);
DESCRIPTION
Warning: Since thisfunction isnot implemented asof Linux 0.99.11, it will alwaysreturn 1 and set errno to ENOSYS. If
acctkit isinstalled, the function performsasadvertised.
When called with the name of an existing file asargument, accounting isturned on and recordsfor each terminating process
are appended to f i l ename asit terminates. An argument of NULL causesaccounting to be turned off.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
NOTES
No accounting isproduced for programsrunning when a crash occurs. In particular, nonterminating processesare never
accounted for.
SEE ALSO
acct(5)
Linux 0.99.11, 10 August 1993
adjtimex
adjtimexTuneskernel clock
SYNOPSIS
#include <sys/timex.h>
int adjtimex(struct timex *buf );
DESCRIPTION
Linux usesDavid Millsclock adjustment algorithm. adjtimex readsand optionally setsadjustment parametersfor this
algorithm.
adjtimex takesa pointer to a t i mex structure, updateskernel parametersfrom field values, and returnsthe same structure with
current kernel values. Thisstructure isdeclared asfollows:
743
struct timex
{
int mode; /* mode selector */
long offset; /* time offset (usec) */
long frequency; /* frequency offset (scaled ppm) */
long maxerror; /* maximum error (usec) */
long esterror; /* estimated error (usec) */
int status; /* clock command/status */
long time_constant; /* pll time constant */
long precision; /* clock precision (usec) (read only) */
long tolerance; /* clock frequency tolerance (ppm)
(read only) */
struct timeval time; /* (read only) */
long tick; /* usecs between clock ticks */
};
The mode field determineswhich parameters, if any, to set. It may contain a bitwise-or combination of zero or more of the
following bits:
#define ADJ_OFFSET 0x0001 /* time offset */
#define ADJ_FREQUENCY 0x0002 /* frequency offset */
#define ADJ_MAXERROR 0x0004 /* maximum time error */
#define ADJ_ESTERROR 0x0008 /* estimated time error */
#define ADJ_STATUS 0x0010 /* clock status */
#define ADJ_TIMECONST 0x0020 /* pll time constant */
#define ADJ_TICK 0x4000 /* tick value */
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
Ordinary usersare restricted to a 0 value for mode. Only the superuser may set any parameters.
RETURN VALUE
On success, adjtimex returnsthe value of buf . st at us:
#define TIME OK 0 /* clock synchronized */
#define TIME INS 1 /* insert leap second */
#define TIME DEL 2 /* delete leap second */
#define TIME OOP 3 /* leap second in progress */
#define TIME BAD 4 /* clock not synchronized */
On failure, adjtimex returns1 and setserrno.
ERRORS
EFAULT buf doesnot point to writable memory.
EPERM buf . mode isnonzero and the user isnot superuser.
EINVAL An attempt ismade to set buf . of f set to a value outside the range -131071 to +131071, or
to set buf . st at us to a value other than those listed above, or to set buf . t i ck to a value
outside the range 900000/HZ to 1100000/HZ,where HZ isthe system timer interrupt
frequency.
SEE ALSO
settimeofday(2)
Linux 1.2.4, 15 April 1995
adjtimex
Part II: SystemCalls
744
alarm
alarmSetsan alarm clock for delivery of a signal
SYNOPSIS
#include <unistd.h>
unsigned int alarm(unsigned int seconds);
DESCRIPTION
alarm arrangesfor a SIGALRM signal to be delivered to the processin seconds seconds.
If seconds is0, no new alarm isscheduled.
In any event, any previously set alarm iscanceled.
RETURN VALUE
alarm returnsthe number of secondsremaining until any previously scheduled alarm wasdue to be delivered, or 0 if there
wasno previously scheduled alarm.
NOTES
alarm and setitimer share the same timer; callsto one will interfere with use of the other.
Scheduling delayscan, asever, cause the execution of the processto be delayed by an arbitrary amount of time.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
setitimer(2), signal(2), sigaction(2), gettimeofday(2), select(2), pause(2), sleep(3)
Linux, 21 July1993
bdflush
bdflushStarts, flushes, or tunesthe buffer-dirty-flush daemon
SYNOPSIS
int bdflush(int f unc, long *addr ess) ;
int bdflush(int f unc, long dat a) ;
DESCRIPTION
bdflush starts, flushes, or tunesthe buffer-dirty-flush daemon. Only the superuser may call bdflush.
If f unc isnegative or 0 and no daemon hasbeen started, bdflush entersthe daemon code and never returns.
If f unc is1, some dirty buffersare written to disk.
If f unc is2 or more and iseven (low bit is0), addr ess isthe addressof a long word, and the tuning parameter numbered
(f unc2)/2 isreturned to the caller in that address.
If f unc is3 or more and isodd (low bit is1), dat a isa long word and the kernel setstuning parameter numbered (f unc3)/2
to that value.
The set of parameters, their values, and their legal rangesare defined in the kernel source file f s/ buf f er . c.
745
RETURN VALUE
If f unc isnegative or 0 and the daemon successfully starts, bdflush never returns. Otherwise, the return value is0 on success
and 1 on failure, with errno set to indicate the error.
ERRORS
EPERM Caller isnot superuser.
EFAULT addr ess pointsoutside your accessible addressspace.
EBUSY An attempt wasmade to enter the daemon code after another processhasalready been
entered.
EINVAL An attempt wasmade to read or write an invalid parameter number, or to write an invalid
value to a parameter.
SEE ALSO
fsync(2), sync(2), update(8), sync(8)
Linux 1.2.4, 15 April 1995
bind
bindBindsa name to a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int bind(int sockf d, struct sockaddr *my_addr ,intaddr l en);
DESCRIPTION
bind givesthe socket, sockf d, the local addressmy_addr . my_addr isaddr l en byteslong. Traditionally, thisiscalled assigning a
name to a socket. (When a socket iscreated with socket(2), it existsin a name spacean addressfamilybut hasno name
assigned.)
NOTES
Binding a name in the UNIX domain createsa socket in the file system that must be deleted by the callerusing unlink(2)
when it isno longer needed.
The rulesused in name binding vary between communication domains. Consult the manual entriesin section 4 for detailed
information.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EBADF sockf d isnot a valid descriptor.
EINVAL The socket isalready bound to an address. Thismay change in the future. See linux/unix/
sock.c for details.
EACCES The addressisprotected and the user isnot the superuser.
The following errorsare specific to UNIX domain (AF_UNIX) sockets:
EINVAL addr l en waswrong, or the socket wasnot in the AF_UNIX family.
EROFS The socket inode would reside on a read-only file system.
EFAULT my_addr pointsoutside your accessible addressspace.
bind
Part II: SystemCalls
746
ENAMETOOLONG my_addr istoo long.
ENOENT The file doesnot exist.
ENOMEM Insufficient kernel memory wasavailable.
ENOTDIR A component of the path prefix isnot a directory.
EACCES Search permission isdenied on a component of the path prefix.
ELOOP my_addr containsa circular reference (that is, via a symbolic link).
HISTORY
The bind function call appeared in BSD 4.2.
SEE ALSO
accept(2), connect(2), listen(2), socket(2), getsockname(2)
Linux 0.99.11, 23 July1993
brk, sbrk
brk, sbrkChange data segment size
SYNOPSIS
#include <unistd.h>
int brk(void *end_dat a_segment );
void *sbrk(ptrdiff ti ncr ement );
DESCRIPTION
brk setsthe end of the data segment to the value specified by end_dat a_segment .
end_dat a_segment must be greater than the end of the text segment and it must be 16KB before the end of the stack.
sbrk incrementsthe programsdata space by i ncr ement bytes. sbrk isnt a system call; it isjust a C library wrapper.
RETURN VALUE
On success, brk returns0, and sbrk returnsa pointer to the start of the new area. On error, 1 isreturned and errno isset to
ENOMEM.
CONFORMS TO
BSD 4.3
brk and sbrk are not defined in the C standard and are deliberately excluded from the POSIX.1 standard (see paragraphs
B.1.1.1.3 and B.8.3.3).
SEE ALSO
execve(2), getrlimit(2), malloc(3), end(3)
Linux 0.99.11, 21 July1993
cacheflush
cacheflushFlushescontentsof the instruction and/or data cache
SYNOPSIS
747
#include <asm/cachectl.h>
int cacheflush(char *addr ,intnbyt es,intcache);
DESCRIPTION
cacheflush flushescontentsof indicated cache(s) for user addressesin the range addr to (addr+nbytes-1). The cache may be
one of the following:
ICACHE Flush the instruction cache.
DCACHE Write back to memory and invalidate the affected valid cache lines.
BCACHE Same as(ICACHE|DCACHE).
RETURN VALUE
cacheflush returns0 on successor -1 on error. If errorsare detected, errno will indicate the error.
ERRORS
EINVAL The cache parameter isnot one of ICACHE, DCACHE, or BCACHE.
EFAULT Some or all of the addressrange addr to (addr+nbytes-1) isnot accessible.
BUGS
The current implementation ignoresthe addr and nbytes parameters. Therefore, the whole cache isalwaysflushed.
NOTE
Thissystem call isonly available on MIPS-based systems.
SEE ALSO
cachectl(2)
Linux, 27 June95
chdir, fchdir
chdir, fchdirChangesthe working directory
SYNOPSIS
#include <unistd.h>
int chdir(const char *pat h);
int fchdir(int f d);
DESCRIPTION
chdir changesthe current directory to that specified in pat h.
fchdir isidentical to chdir, only the directory isgiven asan open file descriptor.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
Depending on the file system, other errorscan be returned. The more general errorsare listed here:
EPERM The processdoesnot have execute permission on the directory.
EFAULT pat h pointsoutside your accessible addressspace.
ENAMETOOLONG pat h istoo long.
chdir, fchdir
Part II: SystemCalls
748
EBADF f d isnot a valid file descriptor.
ENOENT The file doesnot exist.
ENOMEM Insufficient kernel memory wasavailable.
ENOTDIR A component of the path prefix isnot a directory.
EACCES Search permission isdenied on a component of the path prefix.
ELOOP pat h containsa circular reference (that is, via a symbolic link)
SEE ALSO
getcwd(3), chroot(2)
Linux 1.2.4, 15 April 1995
chmod, fchmod
chmod, fchmodChangespermissionsof a file
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int chmod(const char *pat h,modetmode);
int fchmod(int f i l des ,modetmode);
DESCRIPTION
The mode of the file given by pat h or referenced by f i l edes ischanged.
Modesare specified by oring the following:
S_ISUID 04000 Set user ID on execution
S_ISGID 02000 Set group ID on execution
S_ISVTX 01000 Sticky bit
S_IRUSR (S_IREAD) 00400 Read by owner
S_IWUSR (S_IWRITE) 00200 Write by owner
S_IXUSR (S_IEXEC) 00100 Execute/search by owner
S_IRGRP 00040 Read by group
S_IWGRP 00020 Write by group
S_IXGRP 00010 Execute/search by group
S_IROTH 00004 Read by others
S_IWOTH 00002 Write by others
S_IXOTH 00001 Execute/search by others
The effective UID of the processmust be 0 or must match the owner of the file.
The effective UID or GID must be appropriate for setting execution bits.
Depending on the file system, set user ID and set group ID execution bitsmay be turned
off if a file iswritten. On some file systems, only the superuser can set the sticky bit, which
may have a special meaning (that is, for directories, a file can only be deleted by the owner
or the superuser).
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
749
ERRORS
Depending on the file system, other errorscan be returned. The more general errorsfor chmod are listed here:
EPERM The effective UID doesnot match the owner of the file and isnot 0.
EROFS The named file resideson a read-only file system.
EFAULT pat h pointsoutside your accessible addressspace.
ENAMETOOLONG pat h istoo long.
ENOENT The file doesnot exist.
ENOMEM Insufficient kernel memory wasavailable.
ENOTDIR A component of the path prefix isnot a directory.
EACCES Search permission isdenied on a component of the path prefix.
ELOOP pat h containsa circular reference (that is, via a symbolic link)
The general errorsfor fchmod are listed here:
EBADF The descriptor isnot value.
ENOENT See above.
EPERM See above.
EROFS See above.
SEE ALSO
open(2), chown(2), stat(2)
Linux 0.99.11, 21 July1993
chown, fchown
chown, fchownChangesownership of a file
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
int chown(const char *pat h, uid t owner , gid_t gr oup);
int fchown(int f d, uid t owner , gid_t gr oup);
DESCRIPTION
The owner of the file specified by pat h or by f d ischanged. Only the superuser may change the owner of a file. The owner of
a file may change the group of the file to any group of which that owner isa member. The superuser may change the group
arbitrarily.
If the owner or gr oup isspecified as1, that ID isnot changed.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
Depending on the file system, other errorscan be returned. The more general errorsfor chown are listed here:
EPERM The effective UID doesnot match the owner of the file, and isnot 0; or the owner or gr oup
were specified incorrectly.
EROFS The named file resideson a read-only file system.
EFAULT pat h pointsoutside your accessible addressspace.
chown, fchown
Part II: SystemCalls
750
ENAMETOOLONG pat h istoo long.
ENOENT The file doesnot exist.
ENOMEM Insufficient kernel memory wasavailable.
ENOTDIR A component of the path prefix isnot a directory.
EACCES Search permission isdenied on a component of the path prefix.
ELOOP pat h containsa circular reference (that is, via a symbolic link).
The general errorsfor fchown are listed here:
EBADF The descriptor isnot value.
ENOENT See above.
EPERM See above.
EROFS See above.
NOTES
chown doesnot follow symbolic links. The prototype for fchown isonly available if USE BSD isdefined.
SEE ALSO
chmod(2), flock(2)
Linux 0.99.11, 21 July1993
chroot
chrootChangesroot directory
SYNOPSIS
#include <unistd.h>
int chroot(const char *pat h);
DESCRIPTION
chroot changesthe root directory to that specified in pat h. Thisdirectory will be used for pathnamesbeginning with /. The
root directory isinherited by all children of the current process.
Only the superuser may change the root directory.
Note that thiscall doesnot change the current working directory, so that . can be outside the tree rooted at /.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
Depending on the file system, other errorscan be returned. The more general errorsare listed here:
EPERM The effective UID doesnot match the owner of the file, and isnot 0; or the owner or gr oup
were specified incorrectly.
EROFS The named file resideson a read-only file system.
EFAULT pat h pointsoutside your accessible addressspace.
ENAMETOOLONG pat h istoo long.
ENOENT The file doesnot exist.
ENOMEM Insufficient kernel memory wasavailable.
751
ENOTDIR A component of the path prefix isnot a directory.
EACCES Search permission isdenied on a component of the path prefix.
ELOOP pat h containsa circular reference (that is, via a symbolic link)
SEE ALSO
chdir(2)
Linux 1.1.46, 21 August 1994
clone
cloneCreatesa child process
SYNOPSIS
#include <linux/sched.h>
#include <linux/unistd.h>
pid t clone(void *sp, unsigned long f l ags);
DESCRIPTION
clone isan alternate interface to fork, with more options. fork isequivalent to clone(0, SIGCLD|COPYVM).
If sp isnonzero, the child processusessp asitsinitial stack pointer.
The low byte of f l ags containsthe signal sent to the parent when the child dies. f l ags may also be bitwise ored with either or
both of COPYVM and COPYFD.
If COPYVM isset, child pagesare copy-on-write imagesof the parent pages. If COPYVM isnot set, the child processsharesthe same
pagesasthe parent, and both parent and child may write on the same data.
If COPYFD isset, the childsfile descriptorsare copiesof the parentsfile descriptors. If COPYFD isnot set, the childsfile
descriptorsare shared with the parent.
RETURN VALUE
On success, the PID of the child processisreturned in the parentsthread of execution, and 0 isreturned in the childs
thread of execution. On failure, a 1 will be returned in the parentscontext, no child processwill be created, and errno will
be set appropriately.
ERRORS
ENOSYS clone will alwaysreturn thiserror, unlessyour kernel wascompiled with
CLONE_ACTUALLY_WORKS_OK defined.
EAGAIN fork cannot allocate sufficient memory to copy the parentspage tablesand allocate a task
structure for the child.
BUGS
By default, CLONE_ACTUALLY_WORKS_OK isnot defined.
There isno entry for clone in /lib/libc.so.4.5.26.
Commentsin the kernel asof 1.1.46 indicate that it mishandlesthe case where COPYVM isnot set.
SEE ALSO
fork(2)
Linux 1.2.9, 10 June1995
clone
Part II: SystemCalls
752
close
closeClosesa file descriptor
SYNOPSIS
#include <unistd.h>
int close(int f d);
DESCRIPTION
close closesa file descriptor so that it no longer refersto any file and may be reused. Any locksheld on the file it was
associated with, and owned by the process, are removed (regardlessof the file descriptor that wasused to obtain the lock).
If f d isthe last copy of a particular file descriptor, the resourcesassociated with it are freed; if the descriptor wasthe last
reference to a file that hasbeen removed using unlink, the file isdeleted.
RETURN VALUE
close returns0 on success, or 1 if an error occurred.
ERRORS
EBADF f d isnt a valid open file descriptor.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
NOTES
Not checking the return value of close isa common but neverthelessseriousprogramming error. File system implementa-
tionsthat use techniquesaswrite-behind to increase performance may lead to wr i t e(2) succeeding, although the data hasnot
been written yet. The error statusmay be reported at a later write operation, but it isguaranteed to be reported on closing
the file. Not checking the return value when closing the file may lead to silent lossof data. Thiscan especially be observed
with NFS and disk quotas.
SEE ALSO
open(2), fcntl(2), shutdown(2), unlink(2), fclose(3)
14 April 1996
connect
connectInitiatesa connection on a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockf d, struct sockaddr *ser v_addr ,intaddr l en);
DESCRIPTION
The parameter sockf d isa socket. If it isof type SOCK_DGRAM, thiscall specifiesthe peer with which the socket isto be
associated; thisaddressisthat to which datagramsare to be sent, and the only addressfrom which datagramsare to be
received. If the socket isof type SOCK_STREAM, thiscall attemptsto make a connection to another socket. The other socket is
753
specified by serv_addr, which isan addressin the communicationsspace of the socket. Each communicationsspace interprets
the serv_addr, parameter in itsown way. Generally, stream socketsmay successfully connect only once; datagram sockets
may use connect multiple timesto change their association. Datagram socketsmay dissolve the association by connecting to
an invalid address, such asa null address.
RETURN VALUE
If the connection or binding succeeds, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
See the Linux kernel source code for details.
HISTORY
The connect function call first appeared in BSD 4.2.
SEE ALSO
accept(2), bind(2), listen(2), socket(2), getsockname(2)
Linux 0.99.11, 23 July1993
dup, dup2
dup, dup2Duplicate a file descriptor
SYNOPSIS
#include <unistd.h>
int dup(int ol df d);
int dup2(int ol df d,intnewf d);
DESCRIPTION
dup and dup2 create a copy of the file descriptor ol df d.
The old and new descriptorscan be used interchangeably. They share locks, file position pointersand flags; for example, if
the file position ismodified by using lseek on one of the descriptors, the position isalso changed for the other.
The two descriptorsdo not share the close-on-exec flag, however.
dup usesthe lowest-numbered unused descriptor for the new descriptor.
dup2 makesnewf d be the copy of ol df d, closing newf d first if necessary.
RETURN VALUE
dup and dup2 return the new descriptor, or 1 if an error occurred (in which case errno isset appropriately).
ERRORS
EBADF ol df d isnt an open file descriptor, or newf d isout of the allowed range for file descriptors.
EMFILE The processalready hasthe maximum number of file descriptorsopen and tried to open a
new one.
WARNING
The error returned by dup2 isdifferent from that returned by fcntl(...,F_DUPFD,...) when newf d isout of range. On some
systemsdup2 also sometimesreturnsEINVAL like F_DUPFD.
dup, dup2
Part II: SystemCalls
754
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
fcntl(2), open(2), close(2).
Linux 1.1.46, 21 August 1994
execve
execveExecute program
SYNOPSIS
#include <unistd.h>
int execve (const char *f i l ename, const char *ar gv [], const char *envp[]);
DESCRIPTION
execve() executesthe program pointed to by f i l ename. f i l ename must be either a binary executable or a shell script starting
with a line in the format #! i nt er pr et er [arg].
execve() doesnot return on success, and the text, data, bss, and stack of the calling processare overwritten by that of the
program loaded. The program invoked inheritsthe calling processsPID, and any open file descriptorsthat are not set to
close on exec. Signalspending on the parent processare cleared.
If the current program isbeing ptraced, a SIGTRAP issent to it after a successful execve().
RETURN VALUE
On success, execve() doesnot return; on error 1 isreturned and errno isset appropriately.
ERRORS
EACCES The file isnot a regular file.
EACCES Execute permission isdenied for the file.
EPERM The file system ismounted noexec.
EPERM The file system ismounted nosui d and the file hasan SUID or SGID bit set.
E2BIG The argument list istoo big.
ENOEXEC The magic number in the file isincorrect.
EFAULT f i l ename pointsoutside your accessible addressspace.
ENAMETOOLONG f i l ename istoo long.
ENOENT The file doesnot exist.
ENOMEM Insufficient kernel memory wasavailable.
ENOTDIR A component of the path prefix isnot a directory.
EACCES Search permission isdenied on a component of the path prefix.
ELOOP f i l ename containsa circular reference (that is, via a symbolic link).
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
NOTES
SUID and SGID processescan not be ptrace()d SUID or SGID.
755
A maximum line length of 127 charactersisallowed for the first line in a #! executable shell script. Thismay be circum-
vented by changing the max size of buf, in which case you will become bound by the 1024 byte size of a buffer, which isnot
easily worked around.
SEE ALSO
execl(3), fork(2)
Linux 1.1.46, 21 August 1994
fcntl
fcntlManipulate file descriptor
SYNOPSIS
#include <unistd.h>
#include <fcntl.h>
int fcntl(int f d,intcmd);
int fcntl(int f d,intcmd,longar g);
DESCRIPTION
fcntl performsone of variousmiscellaneousoperationson f d. The operation in question isdetermined by cmd:
F_DUPFD Makesar g be a copy of f d, closing f d first if necessary.
The same functionality can be more easily achieved by using dup2(2).
The old and new descriptorsmay be used interchangeably. They share locks, file position
pointers, and flags; for example, if the file position ismodified by using lseek on one of the
descriptors, the position isalso changed for the other.
The two descriptorsdo not share the close-on-exec flag, however.
On success, the new descriptor isreturned.
F_GETFD Read the close-on-exec flag. If the low-order bit is0, the file will remain open acrossexec;
otherwise, it will be closed.
F_SETFD Set the close-on-exec flag to the value specified by arg(only the least significant bit
isused).
F_GETFL Read the descriptorsflags(all flagsasset by open(2)are returned).
F_SETFL Set the descriptorsflagsto the value specified by ar g.
Only O_APPEND and O_NONBLOCK may be set.
The flagsare shared between copies(made with dup and so on) of the same file descriptor.
The flagsand their semanticsare described in open(2).
F_GETLK, F_SETLK, Manage discretionary file locks. The third argument ar g isa pointer to a struct flock
and F_SETLKW (that may be overwritten by thiscall).
F_GETLK Return the flock structure that preventsusfrom obtaining the lock, or set the l type field of
the lock to F_UNLCK if there isno obstruction.
F_SETLK The lock isset (when l type isF_RDLCK or F_WRLCK) or cleared (when it isF_UNLCK).
If the lock isheld by someone else, thiscall returns-1 and setserrno to EACCES or EAGAIN.
F_SETLKW Like F_SETLK, but instead of returning an error, we wait for the lock to be released.
F_GETOWN Get the processID (or processgroup) of the owner of a socket.
Processgroupsare returned asnegative values.
F_SETOWN Set the processor processgroup that ownsa socket.
For these commands, ownership meansreceiving SIGIO or SIG-URG signals.
Processgroupsare specified using negative values.
fcntl
Part II: SystemCalls
756
RETURN VALUE
The return value dependson the operation:
F_DUPFD The new descriptor.
F_GETFD Value of flag.
F_GETFL Value of flags.
F_GETOWN Value of descriptor owner.
On error, 1 isreturned and errno isset appropriately.
ERRORS
EBADF f d isnot an open file descriptor.
EINVAL For F_DUPFD, argisnegative or isgreater than the maximum allowable value.
EMFILE For F_DUPFD, the processalready hasthe maximum number of file descriptorsopen.
NOTES
The errorsreturned by dup2 are different from those returned by F_DUPFD.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
dup2(2), open(2), socket(2).
Linux, 26 September 1995
fdatasync
fdatasyncSynchronizesa filesin-core data with that on disk
SYNOPSIS
#include <unistd.h>
#ifdef POSIX SYNCHRONIZED IO
int fdatasync(int f d);
#endif
DESCRIPTION
fdatasync flushesall data buffersof a file to disk (before the system call returns). It resemblesfsync but isnot required to
update the metadata such asaccesstime.
Applicationsthat accessdatabasesor log filesoften write a tiny data fragment (for example, one line in a log file) and then
call fsync immediately in order to ensure that the written data isphysically stored on the hard disk. Unfortunately, fsync will
alwaysinitiate two write operations: one for the newly written data and another one in order to update the modification time
stored in the inode. If the modification time isnot a part of the transaction concept fdatasync can be used to avoid
unnecessary inode disk write operations.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
757
ERRORS
EBADF f d isnot a valid file descriptor open for writing.
EROFS, EINVAL f d isbound to a special file which doesnot support synchronization.
EIO An error occurred during synchronization.
BUGS
Currently (Linux 1.3.86) fdatasync isequivalent to fsync.
CONFORMS TO
POSIX.4
SEE ALSO
fsync(2), B.O. Gallmeister, POSIX.4, OReilly, pp. 220223, 343.
Linux 1.3.86, 13 April 1996
flock
flockAppliesor removesan advisory lock on an open file
SYNOPSIS
#include <sys/file.h>
int flock(int fd,intoperation);
DESCRIPTION
Apply or remove an advisory lock on an open file. The file isspecified by f d. Valid operationsare given here:
LOCK_SH Shared lock. More than one processmay hold a shared lock for a given file at a given time.
LOCK_EX Exclusive lock. Only one processmay hold an exclusive lock for a given file at a given time.
LOCK_UN Unlock.
LOCK_NB Dont block when locking. May be specified (by oring) along with one of the other
operations.
A single file may not have both shared and exclusive locks. A file islocked (that is, the
inode), not the file descriptor. So, dup(2) and fork(2) do not create multiple instances
of a lock.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EWOULDBLOCK The file islocked and the LOCK_NB flag wasselected.
NOTES
Under Linux, flock isimplemented asa call to fcntl. Please see fcntl(2) for more detailson errors.
SEE ALSO
open(2), close(2), dup(2), execve(2), fcntl(2), fork(2)
Linux 0.99.11, 22 July1993
flock
Part II: SystemCalls
758
fork, vfork
fork, vforkCreatesa child process
SYNOPSIS
#include <unistd.h>
pid t fork(void);
pid t vfork(void);
DESCRIPTION
fork createsa child processthat differsfrom the parent processonly in itsPID and PPID, and in the fact that resource
utilizationsare set to 0. File locksand pending signalsare not inherited.
Under Linux, fork isimplemented using copy-on-write pages, so the only penaltiesincurred by fork are the time and
memory required to duplicate the parentspage tablesand to create a unique task structure for the child.
RETURN VALUE
On success, the PID of the child processisreturned in the parentsthread of execution, and a 0 isreturned in the childs
thread of execution. On failure, a 1 will be returned in the parentscontext, no child processwill be created, and errno will
be set appropriately.
ERRORS
EAGAIN fork cannot allocate sufficient memory to copy the parentspage tablesand allocate a task
structure for the child.
BUGS
Under Linux, vfork ismerely an aliasfor fork. fork never returnsthe error ENOMEM.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
clone(2), execve(2), wait(2)
Linux 1.2.9, 10 June1995
fsync
fsyncSynchronizesa filescomplete in-core state with that on disk
SYNOPSIS
#include <unistd.h>
int fsync(int f d);
DESCRIPTION
fsync copiesall in-core partsof a file to disk.
In some applications, fdatasync isa more efficient alternative to fsync.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
759
ERRORS
EBADF f d isnot a valid file descriptor open for writing.
EROFS, EINVAL f d isbound to a special file that doesnot support synchronization.
EIO An error occurred during synchronization.
CONFORMS TO
POSIX.1b
SEE ALSO
bdflush(2), fdatasync(2), sync(2), update(8), sync(8)
Linux 1.3.85, 13 April 1996
getdents
getdentsGetsdirectory entries
SYNOPSIS
#include <unistd.h>
#include <linux/dirent.h>
#include <linux/unistd.h>
syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count);
int getdents(unsigned int f d, struct dirent *di r p, unsigned int count );
DESCRIPTION
getdents readsseveral di r ent structuresfrom the directory pointed at by f d into the memory area pointed to by di r p. The
parameter count isthe size of the memory area.
The di r ent structure isdeclared asfollows:
struct dirent
{
long d_ino; /* inode number */
off_t d_off; /* offset to next dirent */
unsigned short d_reclen; /* length of this dirent */
char d_name [NAME_MAX+1]; /* file name (null-terminated) */
}
d_i no isan inode number. d_of f isthe distance from the start of the directory to the start of the next di r ent . d_r ecl en isthe
size of thisentire dirent. d_name isa null-terminated filename.
Thiscall supersedesreaddir(2).
RETURN VALUE
On success, the number of bytesread isreturned. On end of directory, 0 isreturned. On error, 1 isreturned and errno isset
appropriately.
ERRORS
EBADF Invalid file descriptor f d.
ENOTDIR File descriptor doesnot refer to a directory.
SEE ALSO
readdir(2), readdir(3)
Linux 1.3.6, 22 July1995
getdents
Part II: SystemCalls
760
getdomainname, setdomainname
getdomainname, setdomainnameGets/setsdomain name
SYNOPSIS
#include <unistd.h>
int getdomainname(char *name, size_t l en);
int setdomainname(const char *name, size_t l en);
DESCRIPTION
These functionsare used to accessor to change the domain name of the current processor.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL For getdomainname, name pointsto NULL or name islonger than l en.
EPERM For setdomainname, the caller wasnot the superuser.
EINVAL For setdomainname, l en wastoo long.
CONFORMS TO
POSIX doesnot specify these calls.
BUGS
getdomainname isnot compliant with other implementationsbecause they alwaysreturn l en bytes, even if name islonger.
Linux, however, returnsEINVAL in thiscase (asof DLL 4.4.1 libraries).
NOTES
Under Linux, getdomainname isimplemented at the library level by calling uname(2).
SEE ALSO
gethostname(2), sethostname(2), uname(2)
Linux 0.99.11, 22 July1993
getdtablesize
getdtablesizeGetsdescriptor table size
SYNOPSIS
#include <unistd.h>
int getdtablesize(void);
DESCRIPTION
getdtablesize returnsthe maximum number of filesa processcan have open.
NOTES
getdtablesize isimplemented asa library function in DLL 4.4.1. Thisfunction returnsOPEN_MAX (set to 256 in Linux
0.99.11) if OPEN_MAX wasdefined when the library wascompiled. Otherwise, 1 isreturned and errno isset to ENOSYS.
761
SEE ALSO
close(2), dup(2), open(2)
Linux 0.99.11, 22 July1993
getgid, getegid
getgid, getegidGetsgroup identity
SYNOPSIS
#include <unistd.h>
gid_t getgid(void);
gid_t getegid(void);
DESCRIPTION
getgid returnsthe real group ID of the current process.
getegid returnsthe effective group ID of the current process.
The real ID correspondsto the ID of the calling process. The effective ID correspondsto the set ID bit on the file being
executed.
ERRORS
These functionsare alwayssuccessful.
CONFORMS TO
POSIX, BSD 4.3
SEE ALSO
setregid(2), setgid(2)
Linux 0.99.11, 23 July1993
getgroups, setgroups
getgroups, setgroupsGets/setsgroup accesslist
SYNOPSIS
#include <unistd.h>
int getgroups(int si ze, gid_t l i st []);
#define_USE_BSD
#include <grp.h>
int setgroups(size_t si ze, const gid_t *l i st );
DESCRIPTION
getgroups Up to si ze supplemental groupsare returned in l i st . If si ze is0, l i st isnot modified, but
the total number of supplemental groupsfor the processisreturned.
setgroups Setsthe supplemental groupsfor the process. Only the superuser may use thisfunction.
getgroups, setgroups
Part II: SystemCalls
762
RETURN VALUE
getgroups On success, the number of groupsstored in list isreturned (if si ze is0, however, the
number of supplemental group IDsassociated with the processisreturned). On error, 1 is
returned and errno isset appropriately.
setgroups On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EFAULT l i st hasan invalid address.
EPERM For setgroups, the user isnot the superuser.
EINVAL For setgroups, gi dset si ze isgreater than NGROUPS (32 for Linux 0.99.11).
CONFORMS TO
getgroups conformsto POSIX.1 (and ispresent in BSD 4.3). Since setgroups requiresprivilege, it isnot covered under
POSIX.1.
BUGS
The USE BSD flag probably shouldnt be required for setgroups.
SEE ALSO
initgroups(3)
Linux 0.99.11, 23 July1993
gethostid, sethostid
gethostid, sethostidGets/setsthe unique identifier of the current host
SYNOPSIS
#include <unistd.h>
long int gethostid(void);
int sethostid(long int hostid);
DESCRIPTION
Get or set a unique 32-bit identifier for the current machine. The 32-bit identifier isintended to be unique among all UNIX
systemsin existence. Thisnormally resemblesthe Internet addressfor the local machine, asreturned by gethostbyname(3),
and thususually never needsto be set.
The sethostid call isrestricted to the superuser.
The host i d argument isstored in the file /etc/hostid.
RETURN VALUES
gethostid returnsthe 32-bit identifier for the current host asset by sethostid(2).
CONFORMS TO
POSIX.1 doesnot define these functions, but ISO/IEC 9945-1:1990 mentionsthem in B.4.4.1.
FILES
/etc/hostid
763
SEE ALSO
hostid(1), gethostbyname(3)
Linux 0.99.13, 29 November 1993
gethostname, sethostname
gethostname, sethostnameGets/setshostname
SYNOPSIS
#include <unistd.h>
int gethostname(char *name, size_t l en);
int sethostname(const char *name, size_t l en);
DESCRIPTION
These functionsare used to accessor to change the hostname of the current processor.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL l en isnegative or, for sethostname, larger than the maximum allowed size. For gethostname
on Linux/i386, l en issmaller than the actual size.
EPERM For sethostname, the caller wasnot the superuser.
EFAULT name isan invalid address.
CONFORMS TO
POSIX.1 doesnot define these functions, but ISO/IEC 9945-1:1990 mentionsthem in B.4.4.1.
BUGS
Some other implementationsof gethostname successfully return l en byteseven if name islonger. Linux/Alpha complieswith
thisbehavior. Linux/i386, however, returnsEINVAL in thiscase (asof DLL 4.6.27 libraries).
NOTES
Under Linux/Alpha, gethostname isa system call. Under Linux/i386, gethostname isimplemented at the library level by
calling uname(2).
SEE ALSO
getdomainname(2), setdomainname(2), uname(2)
Linux 1.3.6, 22 July1995
getitimer, setitimer
getitimer, setitimerGets/setsvalue of an interval timer
SYNOPSIS
#include <sys/time.h>
int getitimer(int whi ch, struct itimerval *val ue);
int setitimer(int whi ch,conststruct itimer-val *val ue, struct itimerval *oval ue);
getitimer, setitimer
Part II: SystemCalls
764
DESCRIPTION
The system provideseach processwith three interval timers, each decrementing in a distinct time domain. When any timer
expires, a signal issent to the process, and the timer (potentially) restarts.
ITIMER_REAL Decrementsin real time and deliversSIGALRM upon expiration.
ITIMER_VIRTUAL Decrementsonly when the processisexecuting, and deliversSIGVTALRM upon expiration.
ITIMER_PROF Decrementsboth when the processexecutesand when the system isexecuting on behalf of
the process. Coupled with ITIMER_VIRTUAL, thistimer isusually used to profile the time
spent by the application in user and kernel space. SIGPROF isdelivered upon expiration.
Timer valuesare defined by the following structures:
struct itimerval {
struct timeval it_interval; /* next value */
struct timeval it_value; /* current value */
};
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
getitimer(2) fillsthe structure indicated by val ue with the current setting for the timer indicated by whi ch (one of
ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF). The element it_value isset to the amount of time remaining on the timer, or
0 if the timer isdisabled. Similarly, it_interval isset to the reset value. setitimer(2) setsthe indicated timer to the value in
val ue. If oval ue isnonzero, the old value of the timer isstored there.
Timersdecrement from i t _val ue to 0, generate a signal, and reset to i t _i nt er val . A timer that isset to 0 (i t _val ue is0 or the
timer expiresand i t _i nt er val is0) stops.
Both t v_sec and t v_usec are significant in determining the duration of a timer.
Timerswill never expire before the requested time, instead expiring some short, constant time afterward, dependent on the
system timer resolution (currently 10ms). Upon expiration, a signal will be generated and the timer reset. If the timer expires
while the processisactive (alwaystrue for ITIMER_VIRT), the signal will be delivered immediately when generated. Otherwise,
the delivery will be offset by a small time dependent on the system loading.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EFAULT val ue and oval ue are not valid pointers.
EINVAL whi ch isnot one of ITIMER_REAL, ITIMER_VIRT, or ITIMER_PROF.
SEE ALSO
gettimeofday(2), sigaction(2), signal(2)
BUGS
Under Linux, the generation and delivery of a signal are distinct and there each signal ispermitted only one outstanding
event. Itstherefore conceivable that under pathologically heavy loading, ITIMER_REAL will expire before the signal from a
previousexpiration hasbeen delivered. The second signal in such an event will be lost.
Linux 0.99.11, 5 August 1993
765
getpagesize
getpagesizeGetssystem page size
SYNOPSIS
#include <unistd.h>
size_t getpagesize(void);
DESCRIPTION
Returnsthe number of bytesin a page. Thisisthe systemspage size, which isnot necessarily the same asthe hardware page
size.
NOTES
getpagesize isimplemented asa library function in DLL 4.4.1. Depending on what isdefined when the library iscompiled,
thisfunction returnsEXEC_PAGESIZE (set to 4096 in Linux 0.99.11), NBPG (set to 4096 in Linux 0.99.11), or NBPC (not defined in
Linux 0.99.11 or DLL 4.4.1 libraries).
SEE ALSO
sbrk(2)
Linux 0.99.11, 23 July1993
getpeername
getpeernameGetsthe name of the connected peer
SYNOPSIS
int getpeername(int s, struct sockaddr *name,int*namel en);
DESCRIPTION
getpeername returnsthe name of the peer connected to socket s . The namel en parameter should be initialized to indicate the
amount of space pointed to by name. On return it containsthe actual size of the name returned (in bytes). The name is
truncated if the buffer provided istoo small.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EBADF The argument s isnot a valid descriptor.
ENOTSOCK The argument s isa file, not a socket.
ENOTCONN The socket isnot connected.
ENOBUFS Insufficient resourceswere available in the system to perform the operation.
EFAULT The name parameter pointsto memory not in a valid part of the processaddressspace.
HISTORY
The getpeername function call appeared in BSD 4.2.
SEE ALSO
accept(2), bind(2), getsockname(2)
BSD Man Page, 24 July1993
getpeername
Part II: SystemCalls
766
getpid, getppid
getpid, getppidGetsprocessidentification
SYNOPSIS
#include <unistd.h>
pid_t getpid(void);
pid_t getppid(void);
DESCRIPTION
getpid returnsthe processID of the current process. (Thisisoften used by routinesthat generate unique temporary
filenames.)
getppid returnsthe processID of the parent of the current process.
CONFORMS TO
POSIX, BSD 4.3, SVID
SEE ALSO
exec(2), fork(2), kill(2), mkstemp(3), tmpnam(3), tempnam(3), tmpfile(3)
Linux 0.99.11, 23 July1993
getpriority, setpriority
getpriority, setpriorityGets/setsprogram scheduling priority
SYNOPSIS
#include <sys/time.h>
#include <sys/resource.h>
int getpriority(int whi ch,int who);
int setpriority(int whi ch,int who,int pr i o);
DESCRIPTION
The scheduling priority of the process, processgroup, or user, asindicated by whi ch and who, isobtained with the getpriority
call and set with the setpriority call. whi ch isone of PRIO_PROCESS, PRIO_PGRP,or PRIO_USER, and who isinterpreted relative to
whi ch (a processidentifier for PRIO_PROCESS, processgroup identifier for PRIO_PGRP, and a user ID for PRIO_USER). A 0 value of
who denotesthe current process, processgroup, or user. pr i o isa value in the range 20 to 20. The default priority is0; lower
prioritiescause more favorable scheduling.
The getpriority call returnsthe highest priority (lowest numerical value) enjoyed by any of the specified processes. The
setpriority call setsthe prioritiesof all the specified processesto the specified value. Only the superuser may lower priorities.
RETURN VALUES
Because getpriority can legitimately return the value 1, it isnecessary to clear the external variable errno prior to the call,
and then check it afterward to determine whether a 1 isan error or a legitimate value. The setpriority call returns0 if there
isno error, or 1 if there is.
ERRORS
ESRCH No processwaslocated using the whi ch and who valuesspecified.
EINVAL whi ch wasnot one of PRIO_PROCESS, PRIO_PGRP,or PRIO_USER.
767
In addition to these errors, setpriority will fail with the following:
EPERM A processwaslocated, but neither itseffective nor real user ID matched the effective user ID
of the caller.
EACCES A nonsuperuser attempted to lower a processpriority.
HISTORY
These function callsappeared in BSD 4.2.
SEE ALSO
nice(1), fork(2), renice(8)
BSD Man Page, 24 July1993
getrlimit, getrusage, setrlimit
getrlimit, getrusage, setrlimitGet/set resource limitsand usage
SYNOPSIS
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
int getrlimit (int r esour ce, struct rlimit *r l i m);
int getrusage (int who, struct rusage *usage);
int setrlimit (int r esour ce, const struct rlimit *r l i m);
DESCRIPTION
getrlimit and setrlimit get and set resource limits. r esour ce should be one of the following:
RLIMIT CPU /* CPU time in seconds */
RLIMIT FSIZE /* Maximum filesize */
RLIMIT DATA /* max data size */
RLIMIT STACK /* max stack size */
RLIMIT CORE /* max core file size */
RLIMIT RSS /* max resident set size */
RLIMIT NPROC /* max number of processes */
RLIMIT NOFILE /* max number of open files */
RLIMIT MEMLOCK /* max locked-in-memory address space*/
A resource may be unlimited if you set the limit to RLIM_INFINITY. RLIMIT_OFILE isthe BSD name for RLIMIT_NOFILE.
The rlimit structure isdefined asfollows:
struct rlimit
{
int rlim_cur;
int rlim_max;
};
getrusage returnsthe current resource usagesfor a who of either RUSAGE_SELF or RUSAGE_CHILDREN:
struct rusage
{
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
long ru_maxrss; /* maximum resident set size */
long ru_ixrss; /* integral shared memory size */
getrlimit, getrusage, setrlimit
Part II: SystemCalls
768
long ru_idrss; /* integral unshared data size */
long ru_isrss; /* integral unshared stack size */
long ru_minflt; /* page reclaims */
long ru_majflt; /* page faults */
long ru_nswap; /* swaps */
long ru_inblock; /* block input operations */
long ru_oublock; /* block output operations */
long ru_msgsnd; /* messages sent */
long ru_msgrcv; /* messages received */
long ru_nsignals; /* signals received */
long ru_nvcsw; /* voluntary context switches */
long ru_nivcsw; /* involuntary context switches */
};
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL getrlimit or setrlimit iscalled with a bad r esour ce. getrusage iscalled with a bad who.
EPERM A nonsuperuser triesto use setrlimit() to increase the soft or hard limit above the current
hard limit, or a superuser triesto increase RLIMIT_NOFILE above the current kernel maximum.
CONFORMS TO
BSD 4.3
SEE ALSO
ulimit(2), quota(2)
Linux, 23 July1993
getsid
getsidGetssession ID
SYNOPSIS
#include <unistd.h>
pid_t getsid(void);
DESCRIPTION
getsid(0) returnsthe session ID of the calling process. getsid(p) returnsthe session ID of the processwith processID p.
ERRORS
On error, 1 will be returned. The only error that can happen isESRCH, when no processwith processID p wasfound.
CONFORMS TO
Thiscall isLinux specific.
SEE ALSO
setsid(2)
Linux 1.3.85, 11 April 1996
769
getsockname
getsocknameGetssocket name
SYNOPSIS
int getsockname(int s , struct sockaddr * name , int * namelen );
DESCRIPTION
getsockname returnsthe current name for the specified socket. The namel en parameter should be initialized to indicate the
amount of space pointed to by name. On return it containsthe actual size of the name returned (in bytes).
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EBADF The argument s isnot a valid descriptor.
ENOTSOCK The argument s isa file, not a socket.
ENOBUFS Insufficient resourceswere available in the system to perform the operation.
EFAULT The name parameter pointsto memory not in a valid part of the processaddressspace.
HISTORY
The getsockname function call appeared in BSD 4.2.
BUGS
Namesbound to socketsin the UNIX domain are inaccessible; getsockname returnsa 0-length name.
SEE ALSO
bind(2), socket(2)
BSD Man Page, 24 July1993
getsockopt, setsockopt
getsockopt, setsockoptGet and set optionson sockets
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int getsockopt(int s ,intl evel ,intopt name,void*opt val ,int*opt l en);
int setsockopt(int s,intl evel ,intopt name, const void *opt val ,intopt l en);
DESCRIPTION
getsockopt and setsockopt manipulate the opt i ons associated with a socket. Optionsmay exist at multiple protocol levels;
they are alwayspresent at the uppermost socket level.
When manipulating socket options, the level at which the option residesand the name of the option must be specified. To
manipulate optionsat the socket level, l evel isspecified asSOL_SOCKET. To manipulate optionsat any other level, the protocol
number of the appropriate protocol controlling the option issupplied. For example, to indicate that an option isto be
interpreted by the TCP protocol, l evel should be set to the protocol number of TCP; see getprotoent(3).
getsockopt, setsockopt
Part II: SystemCalls
770
The parametersopt val and opt l en are used to accessoption valuesfor setsockopt. For getsockopt they identify a buffer in
which the value for the requested option(s) isto be returned. For getsockopt, opt l en isa value-result parameter, initially
containing the size of the buffer pointed to by opt val , and modified on return to indicate the actual size of the value
returned. If no option value isto be supplied or returned, opt val may be NULL.
opt name and any specified optionsare passed uninterpreted to the appropriate protocol module for interpretation. The
include file <sys/ socket . h> containsdefinitionsfor socket-level options, described below. Optionsat other protocol levels
vary in format and name; consult the appropriate entriesin section 4 of the manual.
Most socket-level optionsutilize an i nt parameter for opt val . For setsockopt, the parameter should be nonzero to enable a
boolean option, or 0 if the option isto be disabled. SO_LINGER usesa st r uct linger parameter, defined in <l i nux/ socket . h>,
which specifiesthe desired state of the option and the linger interval (see below). SO_SNDTIMEO and SO_RCVTIMEO use a st r uct
timeval parameter, defined in <sys/ t i me. h>.
The following optionsare recognized at the socket level. Except asnoted, each may be examined with getsockopt and set
with setsockopt:
SO_DEBUG Enablesrecording of debugging information.
SO_REUSEADDR Enableslocal addressreuse.
SO_KEEPALIVE Enableskeep connectionsalive.
SO_DONTROUTE Enablesrouting bypassfor outgoing messages.
SO_LINGER Linger on close if data present.
SO_BROADCAST Enablespermission to transmit broadcast messages.
SO_OOBINLINE Enablesreception of out-of-band data in band.
SO_SNDBUF Setsbuffer size for output.
SO_RCVBUF Setsbuffer size for input.
SO_SNDLOWAT Setsminimum count for output.
SO_RCVLOWAT Setsminimum count for input.
SO_SNDTIMEO Setstime-out value for output.
SO_RCVTIMEO Setstime-out value for input.
SO_TYPE Getsthe type of the socket (get only).
SO_ERROR Getsand clearserror on the socket (get only).
SO_DEBUG enablesdebugging in the underlying protocol modules.
SO_REUSEADDR indicatesthat the rulesused in validating addressessupplied in a bind(2) call should allow reuse of local
addresses.
SO_KEEPALIVE enablesthe periodic transmission of messageson a connected socket. Should the connected party fail to
respond to these messages, the connection isconsidered broken and processesusing the socket are notified via a SIGPIPE
signal when attempting to send data.
SO_DONTROUTE indicatesthat outgoing messagesshould bypassthe standard routing facilities. Instead, messagesare directed to
the appropriate network interface according to the network portion of the destination address.
SO_LINGER controlsthe action taken when unsent messagesare queued on socket and a close(2) isperformed. If the socket
promisesreliable delivery of data and SO_LINGER isset, the system will block the processon the close attempt until it isable to
transmit the data or until it decidesit isunable to deliver the information (a time-out period, termed the linger interval, is
specified in the setsockopt call when SO_LINGER isrequested). If SO_LINGER isdisabled and a close isissued, the system will
processthe close in a manner that allowsthe processto continue asquickly aspossible.
The l i nger structure isdefined in <l i nux/ socket . h> asfollows:
struct linger {
int l_onoff; /* Linger active */
int l_linger; /* How long to linger for */
};
771
l_onoff indicateswhether to linger. If it isset to 1, l_linger containsthe time in hundredthsof secondshow long the process
should linger to complete the close. If l_onoff isset to 0, the processreturnsimmediately.
The option SO_BROADCAST requestspermission to send broadcast datagramson the socket. Broadcast wasa privileged
operation in earlier versionsof the system. With protocolsthat support out-of-band data, the SO_OOBINLINE option requests
that out-of-band data be placed in the normal data input queue asreceived; it will then be accessible with recv or read calls
without the MSG_OOB flag. Some protocolsalwaysbehave asif thisoption isset.
SO_SNDBUF and SO_RCVBUF are optionsto adjust the normal buffer sizesallocated for output and input buffers, respectively. The
buffer size may be increased for high-volume connectionsor may be decreased to limit the possible backlog of incoming data.
The system placesan absolute limit on these values.
SO_SNDLOWAT isan option to set the minimum count for output operations. Most output operationsprocessall of the data
supplied by the call, delivering data to the protocol for transmission and blocking asnecessary for flow control. Nonblocking
output operationswill processasmuch data aspermitted subject to flow control without blocking, but will processno data if
flow control doesnot allow the smaller of the low water mark value or the entire request to be processed. A select(2)
operation testing the ability to write to a socket will return true only if the low water mark amount could be processed. The
default value for SO_SNDLOWAT isset to a convenient size for network efficiency, often 1024.
SO_RCVLOWAT isan option to set the minimum count for input operations. In general, receive callswill block until any
(nonzero) amount of data isreceived, then return with the smaller of the amount available or the amount requested. The
default value for SO_RCVLOWAT is1. If SO_RCVLOWAT isset to a larger value, blocking receive callsnormally wait until they have
received the smaller of the low water mark value or the requested amount. Receive callsmay still return lessthan the low
water mark if an error occurs, a signal iscaught, or the type of data next in the receive queue isdifferent than that returned.
SO_SNDTIMEO isan option to set a time-out value for output operations. It acceptsa st r uct timeval parameter with the
number of secondsand microsecondsused to limit waitsfor output operationsto complete. If a send operation hasblocked
for thismuch time, it returnswith a partial count or with the error EWOULDBLOCK if no data were sent. In the current
implementation, thistimer isrestarted each time additional data are delivered to the protocol, implying that the limit applies
to output portionsranging in size from the low water mark to the high water mark for output.
SO_RCVTIMEO isan option to set a time-out value for input operations. It acceptsa st r uct timeval parameter with the number
of secondsand microsecondsused to limit waitsfor input operationsto complete. In the current implementation, thistimer
isrestarted each time additional data are received by the protocol, and thusthe limit isin effect an inactivity timer. If a
receive operation hasbeen blocked for thismuch time without receiving additional data, it returnswith a short count or with
the error EWOULDBLOCK if no data were received.
Finally, SO_TYPE and SO_ERROR are optionsused only with setsockopt.
SO_TYPE returnsthe type of the socket, such asSOCK_STREAM; it isuseful for serversthat inherit socketson startup.
SO_ERROR returnsany pending error on the socket and clearsthe error status. It may be used to check for asynchronouserrors
on connected datagram socketsor for other asynchronouserrors.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EBADF The argument s isnot a valid descriptor.
ENOTSOCK The argument s isa file, not a socket.
ENOPROTOOPT The option isunknown at the level indicated.
EFAULT The addresspointed to by opt val isnot in a valid part of the processaddressspace. For
getsockopt, thiserror may also be returned if optlen isnot in a valid part of the process
addressspace.
getsockopt, setsockopt
Part II: SystemCalls
772
HISTORY
These system callsappeared in BSD 4.2.
BUGS
Several of the socket optionsshould be handled at lower levelsof the system.
SEE ALSO
ioctl(2), socket(2), getprotoent(3), protocols(5)
BSD Man Page, 22 April 1996
gettimeofday, settimeofday
gettimeofday, settimeofdayGet/set time
SYNOPSIS
#include <sys/time.h>
#include <unistd.h>
int gettimeofday(struct timeval *t v, struct timezone *t z);
int settimeofday(const struct timeval *t v , const struct timezone *t z);
DESCRIPTION
gettimeofday and settimeofday can set the time aswell asa time zone. t v isa timeval struct, asspecified in /usr/include/
sys/time.h:
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
and tz is a timezone:
struct timezone {
int tz_minuteswest;
/* minutes west of Greenwich */
int tz_dsttime;
/* type of dst correction */
};
with daylight savingstimesdefined asfollows:
DST_NONE /* not on dst */
DST_USA /* USA style dst */
DST_AUST /* Australian style dst */
DST_WET /* Western European dst */
DST_MET /* Middle European dst */
DST_EET /* Eastern European dst */
DST_CAN /* Canada */
DST_GB /* Great Britain and Eire */
DST_RUM /* Rumania */
DST_TUR /* Turkey */
DST_AUSTALT /* Australian style with shift in 1986 */
773
And the following macrosare defined to operate on this:
#define timerisset(tvp)\
((tvp)->tv_sec || (tvp)->tv_usec)
#define timercmp(tvp, uvp, cmp)\
((tvp)->tv_sec cmp (uvp)->tv_sec ||\
(tvp)->tv_sec == (uvp)->tv_sec &&\
(tvp)->tv_usec cmp (uvp)->tv_usec)
#define timerclear(tvp)
((tvp)->tv_sec = (tvp)->tv_usec = 0)
If either t v or t z isnull, the corresponding structure isnot set or returned.
Only the superuser can use settimeofday.
ERRORS
EPERM settimeofday iscalled by someone other than the superuser.
EINVAL Time zone (or something else) isinvalid.
CONFORMS TO
BSD 4.3
SEE ALSO
date(1), adjtimex(2), time(2), ctime(3), ftime(3)
Linux 1.2.4, 15 April 1995
getuid, geteuid
getuid, geteuidGet user identity
SYNOPSIS
#include <unistd.h>
uid_t getuid(void);
uid_t geteuid(void);
DESCRIPTION
getuid returnsthe real user ID of the current process.
geteuid returnsthe effective user ID of the current process.
The real ID correspondsto the ID of the calling process. The effective ID correspondsto the set ID bit on the file being
executed.
ERRORS
These functionsare alwayssuccessful.
CONFORMS TO
POSIX, BSD 4.3
SEE ALSO
setreuid(2), setuid(2)
Linux 0.99.11, 23 July1993
getuid, geteuid
Part II: SystemCalls
774
idle
idleMakesprocess0 idle
SYNOPSIS
#include <unistd.h>
void idle(void);
DESCRIPTION
idle isan internal system call used during bootstrap. It marksthe processspagesasswappable, lowersitspriority, and enters
the main scheduling loop. idle never returns.
Only process0 may call idle. Any user process, even a processwith superuser permission, will receive EPERM.
RETURN VALUE
idle never returnsfor process0, and alwaysreturns1 for a user process.
ERRORS
EPERM Always, for a user process.
Linux 1.1.46, 21 August 1994
ioctl
ioctlControlsdevices
SYNOPSIS
#include <sys/ioctl.h>
int ioctl(int d,intr equest , ...);
(The third argument istraditionally char *ar gp and will be so named for thisdiscussion.)
DESCRIPTION
The ioctl function manipulatesthe underlying device parametersof special files. In particular, many operating characteris-
ticsof character special files(for example, terminals) may be controlled with ioctl requests. The argument d must be an open
file descriptor.
An ioctl r equest hasencoded in it whether the argument isan i n parameter or out parameter, and the size of the argument
ar gp in bytes. Macrosand definesused in specifying an ioctl r equest are located in the file <sys/ i oct l . h>.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EBADF d isnot a valid descriptor.
ENOTTY d isnot associated with a character special device.
ENOTTY The specified request doesnot apply to the kind of object that the descriptor d references.
EINVAL r equest or ar gp isnot valid.
HISTORY
An ioctl function call appeared in version 7 AT&T UNIX.
775
SEE ALSO
execve(2), fcntl(2), mt(4), sd(4), tty(4)
INTRODUCTION
Thisisioctl List 1.3.27, a list of ioctl callsin Linux/i386 kernel 1.3.27. It contains421 ioctlsfrom /usr/include/
fasm,linuxg/*.h. For each ioctl, youll find the numerical value, name, and argument type.
An argument type of const struct foo * meansthe argument isinput to the kernel. struct foo * meansthe kernel outputs
the argument. If the kernel usesthe argument for both input and output, thisismarked with // I-O.
Some ioctlstake more argumentsor return more valuesthan a single structure. These are marked // MORE and are docu-
mented further in a separate section.
Thislist isincomplete. It doesnot include
I ioctlsdefined internal to the kernel (scsi ioctl.h).
I ioctlsdefined in modulesdistributed separately from the kernel.
And, of course, I may have errorsand omissions.
Please e-mail changesand commentsto mec@duracef.shout.net. I am particularly interested in loadable modulesthat define
their own ioctls. If you know of such a module, tell me where I can ftp it, and Ill include itsioctlsin my next release.
MAIN TABLE
<i ncl ude/ asm- i 386/ socket . h>
0x00008901 FIOSETOWN const int *
0x00008902 SIOCSPGRP const int *
0x00008903 FIOGETOWN int *
0x00008904 SIOCGPGRP int *
0x00008905 SIOCATMARK int *
0x00008906 SIOCGSTAMP timeval *
<i ncl ude/ asm- i 386/ t er mi os. h>
0x00005401 TCGETS struct termios *
0x00005402 TCSETS const struct termios *
0x00005403 TCSETSW const struct termios *
0x00005404 TCSETSF const struct termios *
0x00005405 TCGETA struct termio *
0x00005406 TCSETA const struct termio *
0x00005407 TCSETAW const struct termio *
0x00005408 TCSETAF const struct termio *
0x00005409 TCSBRK int
0x0000540A TCXONC int
0x0000540B TCFLSH int
0x0000540C TIOCEXCL void
0x0000540D TIOCNXCL void
0x0000540E TIOCSCTTY int
0x0000540F TIOCGPGRP pid_t *
0x00005410 TIOCSPGRP const pid_t *
ioctl
Part II: SystemCalls
776
0x00005411 TIOCOUTQ int *
0x00005412 TIOCSTI const char *
0x00005413 TIOCGWINSZ const struct winsize *
0x00005414 TIOCSWINSZ struct winsize *
0x00005415 TIOCMGET int *
0x00005416 TIOCMBIS const int *
0x00005417 TIOCMBIC const int *
0x00005418 TIOCMSET const int *
0x00005419 TIOCGSOFTCAR int *
0x0000541A TIOCSSOFTCAR const int *
0x0000541B FIONREAD int *
0x0000541B TIOCINQ int *
0x0000541C TIOCLINUX const char *
0x0000541D TIOCCONS void
0x0000541E TIOCGSERIAL struct serial_strucct *
0x0000541F TIOCSSERIAL const struct serial_strucct *
0x00005420 TIOCPKT const int *
0x00005421 FIONBIO const int *
0x00005422 TIOCNOTTY void
0x00005423 TIOCSETD const int *
0x00005424 TIOCGETD int *
0x00005425 TCSBRKP int
0x00005426 TIOCTTYGSTRUCT struct tty_strucct *
0x00005450 FIONCLEX void
0x00005451 FIOCLEX void
0x00005452 FIOASYNC const int *
0x00005453 TIOCSERCONFIG void
0x00005454 TIOCSERGWILD int *
0x00005455 TIOCSERSWILD const int *
0x00005456 TIOCGLCKTRMIOS struct termios *
0x00005457 TIOCSLCKTRMIOS const struct temios *
0x00005458 TIOCSERGSTRUCT struct async_strucct *
0x00005459 TIOCSERGETLSR int *
0x0000545A TIOCSERGETMULTI struct serial_multiport_strucct *
0x0000545B TIOCSERSETMULTI const struct serial_multiport_strucct *
<i ncl ude/ l i nux/ ax25. h>
0x000089E0 SIOCAX25GETUID const struct sockaddr_ax25 *
0x000089E1 SIOCAX25ADDUID const struct sockaddr_ax25 *
0x000089E2 SIOCAX25DELUID const struct sockaddr_ax25 *
0x000089E3 SIOCAX25NOUID const int *
<i ncl ude/ asm- i 386/ t er mi os. h>
777
0x000089E4 SIOCAX25DIGCTL const int *
0x000089E5 SIOCAX25GETPARMS struct ax25_parms_strucct * // I-O
0x000089E6 SIOCAX25SETPARMS const struct ax25_parms-struct *
<i ncl ude/ l i nux/ cdk. h>
0x00007314 STL_BINTR void
0x00007315 STL_BSTART void
0x00007316 STL_BSTOP void
0x00007317 STL_BRESET void
<i ncl ude/ l i nux/ cdr om. h>
0x00005301 CDROMPAUSE void
0x00005302 CDROMRESUME void
0x00005303 CDROMPLAYMSF const struct cdrom_msf *
0x00005304 CDROMPLAYTRKIND const struct cdrom_ti *
0x00005305 CDROMREADTOCHDR struct cdrom_tochdr *
0x00005306 CDROMREADTOCENTRY struct cdrom_tocentry *// I-O
0x00005307 CDROMSTOP void
0x00005308 CDROMSTART void
0x00005309 CDROMEJECT void
0x0000530A CDROMVOLCTRL const struct cdrom_volctrl *
0x0000530B CDROMSUBCHNL struct cdrom_subchnl * // I-O
0x0000530C CDROMREADMODE2 const struct cdrom_msf * // MORE
0x0000530D CDROMREADMODE1 const struct cdrom_msf * // MORE
0x0000530E CDROMREADAUDIO const struct cdrom_read_audio *
0x0000530F CDROMEJECT SW int
0x00005310 CDROMMULTISESSION struct cdrom_multisession * // I-O
0x00005311 CDROM_GET_UPC struct f char [8]; g *
0x00005312 CDROMRESET void
0x00005313 CDROMVOLREAD struct cdrom_volctrl *
0x00005314 CDROMREADRAW const struct cdrom_msf * // MORE
0x00005315 CDROMREADCOOKED const struct cdrom_msf * // MORE
0x00005316 CDROMSEEK const struct cdrom_msf *
<i ncl ude/ l i nux/ cm206. h>
0x00002000 CM206CTL_GET_STAT int
0x00002001 CM206CTL_GET_LAST_STAT int
<i ncl ude/ l i nux/ ax25. h>
ioctl
Part II: SystemCalls
778
<i ncl ude/ l i nux/ cycl ades. h>
0x00435901 CYGETMON struct cyclades_monitor *
0x00435902 CYGETTHRESH int *
0x00435903 CYSETTHRESH int
0x00435904 CYGETDEFTHRESH int *
0x00435905 CYSETDEFTHRESH int
0x00435906 CYGETTIMEOUT int *
0x00435907 CYSETTIMEOUT int
0x00435908 CYGETDEFTIMEOUT int *
0x00435909 CYSETDEFTIMEOUT int
<i ncl ude/ l i nux/ ext 2 f s. h>
0x80046601 EXT2_IOC_GETFLAGS int *
0x40046602 EXT2_IOC_SETFLAGS const int *
0x80047601 EXT2_IOC_GETVERSION int *
0x40047602 EXT2_IOC_SETVERSION const int *
<i ncl ude/ l i nux/ f d. h>
0x00000000 FDCLRPRM void
0x00000001 FDSETPRM const struct floppy_struct *
0x00000002 FDDEFPRM const struct floppy_struct *
0x00000003 FDGETPRM struct floppy_struct *
0x00000004 FDMSGON void
0x00000005 FDMSGOFF void
0x00000006 FDFMTBEG void
0x00000007 FDFMTTRK const struct format_descr *
0x00000008 FDFMTEND void
0x0000000A FDSETEMSGTRESH int
0x0000000B FDFLUSH void
0x0000000C FDSETMAXERRS const struct floppy_max_errors *
0x0000000E FDGETMAXERRS struct floppy_max_errors *
0x00000010 FDGETDRVTYP struct f char [16]; g *
0x00000014 FDSETDRVPRM const struct floppy_drive_params *
0x00000015 FDGETDRVPRM struct floppy_drive_params *
0x00000016 FDGETDRVSTAT struct floppy_drive_struct *
0x00000017 FDPOLLDRVSTAT struct floppy_drive_struct *
0x00000018 FDRESET int
0x00000019 FDGETFDCSTAT struct floppy_fdc_state *
0x0000001B FDWERRORCLR void
0x0000001C FDWERRORGET struct floppy_write_errors *
0x0000001E FDRAWCMD struct floppy_raw_cmd * // MORE // I-O
0x00000028 FDTWADDLE void
779
<i ncl ude/ l i nux/ f s. h>
0x0000125D BLKROSET const int *
0x0000125E BLKROGET int *
0x0000125F BLKRRPART void
0x00001260 BLKGETSIZE int *
0x00001261 BLKFLSBUF void
0x00001262 BLKRASET int
0x00001263 BLKRAGET int *
0x00000001 FIBMAP int * // I-O
0x00000002 FIGETBSZ int *
<i ncl ude/ l i nux/ hdr eg. h>
0x00000301 HDIO_GETGEO struct hd geometry *
0x00000302 HDIO_GET_UNMASKINTR int *
0x00000304 HDIO_GET_MULTCOUNT int *
0x00000307 HDIO_GET_IDENTITY struct hd driveid *
0x00000308 HDIO_GET_KEEPSETTINGS int *
0x00000309 HDIO_GET_CHIPSET int *
0x0000030A HDIO_GET_NOWERR int *
0x0000030B HDIO_GET_DMA int *
0x0000031F HDIO_DRIVE_CMD int * // I-O
0x00000321 HDIO_SET_MULTCOUNT int
0x00000322 HDIO_SET_UNMASKINTR int
0x00000323 HDIO_SET_KEEPSETTINGS int
0x00000324 HDIO_SET_CHIPSET int
0x00000325 HDIO_SET_NOWERR int
0x00000326 HDIO_SET_DMA int
<i ncl ude/ l i nux/ i f eql . h>
0x000089F0 EQL_ENSLAVE struct ifreq * // MORE // I-O
0x000089F1 EQL_EMANCIPATE struct ifreq * // MORE // I-O
0x000089F2 EQL_GETSLAVECFG struct ifreq * // MORE // I-O
0x000089F3 EQL_SETSLAVECFG struct ifreq * // MORE // I-O
0x000089F4 EQL_GETMASTRCFG struct ifreq * // MORE // I-O
0x000089F5 EQL_SETMASTRCFG struct ifreq * // MORE // I-O
<i ncl ude/ l i nux/ i f pl i p. h>
0x000089F0 SIOCDEVPLIP struct ifreq * // I-O
ioctl
Part II: SystemCalls
780
<i ncl ude/ l i nux/ i f ppp. h>
0x00005490 PPPIOCGFLAGS int *
0x00005491 PPPIOCSFLAGS const int *
0x00005492 PPPIOCGASYNCMAP int *
0x00005493 PPPIOCSASYNCMAP const int *
0x00005494 PPPIOCGUNIT int *
0x00005495 PPPIOCSINPSIG const int *
0x00005497 PPPIOCSDEBUG const int *
0x00005498 PPPIOCGDEBUG int *
0x00005499 PPPIOCGSTAT struct ppp_stats *
0x0000549A PPPIOCGTIME struct ppp_ddinfo *
0x0000549B PPPIOCGXASYNCMAP struct f int [8]; g *
0x0000549C PPPIOCSXASYNCMAP const struct f int [8]; g *
0x0000549D PPPIOCSMRU const int *
0x0000549E PPPIOCRASYNCMAP const int *
0x0000549F PPPIOCSMAXCID const int *
<i ncl ude/ l i nux/ i px. h>
0x000089E0 SIOCAIPXITFCRT const char *
0x000089E1 SIOCAIPXPRISLT const char *
0x000089E2 SIOCIPXCFGDATA struct ipx_config_data *
<i ncl ude/ l i nux/ kd. h>
0x00004B60 GIO_FONT struct f char [8192]; g *
0x00004B61 PIO_FONT const struct f char [8192]; g *
0x00004B6B GIO_FONTX struct console_font_desc * // MORE I-O
0x00004B6C PIO_FONTX const struct console_font_desc * //MORE
0x00004B70 GIO_CMAP struct f char [48]; g *
0x00004B71 PIO_CMAP const struct f char [48]; g
0x00004B2F KIOCSOUND int
0x00004B30 KDMKTONE int
0x00004B31 KDGETLED char *
0x00004B32 KDSETLED int
0x00004B33 KDGKBTYPE char *
0x00004B34 KDADDIO int // MORE
0x00004B35 KDDELIO int // MORE
0x00004B36 KDENABIO void // MORE
0x00004B37 KDDISABIO void // MORE
0x00004B3A KDSETMODE int
0x00004B3B KDGETMODE int *
0x00004B3C KDMAPDISP void // MORE
781
0x00004B3D KDUNMAPDISP void // MORE
0x00004B40 GIO_SCRNMAP struct f char [E_TABSZ]; g *
0x00004B41 PIO_SCRNMAP const struct f char [E_TABSZ]; g *
0x00004B69 GIO_UNISCRNMAP struct f short [E_TABSZ]; g *
0x00004B6A PIO_UNISCRNMAP const struct f short [E_TABSZ]; g *
0x00004B66 GIO_UNIMAP struct unimapdesc * // MORE // I-O
0x00004B67 PIO_UNIMAP const struct unimapdesc * // MORE
0x00004B68 PIO_UNIMAPCLR const struct unimapinit *
0x00004B44 KDGKBMODE int *
0x00004B45 KDSKBMODE int
0x00004B62 KDGKBMETA int *
0x00004B63 KDSKBMETA int
0x00004B64 KDGKBLED int *
0x00004B65 KDSKBLED int
0x00004B46 KDGKBENT struct kbentry * // I-O
0x00004B47 KDSKBENT const struct kbentry *
0x00004B48 KDGKBSENT struct kbsentry * // I-O
0x00004B49 KDSKBSENT const struct kbsentry *
0x00004B4A KDGKBDIACR struct kbdiacrs *
0x00004B4B KDSKBDIACR const struct kbdiacrs *
0x00004B4C KDGETKEYCODE struct kbkeycode * // I-O
0x00004B4D KDSETKEYCODE const struct kbkeycode *
0x00004B4E KDSIGACCEPT int
<i ncl ude/ l i nux/ l p. h>
0x00000601 LPCHAR int
0x00000602 LPTIME int
0x00000604 LPABORT int
0x00000605 LPSETIRQ int
0x00000606 LPGETIRQ int *
0x00000608 LPWAIT int
0x00000609 LPCAREFUL int
0x0000060A LPABORTOPEN int
0x0000060B LPGETSTATUS int *
0x0000060C LPRESET void
0x0000060D LPGETSTATS struct lp stats *
<i ncl ude/ l i nux/ mr out e. h>
0x000089E0 SIOCGETVIFCNT struct sioc_vif_req * // I-O
0x000089E1 SIOCGETSGCNT struct sioc_sg_req * // I-O
<i ncl ude/ l i nux/ kd. h>
ioctl
Part II: SystemCalls
782
<i ncl ude/ l i nux/ mt i o. h>
0x40086D01 MTIOCTOP const struct mtop *
0x801C6D02 MTIOCGET struct mtget *
0x80046D03 MTIOCPOS struct mtpos *
0x80206D04 MTIOCGETCONFIG struct mtconfiginfo *
0x40206D05 MTIOCSETCONFIG const struct mtconfiginfo *
<i ncl ude/ l i nux/ net r om. h>
0x000089E0 SIOCNRGETPARMS struct nr_parms_struct * // I-O
0x000089E1 SIOCNRSETPARMS const struct nr_parms_struct *
0x000089E2 SIOCNRDECOBS void
0x000089E3 SIOCNRRTCTL const int *
<i ncl ude/ l i nux/ sbpcd. h>
0x00009000 DDIOCSDBG const int *
0x00005382 CDROMAUDIOBUFSIZ int
<i ncl ude/ l i nux/ scc. h>
0x00005470 TIOCSCCINI void
0x00005471 TIOCCHANINI const struct scc_modem *
0x00005472 TIOCGKISS struct ioctl_command * // I-O
0x00005473 TIOCSKISS const struct ioctl_command *
0x00005474 TIOCSCCSTAT struct scc_stat *
<i ncl ude/ l i nux/ scsi . h>
0x00005382 SCSI_IOCTL_GET_IDLUN struct f int [2]; g *
0x00005383 SCSI_IOCTL_TAGGED_ENABLE void
0x00005384 SCSI_IOCTL_TAGGED_DISABLE void
0x00005385 SCSI_IOCTL_PROBE_HOST const int * // MORE
<i ncl ude/ l i nux/ smb f s. h>
0x80027501 SMB_IOC_GETMOUNTUID uid t *
<i ncl ude/ l i nux/ socki os. h>
0x0000890B SIOCADDRT const struct rtentry * // MORE
0x0000890C SIOCDELRT const struct rtentry * // MORE
0x00008910 SIOCGIFNAME char []
0x00008911 SIOCSIFLINK void
0x00008912 SIOCGIFCONF struct ifconf * // MORE // I-O
0x00008913 SIOCGIFFLAGS struct ifreq * // I-O
0x00008914 SIOCSIFFLAGS const struct ifreq *
783
0x00008915 SIOCGIFADDR struct ifreq * // I-O
0x00008916 SIOCSIFADDR const struct ifreq *
0x00008917 SIOCGIFDSTADDR struct ifreq * // I-O
0x00008918 SIOCSIFDSTADDR const struct ifreq *
0x00008919 SIOCGIFBRDADDR struct ifreq * // I-O
0x0000891A SIOCSIFBRDADDR const struct ifreq *
0x0000891B SIOCGIFNETMASK struct ifreq * // I-O
0x0000891C SIOCSIFNETMASK const struct ifreq *
0x0000891D SIOCGIFMETRIC struct ifreq * // I-O
0x0000891E SIOCSIFMETRIC const struct ifreq *
0x0000891F SIOCGIFMEM struct ifreq * // I-O
0x00008920 SIOCSIFMEM const struct ifreq *
0x00008921 SIOCGIFMTU struct ifreq * // I-O
0x00008922 SIOCSIFMTU const struct ifreq *
0x00008923 OLD SIOCGIFHWADDR struct ifreq * // I-O
0x00008924 SIOCSIFHWADDR const struct ifreq * // MORE
0x00008925 SIOCGIFENCAP int *
0x00008926 SIOCSIFENCAP const int *
0x00008927 SIOCGIFHWADDR struct ifreq * // I-O
0x00008929 SIOCGIFSLAVE void
0x00008930 SIOCSIFSLAVE void
0x00008931 SIOCADDMULTI const struct ifreq *
0x00008932 SIOCDELMULTI const struct ifreq *
0x00008940 SIOCADDRTOLD void
0x00008941 SIOCDELRTOLD void
0x00008950 SIOCDARP const struct arpreq *
0x00008951 SIOCGARP struct arpreq * // I-O
0x00008952 SIOCSARP const struct arpreq *
0x00008960 SIOCDRARP const struct arpreq *
0x00008961 SIOCGRARP struct arpreq * // I-O
0x00008962 SIOCSRARP const struct arpreq *
0x00008970 SIOCGIFMAP struct ifreq * // I-O
0x00008971 SIOCSIFMAP const struct ifreq *
<i ncl ude/ l i nux/ soundcar d. h>
0x00005100 SNDCTL_SEQ_RESET void
0x00005101 SNDCTL_SEQ_SYNC void
0xC08C5102 SNDCTL_SYNTH_INFO struct synth_info * // I-O
0xC0045103 SNDCTL_SEQ_CTRLRATE int * // I-O
0x80045104 SNDCTL_SEQ_GETOUTCOUNT int *
0x80045105 SNDCTL_SEQ_GETINCOUNT int *
0x40045106 SNDCTL_SEQ_PERCMODE void
<i ncl ude/ l i nux/ socki os. h>
ioctl
Part II: SystemCalls
784
<i ncl ude/ l i nux/ soundcar d. h>
0x40285107 SNDCTL FM LOAD INSTR const struct sbi_instrument *
0x40045108 SNDCTL_SEQ_TESTMIDI const int *
0x40045109 SNDCTL_SEQ_RESETSAMPLES const int *
0x8004510A SNDCTL_SEQ_NRSYNTHS int *
0x8004510B SNDCTL_SEQ_NRMIDIS int *
0xC074510C SNDCTL_MIDI_INFO struct midi_info * // I-O
0x4004510D SNDCTL_SEQ_THRESHOLD const int *
0xC004510E SNDCTL_SYNTH_MEMAVL int * // I-O
0x4004510F SNDCTL_FM_4OP_ENABLE const int *
0xCFB85110 SNDCTL_PMGR_ACCESS struct patmgr_info * // I-O
0x00005111 SNDCTL_SEQ_PANIC void
0x40085112 SNDCTL_SEQ_OUTOFBAND const struct seq_event_rec *
0xC0045401 SNDCTL_TMR_TIMEBASE int * // I-O
0x00005402 SNDCTL_TMR_START void
0x00005403 SNDCTL_TMR_STOP void
0x00005404 SNDCTL_TMR_CONTINUE void
0xC0045405 SNDCTL_TMR_TEMPO int * // I-O
0xC0045406 SNDCTL_TMR_SOURCE int * // I-O
0x40045407 SNDCTL_TMR_METRONOME const int *
0x40045408 SNDCTL_TMR_SELECT int * // I-O
0xCFB85001 SNDCTL_PMGR_IFACE struct patmgr_info * // I-O
0xC0046D00 SNDCTL_MIDI_PRETIME int * // I-O
0xC0046D01 SNDCTL_MIDI_MPUMODE const int *
0xC0216D02 SNDCTL_MIDI_MPUCMD struct mpu_command_rec * // I-O
0x00005000 SNDCTL_DSP_RESET void
0x00005001 SNDCTL_DSP_SYNC void
0xC0045002 SNDCTL_DSP_SPEED int * // I-O
0xC0045003 SNDCTL_DSP_STEREO int * // I-O
0xC0045004 SNDCTL_DSP_GETBLKSIZE int * // I-O
0xC0045006 SOUND_PCM_WRITE CHANNELS int * // I-O
0xC0045007 SOUND_PCM_WRITE FILTER int * // I-O
0x00005008 SNDCTL_DSP_POST void
0xC0045009 SNDCTL_DSP_SUBDIVIDE int * // I-O
0xC004500A SNDCTL_DSP_SETFRAGMENT int * // I-O
0x8004500B SNDCTL_DSP_GETFMTS int *
0xC0045005 SNDCTL_DSP_SETFMT int * // I-O
0x800C500C SNDCTL_DSP_GETOSPACE struct audio-buf-info *
0x800C500D SNDCTL_DSP_GETISPACE struct audio-buf-info *
0x0000500E SNDCTL_DSP_NONBLOCK void
0x80045002 SOUND_PCM_READ RATE int *
0x80045006 SOUND_PCM_READ CHANNELS int *
0x80045005 SOUND_PCM_READ BITS int *
785
0x80045007 SOUND_PCM_READ FILTER int *
0x00004300 SNDCTL_COPR_RESET void
0xCFB04301 SNDCTL_COPR_LOAD const struct copr_buffer *
0xC0144302 SNDCTL_COPR_RDATA struct copr_debug_buf * // I-O
0xC0144303 SNDCTL_COPR_RCODE struct copr_debug_buf * // I-O
0x40144304 SNDCTL_COPR_WDATA const struct copr_debug_buf *
0x40144305 SNDCTL_COPR_WCODE const struct copr_debug_buf *
0xC0144306 SNDCTL_COPR_RUN struct copr_debug_buf * // I-O
0xC0144307 SNDCTL_COPR_HALT struct copr_debug_buf * // I-O
0x4FA44308 SNDCTL_COPR_SENDMSG const struct copr_msg *
0x8FA44309 SNDCTL_COPR_RCVMSG struct copr_msg *
0x80044D00 SOUND_MIXER_READ_VOLUME int *
0x80044D01 SOUND_MIXER_READ_BASS int *
0x80044D02 SOUND_MIXER_READ_TREBLE int *
0x80044D03 SOUND_MIXER_READ_SYNTH int *
0x80044D04 SOUND_MIXER_READ_PCM int *
0x80044D05 SOUND_MIXER_READ_SPEAKER int *
0x80044D06 SOUND_MIXER_READ_LINE int *
0x80044D07 SOUND_MIXER_READ_MIC int *
0x80044D08 SOUND_MIXER_READ_CD int *
0x80044D09 SOUND_MIXER_READ_IMIX int *
0x80044D0A SOUND_MIXER_READ_ALTPCM int *
0x80044D0B SOUND_MIXER_READ_RECLEV int *
0x80044D0C SOUND_MIXER_READ_IGAIN int *
0x80044D0D SOUND_MIXER_READ_OGAIN int *
0x80044D0E SOUND_MIXER_READ_LINE1 int *
0x80044D0F SOUND_MIXER_READ_LINE2 int *
0x80044D10 SOUND_MIXER_READ_LINE3 int *
0x80044D1C SOUND_MIXER_READ_MUTE int *
0x80044D1D SOUND_MIXER_READ_ENHANCE int *
0x80044D1E SOUND_MIXER_READ_LOUD int *
0x80044DFF SOUND_MIXER_READ_RECSRC int *
0x80044DFE SOUND_MIXER_READ_DEVMASK int *
0x80044DFD SOUND_MIXER_READ_RECMASK int *
0x80044DFB SOUND_MIXER_READ_STEREODEVS int *
0x80044DFC SOUND_MIXER_READ_CAPS int *
0xC0044D00 SOUND_MIXER_WRITE_VOLUME int * // I-O
0xC0044D01 SOUND_MIXER_WRITE_BASS int * // I-O
0xC0044D02 SOUND_MIXER_WRITE_TREBLE int * // I-O
0xC0044D03 SOUND_MIXER_WRITE_SYNTH int * // I-O
0xC0044D04 SOUND_MIXER_WRITE_PCM int * // I-O
0xC0044D05 SOUND_MIXER_WRITE_SPEAKER int * // I-O
<i ncl ude/ l i nux/ soundcar d. h>
ioctl
Part II: SystemCalls
786
0xC0044D06 SOUND_MIXER_WRITE_LINE int * // I-O
0xC0044D07 SOUND_MIXER_WRITE_MIC int * // I-O
0xC0044D08 SOUND_MIXER_WRITE_CD int * // I-O
0xC0044D09 SOUND_MIXER_WRITE_IMIX int * // I-O
0xC0044D0A SOUND_MIXER_WRITE_ALTPCM int * // I-O
0xC0044D0B SOUND_MIXER_WRITE_RECLEV int * // I-O
0xC0044D0C SOUND_MIXER_WRITE_IGAIN int * // I-O
0xC0044D0D SOUND_MIXER_WRITE_OGAIN int * // I-O
0xC0044D0E SOUND_MIXER_WRITE_LINE1 int * // I-O
0xC0044D0F SOUND_MIXER_WRITE_LINE2 int * // I-O
0xC0044D10 SOUND_MIXER_WRITE_LINE3 int * // I-O
0xC0044D1C SOUND_MIXER_WRITE_MUTE int * // I-O
0xC0044D1D SOUND_MIXER_WRITE_ENHANCE int * // I-O
0xC0044D1E SOUND_MIXER_WRITE_LOUD int * // I-O
0xC0044DFF SOUND_MIXER_WRITE_RECSRC int * // I-O
<i ncl ude/ l i nux/ umsdos f s. h>
0x000004D2 UMSDOS_READDIR_DOS struct umsdos_ioctl * // I-O
0x000004D3 UMSDOS_UNLINK_DOS const struct umsdos_ioctl *
0x000004D4 UMSDOS_RMDIR_DOS const struct umsdos_ioctl *
0x000004D5 UMSDOS_STAT_DOS struct umsdos_ioctl * // I-O
0x000004D6 UMSDOS_CREAT_EMD const struct umsdos_ioctl *
0x000004D7 UMSDOS_UNLINK_EMD const struct umsdos_ioctl *
0x000004D8 UMSDOS_READDIR_EMD struct umsdos_ioctl * // I-O
0x000004D9 UMSDOS_GETVERSION struct umsdos_ioctl *
0x000004DA UMSDOS_INIT_EMD void
0x000004DB UMSDOS_DOS_SETUP const struct umsdos_ioctl *
0x000004DC UMSDOS_RENAME_DOS const struct umsdos_ioctl *
<i ncl ude/ l i nux/ vt . h>
0x00005600 VT_OPENQRY int *
0x00005601 VT_GETMODE struct vt_mode *
0x00005602 VT_SETMODE const struct vt_mode *
0x00005603 VT_GETSTATE struct vt_stat *
0x00005604 VT_SENDSIG void
0x00005605 VT_RELDISP int
0x00005606 VT_ACTIVATE int
0x00005607 VT_WAI TACTI VE int
0x00005608 VT_DISALLOCATE int
0x00005609 VT_RESIZE const struct vt_sizes *
0x0000560A VT_RESIZEX const struct vt_consize *
<i ncl ude/ l i nux/ soundcar d. h>
787
MORE ARGUMENTS
Some ioctlstake a pointer to a structure that containsadditional pointers. These are documented here in alphabetical order.
CDROMREADAUDIO takesan input pointer const struct cdrom read audio *. The buf field pointsto an output buffer of length
nframes * CD FRAMESIZE RAW.
CDROMREADCOOKED, CDROMREADMODE1, CDROMREADMODE2, and CDROM-READRAW take an input pointer const struct cdrom msf *. They
use the same pointer asan output pointer to char []. The length variesby request. For CDROMREADMODE1, most driversuse
CD_FRAMESIZE, but the opticsstorage driver usesOPT BLOCKSIZE instead (both have the numerical value 2048).
CDROMREADCOOKED char [CD_FRAMESIZE]
CDROMREADMODE1 char [CD_FRAMESIZE or OPT_BLOCKSIZE]
CDROMREADMODE2 char [CD_FRAMESIZE_RAW0]
CDROMREADRAW char [CD_FRAMESIZE_RAW]
EQL_ENSLAVE, EQL_EMANCIPATE, EQL_GETSLAVECFG, EQL_SETSLAVECFG, EQL_GETMASTERCFG, and EQL_SETMASTERCFG take a struct
ifreq *. The ifr data field isa pointer to another structure asfollows:
EQL_ENSLAVE const struct slaving_request *
EQL_EMANCIPATE const struct slaving_request *
EQL_GETSLAVECFG struct slave_config * // I-O
EQL_SETSLAVECFG const struct slave_config *
EQL_GETMASTERCFG struct master_config *
EQL_SETMASTERCFG const struct master_config *
FDRAWCMD takesa struct floppy raw cmd *. If flags & FD RAW WRITE isnonzero, then data pointsto an input buffer of length
length. If flags & FD RAW READ isnonzero, then data pointsto an output buffer of length length.
GIO_FONTX and PIO_FONTX take a struct console font desc * or a const struct console_font_desc *, respectively. chardata
pointsto a buffer of char [charcount]. Thisisan output buffer for GIO_FONTX and an input buffer for PIO_FONTX.
GIO_UNIMAP and PIO_UNIMAP take a struct unimapdesc * or a const struct unimapdesc *, respectively. entries pointsto a
buffer of struct unipair [entry ct]. Thisisan output buffer for GIO_UNIMAP and an input buffer for PIO_UNIMAP.
KDADDIO, KDDELIO, KDDISABIO, and KDENABIO enable or disable accessto I/O ports. They are essentially alternate interfacesto
ioperm.
KDMAPDISP and KDUNMAPDISP enable or disable memory mappingsor I/O port access. They are not implemented in the kernel.
SCSI_IOCTL_PROBE_HOST takesan input pointer const int *, which isa length. It usesthe same pointer asan output pointer to
a char [] buffer of thislength.
SIOCADDRT and SIOCDELRT take an input pointer whose type dependson the protocol:
Most protocols const struct rtentry *
AX.25 const struct ax25_route *
NET/ROM const struct nr_route_struct *
SIOCGIFCONF takesa struct ifconf *. The ifc buf field pointsto a buffer of length ifc len bytes, into which the kernel writes
a list of type struct ifreq [].
SIOCSIFHWADDR takesan input pointer whose type dependson the protocol:
Most protocols const struct ifreq *
AX.25 const char [AX25_ADDR_LEN]
TIOCLINUX takesa const char *. It usesthisto distinguish several independent subcases. In the following table, N + foo means
foo after an N-byte pad. struct selection isimplicitly defined in drivers/char/selection.c:
ioctl
Part II: SystemCalls
788
TIOCLINUX-2 1 + const struct selection *
TIOCLINUX-3 void
TIOCLINUX-4 void
TIOCLINUX-5 4 + const struct f long [8]; g *
TIOCLINUX-6 char *
TIOCLINUX-7 char *
TIOCLINUX-10 1 + const char *
DUPLICATE ioctlS
Thislist doesnot include ioctlsin the range SIOCDEVPRIVATE and SIOCPROTOPRIVATE:
0x00000001 FDSETPRM FIBMAP
0x00000002 FDDEFPRM FIGETBSZ
0x00005382 CDROMAUDIOBUFSIZ SCSI_IOCTL_GET_IDLUN
0x00005402 SNDCTL_TMR_START TCSETS
0x00005403 SNDCTL_TMR_STOP TCSETSW
0x00005404 SNDCTL_TMR_CONTINUE TCSETSF
Linux, 17 September 1995
ioperm
iopermSetsport input/output permissions
SYNOPSIS
#include <unistd.h>
int ioperm(unsigned long f r om, unsigned long num,intt ur n_on);
DESCRIPTION
ioperm setsthe port accesspermission bitsfor the processfor num bytesstarting from port addressfrom to the value t ur n_on.
The use of ioperm requiresroot privileges.
Only the first 03ff I/O portscan be specified in thismanner. For more ports, the iopl function must be used. Permissions
are not inherited on fork, but on exec they are. Thisisuseful for giving port accesspermissionsto nonprivileged tasks.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
CONFORMS TO
ioperm isLinux specific.
SEE ALSO
iopl(2)
Linux, 21 January1993
iopl
ioplChangesI/O privilege level
789
SYNOPSIS
#include <unistd.h>
int iopl(int l evel );
DESCRIPTION
iopl changesthe I/O privilege level of the current process, asspecified in l evel .
Thiscall isnecessary to allow 8514-compatible X serversto run under Linux. Because these X serversrequire accessto all
65536 I/O ports, the ioperm call isnot sufficient.
In addition to granting unrestricted I/O port access, running at a higher I/O privilege level also allowsthe processto disable
interrupts. Thiswill probably crash the system and isnot recommended.
The I/O privilege level for a normal processis0.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL l evel isgreater than 3.
EPERM The current user isnot the superuser.
NOTES FROM THE KERNEL SOURCE
iopl hasto be used when you want to accessthe I/O portsbeyond the 0x3ff range: To get the full 65536 portsbitmapped,
youd need 8KB of bitmaps/process, which isa bit excessive.
SEE ALSO
ioperm(2)
Linux 0.99.11, 24 July1993
ipc
ipcSystem V IPC system calls
SYNOPSIS
int ipc(unsigned int cal l , int f i r st , int second,
int t hi r d, void *pt r , long f i f t h);
DESCRIPTION
ipc isa common kernel entry point for the System V IPC callsfor messages, semaphores, and shared memory. cal l
determineswhich IPC function to invoke; the other argumentsare passed through to the appropriate call.
User programsshould call the appropriate functionsby their usual names. Only standard library implementorsand kernel
hackersneed to know about ipc.
SEE ALSO
msgctl(2), msgget(2), msgrcv(2), msgsnd(2), semctl(2), semget(2), semop(2), shmat(2), shmctl(2), shmdt(2), shmget(2)
Linux 1.2.4, 15 April 1995
ipc
Part II: SystemCalls
790
kill
killSendssignal to a process
SYNOPSIS
#include <sys/types.h>
#include <signal.h>
int kill(pid t pi d,intsi g);
DESCRIPTION
The kill system call can be used to send any signal to any processgroup or process.
If pi d ispositive, then signal si g issent to pi d. In thiscase, 0 isreturned on successand a negative value isreturned on error.
If pi d equals1, then si g issent to every processexcept the first one, from higher numbersin the proc table to lower. In this
case, 0 isreturned on success, or the error condition resulting from signaling the last processisreturned.
If pi d islessthan 1, then si g issent to every processin the processgroup pi d. In thiscase, the number of processesthe
signal wassent to isreturned and a negative value isreturned for failure.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL An invalid signal issent.
ESRCH The pid or processgroup doesnot exist. Note that an existing processmight be a zombie, a
processthat already committed termination, but hasnot yet been wait()ed for.
EPERM The effective userID of the processcalling kill() isnot equal to the effective user ID of pi d,
unlessthe superuser called kill().
BUGS
It isimpossible to send a signal to task number one, the init process, for which it hasnot installed a signal handler. Thisis
done to ensure that the system isnot brought down accidentally.
CONFORMS TO
SVID, AT&T, POSIX.1, X/OPEN, BSD 4.3
SEE ALSO
exit(2), exit(2), signal(2), signal(7)
Linux, 1 November 1995
killpg
killpgSendssignal to a processgroup
SYNOPSIS
#include <signal.h>
int killpg(int pgr p,intsi g);
DESCRIPTION
killpg sendsthe signal si g to the processgroup pgr p. See sigaction(2) for a list of signals. If pgr p is0, killpg sendsthe signal
to the sending processsprocessgroup.
791
The sending processand membersof the processgroup must have the same effective user ID, or the sender must be the
superuser. Asa single special case, the continue signal SIGCONT may be sent to any processthat isa descendant of the current
process.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL si g isnot a valid signal number.
ESRCH No processcan be found in the processgroup specified by pgr p.
ESRCH The processgroup wasgiven as0, but the sending processdoesnot have a processgroup.
EPERM The sending processisnot the superuser and one or more of the target processeshasan
effective user ID different from that of the sending process.
HISTORY
The killpg function call appeared in BSD4.0.
SEE ALSO
kill(2), getpgrp(2), signal(2)
BSD Man Page, 23 July1993
link
linkMakesa new name for a file
SYNOPSIS
#include <unistd.h>
int link(const char *ol dpat h, const char *newpat h);
DESCRIPTION
link createsa new link (also known asa hard link) to an existing file.
If newpat h exists, it will not be overwritten.
Thisnew name may be used exactly asthe old one for any operation; both namesrefer to the same file (and so have the same
permissionsand ownership) and it isimpossible to tell which name wasthe original.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EXDEV ol dpat h and newpat h are not on the same filesystem.
EPERM The filesystem containing ol dpat h and newpat h doesnot support the creation of hard links.
EFAULT ol dpat h or newpat h pointsoutside your accessible addressspace.
EACCES Write accessto the directory containing newpat h isnot allowed for the processseffective
UID, or one of the directoriesin ol dpat h or newpat h did not allow search (execute)
permission.
ENAMETOOLONG ol dpat h or newpat h wastoo long.
ENOENT A directory component in ol dpat h or newpat h doesnot exist or isa dangling symbolic link.
ENOTDIR A component used asa directory in ol dpat h or newpat h isnot, in fact, a directory.
link
Part II: SystemCalls
792
ENOMEM Insufficient kernel memory wasavailable.
EROFS The file ison a read-only filesystem.
EEXIST newpat h already exists.
EMLINK The file referred to by ol dpat h already hasthe maximum number of linksto it.
ELOOP ol dpat h or newpat h containsa reference to a circular symbolic link, that is, a symbolic link
whose expansion containsa reference to itself.
ENOSPC The device containing the file hasno room for the new directory entry.
EPERM ol dpat h isthe . or .. entry of a directory.
NOTES
Hard links, ascreated by link, cannot span filesystems. Use symlink if thisisrequired.
CONFORMS TO
SVID, AT&T, POSIX, BSD 4.3
BUGS
On NFS file systems, the return code may be wrong in case the NFS server performsthe link creation and diesbefore it can
say so. Use stat(2) to find out if the link wascreated.
SEE ALSO
symlink(2), unlink(2), rename(2), open(2), stat(2), ln(1), link(8)
Linux, 17 August 1994
listen
listenListensfor connectionson a socket
SYNOPSIS
#include <sys/socket.h>
int listen(int_s,int backl og);
DESCRIPTION
To accept connections, a socket isfirst created with socket(2), a willingnessto accept incoming connectionsand a queue
limit for incoming connectionsare specified with listen, and then the connectionsare accepted with accept(2). The listen
call appliesonly to socketsof type SOCK_STREAM or SOCK_SEQPACKET.
The backl og parameter definesthe maximum length the queue of pending connectionsmay grow to. If a connection request
arriveswith the queue full, the client might receive an error with an indication of ECONNREFUSED, or, if the underlying protocol
supportsretransmission, the request may be ignored so that retriesmay succeed.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EBADF The argument s isnot a valid descriptor.
ENOTSOCK The argument s isnot a socket.
EOPNOTSUPP The socket isnot of a type that supportsthe operation listen.
HISTORY
The listen function call appeared in BSD 4.2.
793
BUGS
If the socket isof type af_inet and the backlog argument isgreater than 128, it issilently truncated to 128. For portable
applications, dont rely on thisvalue since BSD (and at least some BSD-derived systems) limit the backlog to 5.
SEE ALSO
accept(2), connect(2), socket(2)
BSD Man Page, 23 July1993
llseek
_llseekRepositionsthe read/write file offset
SYNOPSIS
#include <unistd.h>
#include <linux/unistd.h>
_syscall5(int, llseek, uint, fd, ulong, hi, ulong, lo, loff_t*,res,uint,wh);
int llseek(unsigned int f d, unsigned long of f set _hi gh,
unsigned long of f set _l ow,loff_t * r esul t , unsigned int whence);
DESCRIPTION
The _llseek function repositionsthe offset of the file descriptor f d to ( of f set _hi gh<<32) | offset_low bytesrelative to the
beginning of the file, the current position in the file, or the end of the file, depending on whether whence isSEEK_SET,
SEEK_CUR,or SEEK_END, respectively. It returnsthe resulting file position in the argument r esul t .
RETURN VALUES
Upon successful completion, _llseek returns0. Otherwise, a value of 1 isreturned and errno isset to indicate the error.
ERRORS
EBADF f d isnot an open file descriptor.
EINVAL whence isinvalid.
CONFORMS TO
Thisfunction isLinux specific.
BUGS
There isno support for fileswith a size of 2GB or more.
SEE ALSO
lseek(2)
Linux 1.2.9, 10 June1995
lseek
lseekRepositionsread/write file offset
SYNOPSIS
#include <unistd.h>
off_t lseek(int f i l des ,off_t of f set ,int whence);
lseek
Part II: SystemCalls
794
DESCRIPTION
The lseek function repositionsthe offset of the file descriptor f i l des to the argument of f set according to the directive
whence. The argument f i l des must be an open file descriptor. lseek repositionsthe file pointer f i l des asfollows:
If whence isSEEK_SET, the offset isset to of f set bytes.
If whence isSEEK_CUR, the offset isset to itscurrent location plusof f set bytes.
If whence isSEEK_END, the offset isset to the size of the file plusof f set bytes.
The lseek function allowsthe file offset to be set beyond the end of the existing end-of-file of the file. If data islater written
at thispoint, subsequent readsof the data in the gap return bytesof zeros(until data isactually written into the gap).
Some devicesare incapable of seeking. The value of the pointer associated with such a device isundefined.
RETURN VALUES
Upon successful completion, lseek returnsthe resulting offset location asmeasured in bytesfrom the beginning of the file.
Otherwise, a value of 1 isreturned and errno isset to indicate the error.
ERRORS
EBADF f i l des isnot an open file descriptor.
ESPIPE f i l des isassociated with a pipe, socket, or FIFO.
EINVAL whence isnot a proper value.
CONFORMS TO
POSIX, BSD 4.3
BUGS
Thisdocumentsuse of whence isincorrect English, but maintained for historical reasons.
SEE ALSO
dup(2), open(2), fseek(3)
Linux 1.2.9, 10 June1995
mkdir
mkdirCreatesa directory
SYNOPSIS
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
int mkdir(const char *pat hname, mode_t mode);
DESCRIPTION
mkdir attemptsto create a directory named pat hname.
mode specifiesthe permissionsto use. It ismodified by the processsumask in the usual way: the permissionsof the created
file is(mode & umask).
The newly created directory will be owned by the effective UID of the process. If the directory containing the file hasthe set
group ID bit set, or if the filesystem ismounted with BSD group semantics, the new directory will inherit the group
ownership from itsparent; otherwise, it will be owned by the effective GID of the process.
If the parent directory hasthe set group ID bit set, so will the newly created directory.
795
RETURN VALUE
mkdir returns0 on success, or -1 if an error occurred (in which case, errno isset appropriately).
ERRORS
EEXIST pat hname already exists(not necessarily asa directory).
EFAULT pat hname pointsoutside your accessible addressspace.
EACCES The parent directory doesnot allow write permission to the process, or one of the
directoriesin pat hname did not allow search (execute) permission.
ENAMETOOLONG pat hname wastoo long.
ENOENT A directory component in pat hname doesnot exist or isa dangling symbolic link.
ENOTDIR A component used asa directory in pat hname isnot, in fact, a directory.
ENOMEM Insufficient kernel memory wasavailable.
EROFS pat hname refersto a file on a read-only filesystem and write accesswasrequested.
ELOOP pat hname containsa reference to a circular symbolic link, that is, a symbolic link whose
expansion containsa reference to itself.
ENOSPC The device containing pathnamehasno room for the new directory.
ENOSPC The new directory cannot be created because the usersdisk quota isexhausted.
BUGS
In some older versionsof Linux (for example, 0.99pl7) all the normal filesystemssometime allow the creation of two filesin
the same directory with the same name. Thisoccursonly rarely and only on a heavily loaded system. It isbelieved that this
bug wasfixed in the Minix filesystem in Linux 0.99pl8 prerelease; and it ishoped that it wasfixed in the other filesystems
shortly afterward.
There are many infelicitiesin the protocol underlying NFS.
SEE ALSO
read(2), write(2), fcntl(2), close(2), unlink(2), open(2), mknod(2), stat(2), umask(2), mount(2), socket(2), socket(2), fopen(3)
Linux 1.0, 29 March 1994
mknod
mknodCreatesa directory
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int mknod(const char *pat hname, mode_t mode,dev_t dev);
DESCRIPTION
mknod attemptsto create a filesystem node (file, device special file, or named pipe) named pat hname, specified by mode and dev.
mode specifiesboth the permissionsto use and the type of node to be created.
It should be a combination (using bitwise OR) of one of the file typeslisted below and the permissionsfor the new node.
The permissionsare modified by the processsumask in the usual way: The permissionsof the created node is(mode &
umask).
mknod
Part II: SystemCalls
796
The file type should be one of S_IFREG, S_IFCHR, S_IFBLK, or S_IFIFO to specify a normal file (which will be created empty),
character special file, block special file, or FIFO (named pipe), respectively, or 0, which will create a normal file.
If the file type isS_IFCHR or S_IFBLK, then dev specifiesthe major and minor numbersof the newly created device special file;
otherwise, it isignored.
The newly created node will be owned by the effective UID of the process. If the directory containing the node hasthe set
group ID bit set, or if the filesystem ismounted with BSD group semantics, the new node will inherit the group ownership
from itsparent directory; otherwise it will be owned by the effective GID of the process.
RETURN VALUE
mknod returns0 on success, or -1 if an error occurred (in which case, errno isset appropriately).
ERRORS
EPERM mode requested creation of something other than a FIFO (named pipe), and the caller isnot
the superuser; also returned if the filesystem containing pat hname doesnot support the type
of node requested.
EINVAL mode requested creation of something other than a normal file, device special file or FIFO.
EEXIST pat hname already exists.
EFAULT pat hname pointsoutside your accessible addressspace.
EACCES The parent directory doesnot allow write permission to the process, or one of the
directoriesin pat hname did not allow search (execute) permission.
ENAMETOOLONG pat hname wastoo long.
ENOENT A directory component in pat hname doesnot exist or isa dangling symbolic link.
ENOTDIR A component used asa directory in pat hname isnot, in fact, a directory.
ENOMEM Insufficient kernel memory wasavailable.
EROFS pat hname refersto a file on a read-only filesystem and write accesswasrequested.
ELOOP pat hname containsa reference to a circular symbolic link, that is, a symbolic link whose
expansion containsa reference to itself.
ENOSPC The device containing pat hname hasno room for the new node.
BUGS
In some older versionsof Linux (for example, 0.99pl7) all the normal filesystemssometime allow the creation of two filesin
the same directory with the same name. Thisoccursonly rarely and only on a heavily loaded system. It isbelieved that this
bug wasfixed in the Minix filesystem in Linux 0.99pl8 prerelease; and it ishoped that it wasfixed in the other filesystems
shortly afterward.
mknod cannot be used to create directoriesor socket files, and cannot be used to create normal filesby usersother than the
superuser.
There are many infelicitiesin the protocol underlying NFS.
SEE ALSO
read(2), write(2), fcntl(2), close(2), unlink(2), open(2), mkdir(2), stat(2), umask(2), mount(2), socket(2), fopen(3)
Linux 1.0, 29 March 1994
mlock
mlockDisablespaging for some partsof memory
797
SYNOPSIS
#include <sys/mman.h>
int mlock(const void *addr , size_t l en);
DESCRIPTION
mlock disablespaging for the memory in the range starting at addr with length l en bytes. All pagesthat contain a part of the
specified memory range are guaranteed to be resident in RAM when the mlock system call returnssuccessfully and they are
guaranteed to stay in RAM until the pagesare unlocked again by munlock or munlockall or until the processterminatesor
startsanother program with exec. Child processesdo not inherit page locksacrossa fork.
Memory locking hastwo main applications: real-time algorithmsand high-security data processing. Real-time applications
require deterministic timing, and, like scheduling, paging isone major cause of unexpected program execution delays. Real-
time applicationswill usually also switch to a real-time scheduler with sched setscheduler.
Cryptographic security software often handlescritical bytessuch aspasswordsor secret keysasdata structures. Asa result of
paging, these secretscould be transferred onto a persistent swap store medium, where they might be accessible to the enemy
long after the security software haserased the secretsin RAM and terminated.
Memory locksdo not stack, that is, pagesthat have been locked several timesby callsto mlock or mlockall will be unlocked
by a single call to munlock for the corresponding range or by munlockall. Pagesthat are mapped to several locationsor by
several processesstay locked into RAM aslong asthey are locked at least at one location or by at least one process.
On POSIX systemson which mlock and munlock are available, _POSIX_MEMLOCK_RANGE isdefined in <unistd.h> and the value
PAGESIZE from <limits.h> indicatesthe number of bytesper page.
RETURN VALUE
On success, mlock returns0. On error, 1 isreturned, errno isset appropriately, and no changesare made to any locksin the
addressspace of the process.
ERRORS
ENOMEM Some of the specified addressrange doesnot correspond to mapped pagesin the address
space of the processor the processtried to exceed the maximum number of allowed locked
pages.
EPERM The calling processdoesnot have appropriate privileges. Only root processesare allowed to
lock pages.
EINVAL l en wasnot a positive number.
STANDARDS
POSIX.1b, SVR4
SEE ALSO
munlock(2), mlockall(2), munlockall(2).
Linux 1.3.43, 26 November 1995
mlockall
mlockallDisablespaging for calling process
SYNOPSIS
#include <sys/mman.h>
int mlockall(int f l ags );
mlockall
Part II: SystemCalls
798
DESCRIPTION
mlockall disablespaging for all pagesmapped into the addressspace of the calling process. Thisincludesthe pagesof the
code, data and stack segments, shared libraries, user space kernel data, shared memory, and memory-mapped files. All
mapped pagesare guaranteed to be resident in RAM when the mlockall system call returnssuccessfully and they are
guaranteed to stay in RAM until the pagesare unlocked again by munlock or munlockall or until the processterminatesor
startsanother program with exec. Child processesdo not inherit page locksacrossa fork.
Memory locking hastwo main applications: real-time algorithmsand high-security data processing. Real-time applications
require deterministic timing, and, like scheduling, paging isone major cause of unexpected program execution delays. Real-
time applicationswill usually also switch to a real-time scheduler with sched setscheduler. Cryptographic security software
often handlescritical bytessuch aspasswordsor secret keysasdata structures. Asa result of paging, these secretscould be
transferred onto a persistent swap store medium, where they might be accessible to the enemy long after the security software
haserased the secretsin RAM and terminated. For security applications, only small partsof memory have to be locked, for
which mlock isavailable.
The f l ags parameter can be constructed from the logical OR of the following constants:
MCL_CURRENT Lock all pagesthat are currently mapped into the addressspace of the process.
MCL_FUTURE Lock all pagesthat will become mapped into the addressspace of the processin the future.
These could be, for instance, new pagesrequired by a growing heap and stack aswell asnew
memory mapped filesor shared memory regions.
If MCL_FUTURE hasbeen specified and the number of locked pagesexceedsthe upper limit of allowed locked pages, the system
call that caused the new mapping will fail with ENOMEM. If these new pageshave been mapped by the growing stack, the kernel
will deny stack expansion and send a SIGSEGV.
Real-time processesshould reserve enough locked stack pagesbefore entering the time-critical section, so no page fault can be
caused by function calls. Thiscan be achieved by calling a function that hasa sufficiently large automatic variable and that
writesto the memory occupied by thislarge array in order to touch these stack pages. Thisway, enough pageswill be
mapped for the stack and can be locked into RAM. The dummy writesensure that not even copy-on-write page faultscan
occur in the critical section.
Memory locksdo not stack, that is, pagesthat have been locked several timesby callsto mlockall or mlock will be unlocked
by a single call to munlockall. Pagesthat are mapped to several locationsor by several processesstay locked into RAM aslong
asthey are locked at least at one location or by at least one process.
On POSIX systemson which mlockall and munlockall are available, POSIX MEMLOCK isdefined in <unistd.h>.
RETURN VALUE
On success, mlockall returns0. On error, 1 isreturned and errno isset appropriately.
ERRORS
ENOMEM The processtried to exceed the maximum number of allowed locked pages.
EPERM The calling processdoesnot have appropriate privileges. Only root processesare allowed to
lock pages.
EINVAL Unknown flagswere specified.
STANDARDS
POSIX.1b, SVR4
SEE ALSO
munlockall(2), mlock(2), munlock(2)
Linux 1.3.43, 26 November 1995
799
mmap, munmap
mmap, munmapMap or unmap filesor devicesinto memory
SYNOPSIS
#include <unistd.h>
#include <sys/mman.h>
#ifdef POSIX MAPPED FILES
void * mmap(void *st ar t , size_t l engt h,int pr ot ,int f l ags ,int f d,off_t of f set );
int munmap(void *st ar t , size_t l engt h);
#endif
DESCRIPTION
The mmap function asksto map l engt h bytesstarting at offset of f set from the file (or other object) specified by f d into
memory, preferably at addressst ar t . Thislatter addressisa hint only, and isusually specified as0. The actual place where
the object ismapped isreturned by mmap.The pr ot argument describesthe desired memory protection. It hasthe following
bits:
PROT_EXEC Pagesmay be executed.
PROT_READ Pagesmay be read.
PROT_WRITE Pagesmay be written.
The f l ags parameter specifiesthe type of the mapped object, mapping options, and whether modificationsmade to the
mapped copy of the page are private to the processor are to be shared with other references. It hasthe following bits:
MAP_FIXED Do not select a different addressthan the one specified. If the specified addresscannot be
used, mmap will fail. If MAP_FIXED isspecified, st ar t must be a multiple of the pagesize. Use of
thisoption isdiscouraged.
MAP_SHARED Share thismapping with all other processesthat map thisobject.
MAP_PRIVATE Create a private copy-on-write mapping.
These three flagsare described in POSIX.4. Linux also knowsabout MAP_DENYWRITE, MAP_EXECUTABLE, and MAP_ANON(YMOUS).
The munmap system call deletesthe mappingsfor the specified addressrange and causesfurther referencesto addresseswithin
the range to generate invalid memory references.
RETURN VALUE
On success, mmap returnsa pointer to the mapped area. On error, MAP_FAILED (1) isreturned and errno isset appropriately.
On success, munmap returns0, and on failure it returns1 and setserrno (probably to EINVAL).
ERRORS
EBADF f d isnot a valid file descriptor (and MAP_ANONYMOUS wasnot set).
EACCES MAP_PRIVATE wasasked, but f d isnot open for reading. Or MAP_SHARED wasasked and
PROT_WRITE isset, f d isnot open for writing.
EINVAL st ar t or l engt h, and of f set are too large, or not aligned on a PAGESIZE boundary.
ETXTBUSY MAP_DENYWRITE wasset but the object specified by f d isopen for writing.
EAGAIN The file hasbeen locked, or too much memory hasbeen locked.
ENOMEM No memory isavailable.
CONFORMS TO
POSIX.4.
mmap, munmap
Part II: SystemCalls
800
SEE ALSO
getpagesize(2), msync(2), shm_open(2), B. O. Gallmeister, POSIX.4, OReilly, pp. 128129, 389391.
Linux 1.3.86, 12 April 1996
modify_ldt
modify_ldtGetsor setsldt
SYNOPSIS
#include <linux/ldt.h> #include <linux/unistd.h>
_syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount )
int modify_ldt(int f unc,void *pt r , unsigned long byt ecount );
DESCRIPTION
modify_ldt readsor writesthe local descriptor table (ldt) for a process. The ldt isa per-processmemory-management table
used by the i386 processor. For more information on thistable, see an Intel 386 processor handbook.
When f unc is0, modify_ldt readsthe ldt into the memory pointed to by pt r . The number of bytesread isthe smaller of
byt ecount and the actual size of the ldt.
When f unc is1, modify_ldt modifiesone ldt entry. pt r pointsto a modi f y_l dt _l dt _s structure and byt ecount must equal the
size of thisstructure.
RETURN VALUE
On success, modify_ldt returnseither the actual number of bytesread (for reading) or 0 (for writing). On failure, modify_ldt
returns1 and setserrno.
ERRORS
ENOSYS f unc isneither 0 nor 1.
EINVAL pt r is0, or f unc is1 and byt ecount isnot equal to the size of the structure
modi f y_l dt _l dt _s,or f unc is1 and the new ldt entry hasillegal values.
EFAULT pt r pointsoutside the addressspace.
SEE ALSO
vm86(2)
Linux 1.3.6, 22 July1995
get_kernel_syms, create_module, init_module, delete_module
get_kernel_syms, create_module, init_module, delete_moduleLoadable module support
SYNOPSIS
#include <linux/module.h>
int get_kernel_syms(struct kernel_sym *table);
int create_module(char *module_name, unsigned long size);
801
int init_module(char *module_name, char *code, unsigned codesize,
struct mod_routines *routines, struct symbol_table *symtab);
int delete_module(char *module_name);
struct kernel_sym {
unsigned long value;
char name[SYM_MAX_NAME];
};
struct mod_routines {
int (*init)(void);
void (*cleanup)(void);
};
struct module_ref {
struct module *module;
struct module_ref *next;
};
struct internal_symbol {
void *addr;
char *name;
};
struct symbol_table {
int size; /* total, including string table!!! */
int n_symbols;
int n_refs;
struct internal_symbol symbol[0];
struct module_ref ref[0];
};
DESCRIPTION
These system callshave not yet been included in any library, which meansthat they have to be called by the
syscall(_NR_function) mechanism. get_kernel_syms(table); hastwo uses: First, if table isNULL, thiscall will only return the
number of symbols, including module names, that are available. Thisnumber should be used to reserve memory for that
many itemsof struct kernel sym.
If table isnot NULL, thiscall will copy all kernel symbolsand module names(and version info) from the kernel to the space
pointed to by table. The entriesare ordered in module LIFO order. For each module an entry that describesthe module will
be followed by entriesdescribing the symbolsexported by thismodule.
Note that for symbolsthat describe a module, the value part of the structure will contain the kernel addressof the structure
that describesthe module.
The name part of the structure isthe module name prepended with #, asin #my module. The symbol that describesa module
will appear before the symbolsdefined by thismodule.
Ahead of the kernel resident symbols, a module name symbol with the dummy name # will appear. Thisinformation can
be used to build a table of module referenceswhen modulesare stacked (or layered). create_module(module_name, size); will
allocate size bytesof kernel space for a module and also create the necessary kernel structures called namefor the new
module. The module will now exist in kernel space, with the statusMOD_UNINITIALIZED.init module(module_name, code,
codesize, routines, symtab);.
Thisisthe actual module loader that will load the module named name into the kernel. The parameterscode and codesize
refer to the relocated binary object module that iscodesize byteslong. Note that the first 4 byteswill be used asa reference
counter in kernel space, updated by the MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT macros.
get_kernel_syms, create_module, init_module, delete_module
Part II: SystemCalls
802
The functionsdescribed in routineswill be used to start and stop the module. These pointersshould therefore contain the
addressesof the init_module() and cleanup_module() functionsthat have to be defined for all loadable modules.
If a module wantsto export symbolsfor use by other modules, or if the module makesreferencesto symbolsdefined by other
modules, the parameter symtab hasto point to a structure that describesthese. A NULL value for symtab meansthat no symbols
are exported and no referencesto other modulesare made.
The symtab that will be copied into the kernel consistsof a symbol table structure immediately followed by a string table,
containing the namesof the symbolsdefined by the module. The size element hasto include the size of thisstring table as
well. Special considerationsfollow.
The n_symbols and n_refs elementstellshow many symbolsand how many module referencesare included in the symbol
table structure. Immediately after these integers, the array of symbol definitionsfollows. The name element in each struct
internal symbol should actually not be an ordinary pointer, but instead the offset of the corresponding string table entry
relative to the start of the symbol table structure.
When all defined symbolshave been listed, the symbol_table structure continueswith the array of module references, as
described by the struct module_ref elements. Only the module field of these structureshave to be initialized. The module
addressesthat were obtained from a previousget_kernel_syms call, for elementswith namesstarting with # should be copied
to thisfield.
If the module could be successfully loaded, and if the call to the module function init_module() also succeeds, the statusof
the module will be changed to MOD_RUNNING. Otherwise, the kernel memory occupied by module will be freed.
delete_module(module_name); should be used to unload a module. If the module reference count showsthat the module isnot
active, and if there are no referencesto thismodule from other modules, the module function cleanup_module() will be
called. If all these stepssucceed, the kernel memory occupied by the module and itsstructureswill be freed.
DIAGNOSTICS
If there are any errors, these functionswill return the value -1, and the global variable errno will contain the error number. A
descriptive text will also be written on the console device.
SEE ALSO
insmod(1), rmmod(1), lsmod(1), ksyms(1)
HISTORY
The module support wasfirst conceived by Anonymous.
Linux version by BasLaarhoven (bas@vimec.nl), 0.99.14 version by Jon Tombs(jon@gtex02.us.es), extended by Bjorn
Ekwall (bj0rn@blox.se).
BUGS
Naah...
Linux, 25 January1995
mount, umount
mount, umountMount and unmount filesystems.
SYNOPSIS
#include <sys/mount.h>
#include <linux/fs.h>
int mount(const char *speci al f i l e, const char * di r ,
const char * f i l esyst emt ype, unsigned long r wf l ag , const void * dat a);
int umount(const char *speci al f i l e);
int umount(const char *di r );
803
DESCRIPTION
mount attachesthe filesystem specified by speci al f i l e (which isoften a device name) to the directory specified by di r .
umount removesthe attachment of the filesystem specified by speci al f i l e or di r .
Only the superuser may mount and unmount filesystems.
The f i l esyst emt ype argument may take one of the valueslisted in /proc/filesystems (such asminix, ext2, msdos, proc, nfs,
iso9660).
The r wf l ag argument hasthe magic number 0xC0ED in the top 16 bits, and variousmount flags(asdefined in <linux/fs.h>) in
the low order 16 bits:
#define MS_RDONLY 1 /* mount read-only */
#define MS_NOSUID 2 /* ignore suid and sgid bits */
#define MS_NODEV 4 /* disallow access to device special files */
#define MS_NOEXEC 8 /* disallow program execution */
#define MS_SYNC 16 /* writes are synced at once */
#define MS_REMOUNT 32 /* alter flags of a mounted FS */
#define MS_MGC_VAL 0xC0ED0000
If the magic number isabsent, then the last two argumentsare not used.
The dat a argument isinterpreted by the different filesystems.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
The following error valuesresult from filesystem type independent errors. Each filesystem type may have itsown special
errorsand itsown special behavior. See the kernel source code for details.
EPERM The user isnot the superuser.
ENODEV f i l esyst emt ype not configured in the kernel.
ENOTBLK speci al f i l e isnot a block device (if a device wasrequired).
EBUSY speci al f i l e isalready mounted. Or it cannot be remounted read-only because it still holds
filesopen for writing. Or, it cannot be mounted on di r because di r isstill busy (it isthe
working directory of some task, the mount point of another device, hasopen files, and so
on).
EINVAL speci al f i l e had an invalid superblock. Or, a remount wasattempted, while speci al f i l e
wasnot already mounted on di r . Or, an umount wasattempted, while di r wasnot a mount
point.
EFAULT One of the pointer argumentspointsoutside the user addressspace.
ENOMEM The kernel could not allocate a free page to copy filenamesor data into.
ENAMETOOLONG A pathname waslonger than MAXPATHLEN.
ENOENT A pathname wasempty or had a nonexistent component.
ENOTDIR The second argument, or a prefix of the first argument, isnot a directory.
EACCES A component of a path wasnot searchable.
Or, mounting a read-only filesystem wasattempted without giving the MS_RDONLY flag.
Or, the block device speci al f i l e islocated on a filesystem mounted with the MS_NODEV
option.
ENXIO The major number of the block device speci al f i l e isout of range.
EMFILE (In case no block device isrequired:) Table of dummy devicesisfull.
mount, umount
Part II: SystemCalls
804
CONFORMS TO
These functionsare rather Linux specific.
SEE ALSO
mount(8), umount(8)
Linux 1.1.67, 28 November 1994
mprotect
mprotectControlsallowable accessesto a region of memory
SYNOPSIS
#include <sys/mman.h>
int mprotect(caddr_t addr , size_t *l en, int pr ot );
DESCRIPTION
mprotect controlshow a section of memory can be accessed. If an accessisdisallowed by the protection given it, the program
receivesa SIGSEGV.
pr ot isa bitwise-OR of the following values:
PROT_NONE The memory cannot be accessed at all.
PROT_READ The memory can be read.
PROT_WRITE The memory can be written to.
PROT_EXEC The memory can contain executing code.
The new protection replacesany existing protection. For example, if the memory had previously been marked PROT_READ, and
mpr ot ect isthen called with pr ot PROT_WRITE, it will no longer be readable.
RETURN VALUE
On success, mprotect returns0. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL addr isnot a valid pointer.
EFAULT The memory cannot be accessed.
EACCES The memory cannot be given the specified access. Thiscan happen, for example, if you
mmap(2) a file to which you have read-only access, then ask mprotect to mark it PROT_WRITE.
ENOMEM Internal kernel structurescould not be allocated.
EXAMPLE
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>
int
main(void)
{
char *p;
char c;
805
/* Allocate a buffer; it will have the default
protection of PROT_READ|PROT_WRITE. */
p = malloc(1024);
if (!p) {
perror(Couldnt malloc(1024));
exit(errno);
}
c = p[666]; /* Read; ok */
p[666] = 42; /* Write; ok */
/* Mark the buffer read-only. */
if (mprotect(p, 1024, PROT_READ)) {
perror(Couldnt mprotect);
exit(errno);
}
c = p[666]; /* Read; ok */
p[666] = 42; /* Write; program dies on SIGSEGV */
exit(0);
}
SEE ALSO
mmap(2)
Linux 1.2, 23 June1995
mremap
mremapRemapsa virtual memory address
SYNOPSIS
#include <unistd.h>
#include <sys/mman.h>
void * mremap(void * ol d_addr ess, size_t ol d_si ze , size_t new_si ze, unsigned long f l ags)
DESCRIPTION
mremap expands(or shrinks) an existing memory mapping, potentially moving it at the same time (controlled by the f l ags
argument and the available virtual addressspace).
ol d_addr ess isthe old addressof the virtual memory block that you want to expand (or shrink). Note that ol d_addr ess hasto
be page aligned. ol d_si ze isthe old size of the virtual memory block. new_si ze isthe requested size of the virtual memory
block after the resize.
The f l ags argument isa bitmap of flags.
In Linux the memory isdivided into pages. A user processhasone or linear virtual memory segments. Each virtual memory
segment hasone or more mappingsto real memory pages(in the page table). Each virtual memory segment hasitsown
protection (accessrights), which may cause a segmentation violation if the memory isaccessed incorrectly (for example,
writing to a read-only segment). Accessing virtual memory outside of the segmentswill also cause a segmentation violation.
mremap usesthe Linux page table scheme. mremap changesthe mapping between virtual addressesand memory pages. Thiscan
be used to implement a very efficient realloc.
mremap
Part II: SystemCalls
806
FLAGS
MREMAP_MAYMOVE Indicateswhether the operation should fail, or changesthe virtual addressif the resize
cannot be done at the current virtual address.
RETURN VALUE
On success, mremap returnsa pointer to the new virtual memory area. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EINVAL An invalid argument wasgiven. Most likely ol d_addr ess wasnot page aligned.
EFAULT Segmentation fault. Some addressin the range ol d_addr ess to ol d_addr ess+ol d_si ze isan
invalid virtual memory addressfor thisprocess. You can also get EFAULT even if there exist
mappingsthat cover the whole addressspace requested, but those mappingsare of different
types.
EAGAIN The memory segment islocked and cannot be remapped.
ENOMEM The memory area cannot be expanded at the current virtual address, and the MREMAP_MAYMOVE
flag isnot set in f l ags. Or there isnot enough (virtual) memory available.
SEE ALSO
getpagesize(2), realloc(3), malloc(3), brk(2), sbrk(2), mmap(2), your favorite OS text book for more information on paged
memory. (Modern OperatingSystemsby Andrew S. Tannenbaum, InsideLinux by Randolf Bentson, TheDesign of theUNIX
OperatingSystemby Maurice J. Bach.)
Linux 1.3.87, 12 April 1996
msgctl
msgctlHandlesmessage control operations
SYNOPSIS
# include <sys/types.h>
# include <sys/ipc.h>
# include <sys/msg.h>
int msgctl ( int msqi d, int cmd , struct msqid_ds * buf );
int cmd, struct msqid_ds *buf;
DESCRIPTION
The function performsthe control operation specified by cmd on the message queue with identifier msqi d. Legal valuesfor cmd
are
IPC_STAT Copiesinfo from the message queue data structure into the structure pointed to by buf . The
user must have read accessprivilegeson the message queue.
IPC_SET Writesthe valuesof some membersof the msqid ds structure pointed to by buf to the
message queue data structure, updating also itsmsg_ctime member. Considered members
from the user-supplied struct msqid ds pointed to by buf are msg_perm.uid, msg_perm.gid,
and msg_perm.mode /* only lowest 9-bits */ msg_qbytes.
The calling processeffective user ID must be one among superuser, creator or owner of the
message queue. Only the superuser can raise the msg_qbytes value beyond the system
parameter MSGMNB.
IPC_RMID Remove immediately the message queue and itsdata structuresawakening all waiting reader
and writer processes(with an error return and errno set to EIDRM). The calling process
effective user ID must be one among superuser, creator or owner of the message queue.
807
RETURN VALUE
If successful, the return value will be 0;otherwise, the return value will be 1 with errno indicating the error.
ERRORS
For a failing return, errno will be set to one of the following values:
EACCESS The argument cmd isequal to IPC_STAT, but the calling processhasno read accesspermis-
sionson the message queue msqi d.
EFAULT The argument cmd hasvalue IPC_SET or IPC_STAT, but the addresspointed to by buf isnt
accessible.
EIDRM The message queue wasremoved.
EINVAL Invalid value for cmd or msqi d.
EPERM The argument cmd hasvalue IPC_SET or IPC_RMID, but the calling processeffective user ID
hasinsufficient privilegesto execute the command. Note that thisisalso the case of a
nonsuperuser processtrying to increase the msg_qbytes value beyond the value specified by
the system parameter MSGMNB.
NOTES
The IPC_INFO, MSG_STAT, and MSG_INFO control callsare used by the ipcs(1) program to provide information on allocated
resources. In the future these can be modified asneeded or moved to a proc file system interface.
SEE ALSO
ipc(5), msgget(2), msgsnd(2), msgrcv(2)
Linux 0.99.13, 1 November 1993
msgget
msggetGetsa message queue identifier
SYNOPSIS
# include <sys/types.h>
# include <sys/ipc.h>
# include <sys/msg.h>
int msgget ( key_t key,int msgf l g );
DESCRIPTION
The function returnsthe message queue identifier associated to the value of the key argument. A new message queue is
created if key hasvalue IPC_PRIVATE or key isnt IPC_PRIVATE, no existing message queue isassociated to key , and IPC_CREAT is
asserted in msgf l g (that is, msgf l g &IPC_CREAT isnt 0). The presence in msgf l g of the fieldsIPC_CREAT and IPC_EXCL playsthe
same role, with respect to the existence of the message queue, asthe presence of O_CREAT and O_EXCL in the mode argument of
the op_en(2) system call: That is, the msgget function failsif msgf l g assertsboth IPC_CREAT and IPC_EXCL and a message queue
already existsfor key .
Upon creation, the lower 9 bitsof the argument msgf l g define the accesspermissions(for owner, group, and others) to the
message queue in the same format, and with the same meaning, asfor the accesspermissionsparameter in the open(2) or
creat(2) system calls(though the execute permissionsare not used by the system).
Furthermore, while creating, the system call initializesthe system message queue data structure msqid ds asfollows:
msg_perm.cuid and msg_perm.uid are set to the effective user ID of the calling process.
msg_perm.cgid and msg_perm.gid are set to the effective group ID of the calling process.
msgget
Part II: SystemCalls
808
The lowest-order 9 bitsof msg_perm.mode are set to the lowest-order 9 bit of msgf l g.
msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime are set to 0.
msg_ctime isset to the current time.
msg_qbytes isset to the system limit MSGMNB.
If the message queue already exists, the accesspermissionsare verified, and a check ismade to see whether it ismarked for
destruction.
RETURN VALUE
If successful, the return value will be the message queue identifier (a positive integer), otherwise 1 with errno indicating the
error.
ERRORS
For a failing return, errno will be set to one of the following values:
EACCES A message queue existsfor key, but the calling processhasno accesspermissionsto the
queue.
EEXIST A message queue existsfor key and msgf l g wasasserting both IPC_CREAT and IPC_EXCL.
EIDRM The message queue ismarked asto be removed.
ENOENT No message queue existsfor key and msgf l g wasnt asserting IPC_CREAT.
ENOMEM A message queue hasto be created but the system hasnot enough memory for the new data
structure.
ENOSPC A message queue hasto be created but the system limit for the maximum number of
message queues(MSGMNI) would be exceeded.
NOTES
IPC_PRIVATE isnt a flag field, but a key_t type. If thisspecial value isused for key, the system call ignoreseverything but the
lowest-order 9 bitsof msgf l g and createsa new message queue (on success).
The following isa system limit on message queue resourcesaffecting a msgget call:
MSGMNI Systemwide maximum number of message queues; policy dependent.
BUGS
Use of IPC_PRIVATE doesnt inhibit other processesthe accessto the allocated message queue.
Asfor the files, there iscurrently no intrinsic way for a processto ensure exclusive accessto a message queue. Asserting both
IPC_CREAT and IPC_EXCL in msgf l g only ensures(on success) that a new message queue will be created; it doesnt imply
exclusive accessto the message queue.
SEE ALSO
ftok(3), ipc(5), msgctl(2), msgsnd(2), msgrcv(2)
Linux 0.99.13, 1 November 1993
msgop
msgopCompletesmessage operations
SYNOPSIS
# include <sys/types.h>
# include <sys/ipc.h>
# include <sys/msg.h>
809
int msgsnd ( int msqi d, struct msgbuf *msgp ,int msgsz,int msgf l g );
int msgrcv ( int msqi d, struct msgbuf *msgp,int msgsz,long msgt yp,int msgf l g );
DESCRIPTION
To send or receive a message, the calling processallocatesa structure that lookslike the following:
struct msgbuf {
long mtype; /* message type, must be > 0 */
char mtext[1]; /* message data */
};
but with an array mtext of size msgsz, a nonnegative integer value. The structure member mtype must have a strictly positive
integer value that can be used by the receiving processfor message selection (see the section about msgrcv).
The calling processmust have write accesspermissionsto send and read accesspermissionsto receive a message on the queue.
The msgsnd system call queuesa copy of the message pointed to by the msgp argument on the message queue whose identifier
isspecified by the value of the msqi d argument.
The argument msgf l g specifiesthe system call behavior if queuing the new message will require more than msg_qbytes in the
queue. Asserting IPC_NOWAIT, the message will not be sent and the system call fails, returning with errno set to EAGAIN.
Otherwise the processissuspended until the condition for the suspension no longer exists(in which case the message issent
and the system call succeeds), or the queue isremoved (in which case the system call failswith errno set to EIDRM), or the
processreceivesa signal that hasto be caught (in which case the system call failswith errno set to EINTR).
Upon successful completion, the message queue data structure isupdated asfollows:
msg_lspid Set to the processD of the calling process.
msg_qnum Incremented by 1.
msg_stime Set to the current time.
The system call msgrcv readsa message from the message queue specified by msqi d into the msgbuf pointed to by the msgp
argument, removing from the queue, on success, the read message.
The argument msgsz specifiesthe maximum size in bytesfor the member mtext of the structure pointed to by the msgp
argument. If the message text haslength greater than msgsz, then if the msgf l g argument assertsMSG_NOERROR, the message text
will be truncated (and the truncated part will be lost); otherwise, the message isnt removed from the queue and the system
call fails, returning with errno set to E2BIG.
The argument msgt yp specifiesthe type of message requested asfollows:
If msgt yp is0, the message on the queuesfront isread.
If msgt yp isgreater than 0, the first message on the queue of type msgt yp isread if MSG_EXCEPT isnt asserted by the msgf l g
argument; otherwise, the first message on the queue of type not equal to msgt yp will be read.
If msgt yp islessthan 0, the first message on the queue with the lowest type lessthan or equal to the absolute value of msgt yp
will be read.
The msgf l g argument assertsnone, one, or more (ORing them) among the following flags:
IPC_NOWAIT For immediate return if no message of the requested type ison the queue. The system call
failswith errno set to ENOMSG.
MSG_EXCEPT Used with msgt yp greater than 0 to read the first message on the queue with message type
that differsfrom msgt yp.
MSG_NOERROR To truncate the message text if longer than msgsz bytes.
msgop
Part II: SystemCalls
810
If no message of the requested type isavailable and IPC_NOWAIT isnt asserted in msgf l g, the calling processisblocked until one
of the following conditionsoccurs:
A message of the desired type isplaced on the queue.
The message queue isremoved from the system. In such a case the system call failswith errno set to EIDRM.
The calling processreceivesa signal that hasto be caught. In such a case the system call failswith errno set to EINTR.
Upon successful completion, the message queue data structure isupdated asfollows:
msg_lrpid Set to the processD of the calling process.
msg_qnum Decremented by 1.
msg_rtime Set to the current time.
RETURN VALUE
On a failure, both functionsreturn 1 with errno indicating the error; otherwise, msgsnd returns0 and msgrvc returnsthe
number of bytesactually copied into the mtext array.
ERRORS
When msgsnd fails, at return errno will be set to one of the following values:
EAGAIN The message cant be sent due to the msg_qbytes limit for the queue, and IPC_NOWAIT was
asserted in mgsf l g.
EACCES The calling processhasno write accesspermissionson the message queue.
EFAULT The addresspointed to by msgp isnt accessible.
EIDRM The message queue wasremoved.
EINTR Sleeping on a full message queue condition, the processreceived a signal that had to be
caught.
EINVAL Invalid msqi d value, or nonpositive mt ype value, or invalid msgsz value (lessthan 0 or greater
than the system value MSGMAX).
ENOMEM The system hasnot enough memory to make a copy of the supplied msgbuf.
When msgrcv fails, at return errno will be set to one of the following values:
E2BIG The message text length isgreater than msgsz and MSG_NOERROR isnt asserted in msgf l g.
EACCES The calling processhasno read accesspermissionson the message queue.
EFAULT The addresspointed to by msgp isnt accessible.
EIDRM While the processwassleeping to receive a message, the message queue wasremoved.
EINTR While the processwassleeping to receive a message, the processreceived a signal that had to
be caught.
EINVAL Illegal msgqi d value, or msgsz lessthan 0.
ENOMSG IPC_NOWAIT wasasserted in msgf l g and no message of the requested type existed on the
message queue.
NOTES
The followingsare system limitsaffecting a msgsnd system call:
MSGMAX Maximum size for a message text; the implementation set thisvalue to 4080 bytes.
MSGMNB Default maximum size in bytesof a message queue: policy dependent. The superuser can
increase the size of a message queue beyond MSGMNB by a msgctl system call.
The implementation hasno intrinsic limitsfor the systemwide maximum number of message headers(MSGTQL) and for the
systemwide maximum size in bytesof the message pool (MSGPOOL).
811
SEE ALSO
ipc(5), msgctl(2), msgget(2), msgrcv(2), msgsnd(2)
Linux 0.99.13, 1 November 1993
msync
msyncSynchronizesa file with a memory map
SYNOPSIS
#include <unistd.h>
#include <sys/mman.h>
#ifdef_POSIX_MAPPED_FILES
#ifdef_POSIX_SYNCHRONIZED_IO
int msync(const void *st ar t , size_t l engt h,int f l ags);
#endif
#endif
DESCRIPTION
msync flusheschangesmade to the in-core copy of a file that wasmapped into memory using mmap(2) back to disk. Without
use of thiscall, there isno guarantee that changesare written back before munmap(2) iscalled. To be more precise, the part of
the file that correspondsto the memory area starting at st ar t and having length l engt h isupdated. The f l ags argument may
have the bitsMS_ASYNC, MS_SYNC, and MS_INVALIDATE set, but not both MS_ASYNC and MS_SYNC. MS_ASYNC specifiesthat an update
be scheduled, but the call returnsimmediately. MS_SYNC asksfor an update and waitsfor it to complete. MS_INVALIDATE asksto
invalidate other mappingsof the same file (so that they can be updated with the fresh valuesjust written).
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EINVAL st ar t isnot a multiple of PAGESIZE, or any bit other than MS_ASYNC | MS_INVALIDATE |
MS_SYNC isset in f l ags.
EFAULT The indicated memory (or part of it) wasnot mapped.
CONFORMS TO
POSIX.4.
SEE ALSO
mmap(2), B.O. Gallmeister, POSIX.4, OReilly, pp. 128129, 389391.
Linux 1.3.86, 12 April 1996
munlock
munlockReenablespaging for some partsof memory
SYNOPSIS
#include <sys/mman.h>
int munlock(const void *addr , size_t l en);
munlock
Part II: SystemCalls
812
DESCRIPTION
munlock reenablespaging for the memory in the range starting at addr with length l en bytes. All pagesthat contain a part of
the specified memory range can after calling munlock be moved to external swap space again by the kernel.
Memory locksdo not stack, that is, pagesthat have been locked several timesby callsto mlock or mlockall will be unlocked
by a single call to munlock for the corresponding range or by munlockall. Pagesthat are mapped to several locationsor by
several processesstay locked into RAM aslong asthey are locked at least at one location or by at least one process.
On POSIX systemson which mlock and munlock are available, _POSIX_MEMLOCK_RANGE isdefined in <unistd.h>
and the value PAGESIZE from <limits.h> indicatesthe number of bytesper page.
RETURN VALUE
On success, munlock returns0. On error, 1 isreturned, errno isset appropriately, and no changesare made to any locksin
the addressspace of the process.
ERRORS
ENOMEM Some of the specified addressrange doesnot correspond to mapped pagesin the address
space of the process.
EINVAL l en wasnot a positive number.
STANDARDS
POSIX.1b, SVR4
SEE ALSO
mlock(2), mlockall(2), munlockall(2).
Linux 1.3.43, 26 November 1995
munlockall
munlockallReenablespaging for calling process
SYNOPSIS
#include <sys/mman.h>
int munlockall(void);
DESCRIPTION
munlockall reenablespaging for all pagesmapped into the addressspace of the calling process.
Memory locksdo not stack, that is, pagesthat have been locked several timesby callsto mlock or mlockall will be unlocked
by a single call to munlockall. Pagesthat are mapped to several locationsor by several processesstay locked into RAM aslong
asthey are locked at least at one location or by at least one process.
On POSIX systemson which mlockall and munlockall are available, _POSIX_MEMLOCK isdefined in <uni st d. h>.
RETURN VALUE
On success, munlockall returns0. On error, 1 isreturned and errno isset appropriately.
STANDARDS
POSIX.1b, SVR4
813
SEE ALSO
mlockall(2), mlock(2), munlock(2)
Linux 1.3.43, 26 November 1995
nanosleep
nanosleepPausesexecution for a specified time
SYNOPSIS
#include <time.h>
int nanosleep(const struct timespec *r eq, struct timespec *r em);
DESCRIPTION
nanosleep delaysthe execution of the program for at least the time specified in * r eq.The function can return earlier if a signal
hasbeen delivered to the process. In thiscase, it returns-1, setserrno to EINTR, and writesthe remaining time into the
structure pointed to by r em unlessr em isNULL. The value of * r em can then be used to call nanosleep again and complete the
specified pause.
The structure t i mespec isused to specify intervalsof time with nanosecond precision. It isspecified in <t i me. h> and hasthe
form
struct timespec
{
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
The value of the nanosecondsfield must be in the range 0 to 999 999 999.
Compared to sleep(3) and usleep(3), nanosleep hasthe advantage of not affecting any signals; it isstandardized by POSIX, it
provideshigher timing resolution, and it allowsto continue a sleep that hasbeen interrupted by a signal more easily.
ERRORS
In case of an error or exception, the nanosleep system call returns-1 instead of 0 and setserrno to one of the following values:
EINTR The pause hasbeen interrupted by a nonblocked signal that wasdelivered to the process.
The remaining sleep time hasbeen written into *r em so that the processcan easily call
nanosleep again and continue with the pause.
EINVAL The value in the t v_nsec field wasnot in the range 0 to 999 999 999 or t v_sec wasnegative.
BUGS
The current implementation of nanosleep isbased on the normal kernel timer mechanism, which hasa resolution of 1/HZ s
(that is, 10mson Linux/i386 and 1mson Linux/Alpha). Therefore, nanosleep pausesalwaysfor at least the specified time;
however, it can take up to 10mslonger than specified until the processbecomesrunnable again. For the same reason, the
value returned in case of a delivered signal in *r em isusually rounded to the next larger multiple of 1/HZ s.
Because some applicationsrequire much more precise pauses(for example, in order to control some time-critical hardware),
nanosleep isalso capable of short high-precision pauses. If the processisscheduled under a real-time policy such as
SCHED_FI FO or SCHED_RR, then pausesof up to 2mswill be performed asbusy waitswith microsecond precision.
STANDARDS
POSIX.1b
nanosleep
Part II: SystemCalls
814
SEE ALSO
sleep(3), usleep(3), sched_setscheduler(2), timer_create(2)
Linux 1.3.85, 10 April 1996
nice
niceChangesprocesspriority
SYNOPSIS
#include <unistd.h>
int nice(int i nc);
DESCRIPTION
nice addsi nc to the priority for the calling PID. Note that only the superuser may specify a negative increment, or priority
increase. Note that internally, a higher number isa higher priority. Do not confuse thiswith the priority scheme asused by
the nice interface.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EPERM A nonsuperuser attemptsto do a priority increase, a numerical decrease, by supplying a
negative i nc.
CONFORMS TO
SVID EXT, AT&T, X/OPEN, BSD 4.3
SEE ALSO
nice(1), setpriority(2), fork(2), renice(8)
Linux, 28 March 1992
oldfstat, oldlstat, oldstat, oldolduname, olduname
oldfstat, oldlstat, oldstat, oldolduname, oldunameObsolete system calls
SYNOPSIS
Obsolete system calls.
DESCRIPTION
The Linux 1.3.6 kernel implementsthese callsto support old executables. These callsreturn structuresthat have grown since
their first implementations, but old executablesmust continue to receive old smaller structures.
Current executablesshould be linked with current librariesand never use these calls.
SEE ALSO
fstat(2), lstat(2), stat(2), uname(2), undocumented(2), unimplemented(2)
Linux 1.3.6, 22 July1995
815
open, creat
open, creatOpen and possibly create a file or device
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pat hname,int f l ags);
int open(const char *pat hname,int f l ags,mode_t mode);
int creat(const char *pat hname,mode_t mode);
DESCRIPTION
open attemptsto open a file and return a file descriptor (a small, nonnegative integer for use in read, write, and so on).
f l ags isone of O_RDONLY, O_WRONLY, or O_RDWR, which request opening the file read-only, write-only, or read/write, respectively.
f l ags may also be bitwise-ORed with one or more of the following:
O_CREAT If the file doesnot exist it will be created.
O_EXCL When used with O_CREAT, if the file already exists, it isan error and the open will fail. Seethe
Bugs section, though.
O_NOCTTY If pat hname refersto a terminal devicesee tty(4) it will not become the processs
controlling terminal even if the processdoesnot have one.
O_TRUNC If the file already exists, it will be truncated.
O_APPEND The file isopened in append mode. Initially, and before each write, the file pointer is
positioned at the end of the file, asif with lseek.
O_NONBLOCK or O_NDELAY The file isopened in nonblocking mode. Neither the open nor any subsequent operationson
the file descriptor that isreturned will cause the calling processto wait.
O_SYNC The file isopened for synchronousI/O. Any writeson the resulting file descriptor will
block the calling processuntil the data hasbeen physically written to the underlying
hardware. Seethe Bugs section, though.
Some of these optional flagscan be altered using fcntl after the file hasbeen opened.
mode specifiesthe permissionsto use if a new file iscreated. It ismodified by the processsumask in the usual way: The
permission of the created file is(mode & umask).
The following symbolic constantsare provided for mode:
S_IRWXU 00700 user (file owner) hasread, write, and execute permission.
S_IRUSR (S_IREAD) 00400 user hasread permission.
S_IWUSR (S_IWRITE) 00200 user haswrite permission.
S_IXUSR (S_IEXEC) 00100 user hasexecute permission.
S_IRWXG 00070 group hasread, write, and execute permission.
S_IRGRP 00040 group hasread permission.
S_IWGRP 00020 group haswrite permission.
S_IXGRP 00010 group hasexecute permission.
S_IRWXO 00007 othershave read, write, and execute permission.
S_IROTH 00004 othershave read permission.
S_IWOTH 00002 othershave write permission.
S_IXOTH 00001 othershave execute permission.
mode should alwaysbe specified when O_CREAT isin the f l ags, and isignored otherwise.
creat isequivalent to open with f l ags equal to O_CREAT|O_WRONLY|O_TRUNC.
open, creat
Part II: SystemCalls
816
RETURN VALUE
open and creat return the new file descriptor, or 1 if an error occurred (in which case errno isset appropriately). Note that
open can open device-special files, but creat cannot create themuse mknod(2) instead.
ERRORS
EEXIST pat hname already existsand O_CREAT and O_EXCL were used.
EISDIR pat hname refersto a directory and the accessrequested involved writing.
ETXTBSY pat hname refersto an executable image which iscurrently being executed and write access
wasrequested.
EFAULT pat hname pointsoutside your accessible addressspace.
EACCES The requested accessto the file isnot allowed, or one of the directoriesin pat hname did not
allow search (execute) permission.
ENAMETOOLONG pat hname wastoo long.
ENOENT A directory component in pat hname doesnot exist or isa dangling symbolic link.
ENOTDIR A component used asa directory in pat hname isnot, in fact, a directory.
EMFILE The processalready hasthe maximum number of filesopen.
ENFILE The limit on the total number of filesopen on the system hasbeen reached.
ENOMEM Insufficient kernel memory wasavailable.
EROFS pat hname refersto a file on a read-only filesystem and write accesswasrequested.
ELOOP pat hname containsa reference to a circular symbolic link, that is, a symbolic link whose
expansion containsa reference to itself.
ENOSPC pat hname wasto be created but the device containing pat hname hasno room for the new file.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
BUGS
O_SYNC isnot currently implemented (asof Linux 0.99pl7).
There are many infelicitiesin the protocol underlying NFS, affecting amongst othersO_SYNC, O_NDELAY, and O_APPEND.
O_EXCL isbroken on NFS filesystems; programsthat rely on it for performing locking taskswill contain a race condition. The
solution for performing atomic file locking using a lockfile isto create a unique file on the same fs (for example, incorporat-
ing hostname and PID), use link(2) to make a link to the lockfile, and use stat(2) on the unique file to check if itslink
count hasincreased to 2. Do not use the return value of the link() call.
SEE ALSO
read(2), write(2), fcntl(2), close(2), unlink(2), mknod(2), stat(2), umask(2), mount(2), socket(2), socket(2), fopen(3), link(2)
Linux 0.99.7, 21 July1993
outb, outw, outl, outsb, outsw, outsl
outb, outw, outl, outsb, outsw, outslPort output
inb, inw, inl, insb, insw, inslPort input
outb_p, outw_p, outl_p, inb_p, inw_p, inl_pPause I/O
DESCRIPTION
Thisfamily of functionsisused to do low-level port input and output. They are primarily designed for internal kernel use,
but can be used from user space, given the following information in addition to that given in outb(9).
817
You compile with O or O2 or something similar. The functionsare defined asinline macrosand will not be substituted in
without optimization enabled, causing unresolved referencesat link time.
You use ioperm(2) or alternatively iopl(2) to tell the kernel to allow the user space application to accessthe I/O portsin
question. Failure to do thiswill cause the application to receive a segmentation fault.
CONFORMS TO
outb and friendsare hardware specific. The por t and val ue argumentsare in the opposite order from most DOSimplementa-
tions.
SEE ALSO
outb(9), ioperm(2), iopl(2)
Linux, 29 November 1995
pause
pauseWaitsfor signal
SYNOPSIS
#include <unistd.h>
int pause(void);
DESCRIPTION
The pause system call causesthe invoking processto sleep until a signal isreceived.
RETURN VALUE
pause alwaysreturns1, and errno isset to ERESTARTNOHAND.
ERRORS
EINTR Signal wasreceived.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
kill(2), select(2), signal(2)
Linux, 31 August 1995
personality
personalitySetsthe processexecution domain
SYNOPSIS
int personality(unsigned long per sona);
DESCRIPTION
Linux supportsdifferent execution domains, or personalities, for each process. Among other things, execution domainstell
Linux how to map signal numbersinto signal actions. The execution domain system allowsLinux to provide limited support
for binariescompiled under other UNIX-like operating systems.
personality will make the execution domain referenced by per sona the new execution domain of the current process.
personality
Part II: SystemCalls
818
RETURN VALUE
On success, per sona ismade the new execution domain and the previousper sona isreturned. On error, 1 isreturned and
errno isset appropriately.
ERRORS
EINVAL per sona doesnot refer to a valid execution domain.
FILE
/usr/include/linux/personality.h
CONFORMS TO
personality isLinux specific.
Linux 2.0, 22 July1996
phys
physAllowsa processto accessphysical addresses(thiscommand isnot implemented)
SYNOPSIS
int phys(int physnum, char *virtaddr,longsize, char *physaddr);
DESCRIPTION
Warning: Because thisfunction isnot implemented asof Linux 0.99.11, it will alwaysreturn 1 and set errno to ENOSYS.
phys mapsarbitrary physical memory into a processsvirtual addressspace. physnum isa number (03) that specifieswhich of
the four physical spacesto set up. Up to four phys callscan be active at any one time. virtaddr isthe processsvirtual address.
size isthe number of bytesto map in. physaddr isthe physical addressto map in.
Valid virtaddr and physaddr valuesare constrained by hardware and must be at an addressmultiple of the resolution of the
CPUsmemory management scheme. If size isnonzero, size isrounded up to the next MMU resolution boundary. If size is
0, any previousphys(2) mapping for that physnum isnullified.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
CONFORMS TO
version 7 AT&T UNIX
BUGS
phys isvery machine dependent.
SEE ALSO
mmap(2), munmap(2)
Linux 0.99.11, 24 July1993
pipe
pipeCreatesa pipe
819
SYNOPSIS
#include <unistd.h>
int pipe(int filedes[2]);
DESCRIPTION
pipe createsa pair of file descriptors, pointing to a pipe inode, and placesthem in the array pointed to by filedes. filedes[0]
isfor reading, filedes[1] isfor writing.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EMFILE Too many file descriptorsare in use by the process.
ENFILE The system file table isfull.
EFAULT filedes isnot valid.
SEE ALSO
read(2), write(2), fork(2), socketpair(2)
Linux 0.99.11, 23 July1993
profil
profilExecution time profile
SYNOPSIS
#include <unistd.h>
int profil(char *buf, int buf si z ,int of f set ,int scal e);
DESCRIPTION
Under Linux 0.99.11, profil isnot implemented in the kernel. Instead, the DLL 4.4.1 librariesprovide a user-space
implementation.
buf pointsto buf si z bytesof core. Every virtual 10 milliseconds, the usersprogram counter (PC) isexamined: of f set is
subtracted and the result ismultiplied by scal e. If thisaddressisin buf, the word pointed to isincremented.
If scal e islessthan 2 or buf si z is0, profiling isdisabled.
RETURN VALUE
0 isalwaysreturned.
BUGS
profil cannot be used on a program that also usesITIMER_PROF itimers.
Calling profil with an invalid buf will result in a core dump.
True kernel profiling providesmore accurate results.
SEE ALSO
gprof(1), setitimer(2), signal(2), sigaction(2)
Linux 0.99.11, 23 July1993
profil
Part II: SystemCalls
820
ptrace
ptraceProcesstrace
SYNOPSIS
#include <sys/ptrace.h>
int ptrace(int r equest ,int pi d,int addr ,int dat a);
DESCRIPTION
ptrace providesa meansby which a parent processcan control the execution of a child processand examine and change its
core image. Itsprimary use isfor the implementation of breakpoint debugging. A traced processrunsuntil a signal occurs.
Then it stopsand the parent isnotified with wait(2). When the processisin the stopped state, itsmemory can be read and
written. The parent can also cause the child to continue execution, optionally ignoring the signal which caused stopping.
The value of the request argument determinesthe precise action of the system call:
PTRACE_TRACEME Thisprocessisto be traced by itsparent. The parent should be expecting to trace the child.
PTRACE_PEEKTEXT, Read word at location addr .
PTRACE_PEEKDATA
PTRACE_PEEKUSR Read word at location addr in the USER area.
PTRACE_POKETEXT, Write word at location addr .
PTRACE_POKEDATA
PTRACE_POKEUSR Write word at location addr in the USER area.
PTRACE_SYSCALL, Restart after signal.
PTRACE_CONT
PTRACE_KILL Send the child a SIGKILL to make it exit.
PTRACE_SINGLESTEP Set the trap flag for single stepping.
PTRACE_ATTACH Attach to the processspecified in pi d.
PTRACE_DETACH Detach a processthat waspreviously attached.
NOTES
init, the processwith processID 1, may not use thisfunction.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EPERM The specified process(that is, init), cannot be traced or isalready being traced.
ESRCH The specified processdoesnot exist.
EIO Request isnot valid.
CONFORMS TO
SVID EXT, AT&T, X/OPEN, BSD 4.3
SEE ALSO
gdb(1), exec(2), signal(2), wait(2)
Linux 0.99.11, 23 July1993
821
quotactl
quotactlManipulatesdisk quotas
SYNOPSIS
#include <sys/types.h>
#include <sys/quota.h>
int quotactl (int cmd, const char *speci al , intid , caddr_t addr );
#include <linux/unistd.h>
syscall4(int, quotactl, int, cmd, const char *, speci al ,int, i d, caddr_t, addr );
DESCRIPTION
The quota system definesfor each user or group a soft limit and a hard limit bounding the amount of disk space that can be
used on a given filesystem. The hard limit cannot be crossed. The soft limit can be crossed, but warningswill ensue.
Moreover, the user cannot be above the soft limit for more than one week (by default) at a time: After thisweek the soft limit
countsasa hard limit.
The quotactl system call manipulatesthese quotas. Itsfirst argument isof the form
QCMD(subcmd,type)
where type iseither USRQUOTA or GRPQUOTA (for user quota and group quota, respectively.
The second argument special isthe block special device these quotasapply to. It must be mounted.
The third argument ID isthe user or group ID these quotasapply to (when relevant).
The fourth argument, addr , isthe addressof a data structure, depending on the command.
The subcmd isone of the following:
Q_QUOTAON Enablesquotas. The addr argument isthe pathname of the file containing the quotasfor the filesystem.
Q_QUOTAOFF Disablesquotas.
Q_GETQUOTA Getslimitsand current usage of disk space. The addr argument isa pointer to a dqblk structure
(defined in <sys/quota.h>).
Q_SETQUOTA Setslimitsand current usage; addr isasbefore.
Q_SETQLIM Setslimits; addr isasbefore.
Q_SETUSE Setsusage.
Q_SYNC Syncsdisk copy of a filesystemsquotas.
Q_GETSTATS Getscollected stats.
RETURN VALUE
On success, quotactl returns0. On error, 1 isreturned and errno isset appropriately.
ERRORS
ENOPKG The kernel wascompiled without quota support.
EFAULT Bad addr value.
EINVAL t ype isnot a known quota type. Or special could not be found.
ENOTBLK speci al isnot a block special device.
ENODEV speci al cannot be found in the mount table.
EACCES The quota file isnot an ordinary file.
EIO Cannot read or write the quota file.
EMFILE Too many open files: Cannot open quota file.
quotactl
Part II: SystemCalls
822
EBUSY Q_QUOTAON wasasked, but quota were enabled already.
ESRCH Q_GETQUOTA or Q_SETQUOTA or Q_SETUSE or Q_SETQLIM wasasked for a filesystem that didnt have quota
enabled.
EPERM The processwasnot root (for the filesystem), and Q_GETQUOTA wasasked for another ID than that of the
processitself, or anything other than Q_GETSTATS or Q_SYNC wasasked.
CONFORMS TO
BSD
Linux 1.3.88, 14 April 1996
read
readReadsfrom a file descriptor
SYNOPSIS
#include <unistd.h>
ssize_t read(int f d,void*buf , size_t count );
DESCRIPTION
read() attemptsto read up to count bytesfrom file descriptor fd into the buffer starting at buf.
If count is0, read() returns0 and hasno other results. If count isgreater than SSIZE_MAX, the result isunspecified.
RETURN VALUE
On success, the number of bytesread isreturned (0 indicatesend of file) and the file position isadvanced by thisnumber. It
isnot an error if thisnumber issmaller than the number of bytesrequested; thismay happen, for example, because fewer
bytesare actually available right now (maybe because we were close to end-of-file or because we are reading from a pipe, or
from a terminal), or because read() wasinterrupted by a signal. On error, 1 isreturned and errno isset appropriately. In this
case it isleft unspecified whether the file position (if any) changes.
ERRORS
EINTR The call wasinterrupted by a signal before any data wasread.
EAGAIN Non-blocking I/O hasbeen selected using O_NONBLOCK and no data wasimmediately available for
reading.
EIO I/O error. Thiswill happen, for example, when the processisin a background processgroup, triesto
read from itscontrolling tty, and it isignoring or blocking SIGTTIN or itsprocessgroup isorphaned.
EISDIR fd refersto a directory.
EBADF fd isnot a valid file descriptor or isnot open for reading.
EINVAL fd isattached to an object that isunsuitable for reading.
EFAULT buf isoutside your accessible addressspace.
Other errorsmay occur, depending on the object connected to fd. POSIX allowsa read that isinterrupted after reading some
data to return 1 (with errno set to EINTR) or to return the number of bytesalready read.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
readdir(2), write(2), write(2), fcntl(2), close(2), lseek(2), select(2), readlink(2), ioctl(2), fread(3)
Linux, 17 January1996
823
readdir
readdirReadsdirectory entry
SYNOPSIS
#include <unistd.h>
#include <linux/dirent.h>
#include <linux/unistd.h>
syscall3(int, readdir, uint, fd, struct dirent *, dirp, uint, count);
int readdir(unsigned int f d, struct dirent *di r p, unsigned int count );
DESCRIPTION
Thisisnot the function you are interested in. Look at readdir(3) for the POSIX-conforming C library interface. Thispage
documentsthe bare kernel system call interface, which can change, and which issuperseded by getdents(2).
readdir readsone dirent structure from the directory pointed at by fd into the memory area pointed to by di r p. The
parameter count isignored; at most one dirent structure isread.
The dirent structure isdeclared asfollows:
struct dirent
{
long d_ino; /* inode number */
off_t d_off; /* offset to this dirent */
unsigned short d_reclen; /* length of this d_name */
char d_name [NAME_MAX+1]; /* file name (null-terminated) */
}
d_i no isan inode number. d_of f isthe distance from the start of the directory to thisdirent. d_r ecl en isthe size of d_name, not
counting the null terminator. d_name isa null-terminated filename.
RETURN VALUE
On success, 1 isreturned. On end of directory, 0 isreturned. On error, 1 isreturned and errno isset appropriately.
ERRORS
EBADF Invalid file descriptor fd.
ENOTDIR File descriptor doesnot refer to a directory.
CONFORMS TO
Thissystem call isLinux specific.
SEE ALSO
getdents(2), readdir(3)
Linux 1.3.6, 22 July1995
readlink
readlinkReadsvalue of a symbolic link
SYNOPSIS
#include <unistd.h>
int readlink(const char *pat h, char *buf , size_t buf si z);
readlink
Part II: SystemCalls
824
DESCRIPTION
readlink placesthe contentsof the symbolic link path in the buffer buf , which hassize buf si z. Readlink doesnot append a
NUL character to buf .
RETURN VALUES
The call returnsthe count of charactersplaced in the buffer if it succeeds, or a 1 if an error occurs, placing the error code in
the global variable errno.
ERRORS
ENOTDIR A component of the path prefix isnot a directory.
EINVAL The pathname containsa character with the high-order bit set.
ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023
characters.
ENOENT The named file doesnot exist.
EACCES Search permission isdenied for a component of the path prefix.
ELOOP Too many symbolic linkswere encountered in translating the pathname.
EINVAL The named file isnot a symbolic link.
EIO An I/O error occurred while reading from the filesystem.
EFAULT buf extendsoutside the processsallocated addressspace.
HISTORY
The readlink function call appeared in BSD 4.2.
SEE ALSO
stat(2), lstat(2), symlink(2)
BSD Man Page, 24 July1993
readv, writev
readv, writevReadsor writesa vector
SYNOPSIS
#include <sys/uio.h>
int readv(int f d, const struct iovec * vect or , size_t count );
int writev(int f d, const struct iovec * vect or , size_t count );
struct iovec {
ptr_t i ov_base; /* Starting address. */
size_t i ov_l en; /* Length in bytes. */
};
DESCRIPTION
readv readsdata from file descriptor f d and putsthe result in the buffersdescribed by vect or . The number of buffersis
specified by count . The buffersare filled in the order specified. Operatesjust like read except that data isput in vector
instead of a contiguousbuffer.
writev writesdata to file descriptor f d, and from the buffersdescribed by vector. The number of buffersisspecified by count .
The buffersare used in the order specified. Operatesjust like write except that data istaken from vect or instead of a
contiguousbuffer.
825
RETURN VALUE
On success, readv returnsthe number of bytesread. On success, writev returnsthe number of byteswritten. On error, 1 is
returned, and errno isset appropriately.
ERRORS
EINVAL An invalid argument wasgiven. For instance count might be greater than MAX_IOVEC, or 0. f d could
also be attached to an object that isunsuitable for reading.
EFAULT Segmentation fault. Most likely vect or or some of the i ov_base pointerspointsto memory that is
not properly allocated.
EBADF The file descriptor f d isnot valid.
EINTR The call wasinterrupted by a signal before any data wasread/written.
EAGAIN Non-blocking I/O hasbeen selected using O_NONBLOCK and no data wasimmediately available for
reading. (Or the file descriptor fd isfor an object that islocked.)
EISDIR f d refersto a directory.
EOPNOTSUP f d refersto a socket or device that doesnot support reading/writing.
Other errorsmay occur, depending on the object connected to f d.
SEE ALSO
read(2), write(2), fprintf(3), fscanf(2)
Linux 1.3.86, 12 April 1996
reboot
rebootRebootsor disablesCtrl+Alt+Del
SYNOPSIS
#include <unistd.h>
int reboot (int magi c ,int magi c_t oo,int f l ag);
DESCRIPTION
reboot rebootsthe system or enables/disablesCAD.
If magic = 0xfee1dead and magic_too = 672274793, the action performed will be based on f l ag.
If flag=0x1234567, a hard reset isperformed.
If flag=0x89abcdef, CAD isenabled.
If flag=0, CAD isdisabled and a signal issent to processID 1.
Note that reboot() doesnot sync()!
Only the superuser may use thisfunction.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and er r no isset appropriately.
ERRORS
EINVAL Bad magi c numbersor f l ag.
EPERM A non-root user hasattempted to call reboot.
readv, writev
Part II: SystemCalls
826
CONFORMS TO
reboot isLinux specific.
SEE ALSO
sync(2), ctrlaltdel(8), halt(8), reboot(8)
Linux 0.99.10, 28 March 1992
recv, recvfrom, recvmsg
recv, recvfrom, recvmsgReceivesa message from a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int recv(int s, void *buf , intl en, unsigned int f l ags);
int recvfrom(int s, void*buf , int l en, unsigned int f l ags,
struct sockaddr *f r om, int *f r oml en);
int recvmsg(int s, struct msghdr *msg, unsigned int f l ags );
DESCRIPTION
Warning: Thisisa BSD man page. Asof Linux 0.99.11, recvmsg wasnot implemented.
recvfrom and recvmsg are used to receive messagesfrom a socket, and may be used to receive data on a socket whether or not
it isconnection oriented.
If f r om isnon-nil, and the socket isnot connection-oriented, the source addressof the message isfilled in. f r oml en isa value-
result parameter, initialized to the size of the buffer associated with f r om and modified on return to indicate the actual size of
the addressstored there.
The recv call isnormally used only on a connected socket (see connect(2)) and isidentical to recvfrom with a nil from
parameter. Because it isredundant, it might not be supported in future releases.
All three routinesreturn the length of the message on successful completion. If a message istoo long to fit in the supplied
buffer, excessbytesmight be discarded depending on the type of socket from which the message isreceived (see socket(2)).
If no messagesare available at the socket, the receive call waitsfor a message to arriveunlessthe socket isnonblocking (see
fcntl(2)), in which case the value 1 isreturned and the external variable errno isset to EWOULDBLOCK. The receive calls
normally return any data available, up to the requested amount, rather than wait for receipt of the full amount requested;
thisbehavior isaffected by the socket-level optionsSO_RCVLOWAT and SO_RCVTIMEO, described in getsockopt(2).
The select(2) call may be used to determine when more data arrives.
The f l ags argument to a recv call isformed by oring one or more of the values:
MSG_OOB Processout-of-band data
MSG_PEEK Peek at incoming message
MSG_WAITALL Wait for full request or error
The MSG_OOB flag requestsreceipt of out-of-band data that would not be received in the normal data stream. Some protocols
place expedited data at the head of the normal data queue; thusthisflag cannot be used with such protocols. The MSG_PEEK
flag causesthe receive operation to return data from the beginning of the receive queue without removing that data from the
queue; thus, a subsequent receive call will return the same data. The MSG_WAITALL flag requeststhat the operation block until
the full request issatisfied. However, the call might still return lessdata than requested if a signal iscaught, an error or
disconnect occurs, or the next data to be received isof a different type than that returned.
827
The recvmsg call usesa msghdr structure to minimize the number of directly supplied parameters. Thisstructure hasthe
following form, asdefined in sys/socket.h:
struct msghdr {
caddr_t msg_name; /* optional address */
u_int msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter/gather array */
u_int msg_iovlen; /* # elements in msg_iov */
caddr_t msg_control; /* ancillary data, see below */
u_int msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
};
Here msg_name and msg_namelen specify the destination addressif the socket isunconnected; msg_name may be given asa null
pointer if no namesare desired or required. msg_iov and msg_iovlen describe scatter gather locations, asdiscussed in read(2).
msg_control, which haslength msg_controllen, pointsto a buffer for other protocol controlrelated messagesor other
miscellaneousancillary data. The messagesare of the form
struct cmsghdr {
u_int cmsg_len; /* data byte count, including hdr */
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
/* followed by
u_char cmsg_data[]; */
};
You could use this, for example, to learn of changesin the data stream in XNS/SPP, or in ISO, to obtain user-
connection-request data by requesting a recvmsg with no data buffer provided immediately after an accept call.
Open file descriptorsare now passed asancillary data for AF_UNIX domain sockets, with cmsg_level set to SOL_SOCKET and
cmsg_type set to SCM_RIGHTS.
The msg_flags field isset on return according to the message received. MSG_EOR indicatesend-of-record; the data returned
completed a record (generally used with socketsof type SOCK_SEQPACKET). MSG_TRUNC indicatesthat the trailing portion of a
datagram wasdiscarded because the datagram waslarger than the buffer supplied. MSG_CTRUNC indicatesthat some control
data wasdiscarded due to lack of space in the buffer for ancillary data. MSG_OOB isreturned to indicate that expedited or out-
of-band data wasreceived.
RETURN VALUES
These callsreturn the number of bytesreceived, or 1 if an error occurred.
ERRORS
EBADF The argument s isan invalid descriptor.
ENOTCONN The socket isassociated with a connection-oriented protocol and hasnot been connected (see
connect(2) and accept(2)).
ENOTSOCK The argument s doesnot refer to a socket.
EWOULDBLOCK The socket ismarked non-blocking, and the receive operation would block, or a receive timeout
had been set, and the timeout expired before data wasreceived.
EINTR The receive wasinterrupted by delivery of a signal before any data wasavailable.
EFAULT The receive buffer pointer(s) point outside the processsaddressspace.
HISTORY
These function callsappeared in BSD 4.2.
recv, recvfrom, recvmsg
Part II: SystemCalls
828
SEE ALSO
fcntl(2), read(2), select(2), getsockopt(2), socket(2)
BSD Man Page, 24 July1993
rename
renameChangesthe name or location of a file
SYNOPSIS
#include <unistd.h>
int rename(const char *ol dpat h, const char *newpat h);
DESCRIPTION
rename renamesa file, moving it between directoriesif required.
Any other hard linksto the file (ascreated using link) are unaffected.
If newpat h already existsit will be automatically overwritten (subject to a few conditionssee the Errors section), so that
there isno point at which another processattempting to accessnewpat h will find it missing.
If newpat h existsbut the operation failsfor some reason or the system crashes, rename guaranteesto leave an instance of
newpat h in place.
However, when overwriting there will probably be a window in which both ol dpat h and newpat h refer to the file being
renamed.
If ol dpat h refersto a symbolic link, the link will be renamed; if newpat h refersto a symbolic link, the link will be overwritten.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EISDIR newpat h isan existing directory, but ol dpat h isnot a directory.
EXDEV ol dpat h and newpat h are not on the same filesystem.
ENOTEMPTY newpat h isa non-empty directory.
EBUSY newpat h existsand isthe current working directory or root directory of some process.
EINVAL An attempt wasmade to make a directory a subdirectory of itself.
EMLINK ol dpat h already hasthe maximum number of linksto it, or it wasa directory and the directory
containing newpat h hasthe maximum number of links.
ENOTDIR A component used asa directory in ol dpat h or newpat h isnot, in fact, a directory.
EFAULT ol dpat h or newpat h pointsoutside your accessible addressspace.
EACCES Write accessto the directory containing ol dpat h or newpat h isnot allowed for the processseffective
UID, or one of the directoriesin ol dpat h or newpat h did not allow search (execute) permission, or
ol dpat h wasa directory and did not allow write permission (needed to update the .. entry).
EPERM The directory containing ol dpat h hasthe sticky bit set, and the processseffective UID isneither the
UID of the file to be deleted nor that of the directory containing it, or the filesystem containing
pat hname doesnot support renaming of the type requested.
ENAMETOOLONG ol dpat h or newpat h wastoo long.
ENOENT A directory component in ol dpat h or newpat h doesnot exist or isa dangling symbolic link.
ENOMEM Insufficient kernel memory wasavailable.
EROFS The file ison a read-only filesystem.
829
ELOOP ol dpat h or newpat h containsa reference to a circular symbolic link; that is, a symbolic link whose
expansion containsa reference to itself.
ENOSPC The device containing the file hasno room for the new directory entry.
CONFORMS TO
POSIX, BSD 4.3, ANSI C
BUGS
Currently (Linux 0.99pl7), most of the filesystemsexcept Minix will not allow any overwriting renamesinvolving directories.
You get EEXIST if you try.
On NFS filesystems, you cannot assume that just because the operation failed, the file wasnot renamed. If the server does
the rename operation and then crashes, the retransmitted RPC, which will be processed when the server isup again, causesa
failure. The application isexpected to deal with this. See link(2) for a similar problem.
SEE ALSO
link(2), unlink(2), symlink(2), mv(1), link(8)
Linux 0.99.7, 24 July1993
rmdir
rmdirDeletesa directory
SYNOPSIS
#include <unistd.h>
int rmdir(const char *pat hname);
DESCRIPTION
rmdir deletesa directory, which must be empty.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM The filesystem containing pat hname doesnot support the removal of directories.
EFAULT pat hname pointsoutside your accessible addressspace.
EACCES Write accessto the directory containing pat hname wasnot allowed for the processseffective UID,
or one of the directoriesin pat hname did not allow search (execute) permission.
EPERM The directory containing pat hname hasthe sticky bit (S_ISVTX) set, and the processseffective UID is
neither the UID of the file to be deleted nor that of the directory containing it.
ENAMETOOLONG pat hname wastoo long.
ENOENT A directory component in pat hname doesnot exist or isa dangling symbolic link.
ENOTDIR pat hname, or a component used asa directory in pat hname, isnot, in fact, a directory.
ENOTEMPTY pat hname containsentriesother than . and ...
EBUSY pat hname isthe current working directory or root directory of some process.
ENOMEM Insufficient kernel memory wasavailable.
EROFS pat hname refersto a file on a read-only filesystem.
ELOOP pat hname containsa reference to a circular symbolic link; that is, a symbolic link containing a
reference to itself.
rmdir
Part II: SystemCalls
830
CONFORMS TO
SVID, AT&T, POSIX, BSD 4.3
BUGS
Infelicitiesin the protocol underlying NFS can cause the unexpected disappearance of directoriesthat are still being used.
SEE ALSO
rename(2), mkdir(2), chdir(2), unlink(2), rmdir(1), rm(1)
Linux 0.99.7, 24 July1993
sched_get_priority_max, sched_get_priority_min
sched_get_priority_max, sched_get_priority_minGetsstatic priority range
SYNOPSIS
#include <sched.h>
int sched_get_priority_max(int pol i cy);
int_sched_get_priority_min(int pol i cy);
DESCRIPTION
sched_get_priority_max returnsthe maximum priority value that can be used with the scheduling algorithm identified by
pol i cy. sched_get_priority_min returnsthe minimum priority value that can be used with the scheduling algorithm
identified by pol i cy. Supported pol i cy valuesare SCHED_FIFO, SCHED_RR, and SCHED_OTHER.
Processeswith numerically higher priority valuesare scheduled before processeswith numerically lower priority values.
Therefore, the value returned by sched_get_priority_max will be greater than the value returned by sched_get_priority_min.
Linux allowsthe static priority value range 1 to 99 for SCHED_FIFO and SCHED_RR, and the priority 0 for SCHED_OTHER.
Scheduling priority rangesfor the variouspoliciesare not alterable.
The range of scheduling prioritiesmay vary on other POSIX systems, so it isa good idea for portable applicationsto use a
virtual priority range and map it to the interval given by sched_get_priority_max and sched_get_priority_min. POSIX.1b
requiresa spread of at least 32 between the maximum and the minimum valuesfor SCHED_FIFO and SCHED_RR.
POSIX systemson which sched_get_priority_max and sched_get_priority_min are available define
_POSIX_PRIORITY_SCHEDULING in <unistd.h>.
RETURN VALUE
On success, sched_get_priority_max and sched_get_priority_min return the maximum and minimum priority valuesfor the
named scheduling policy. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EINVAL The parameter policy doesnot identify a defined scheduling policy.
STANDARDS
POSIX.1b (formerly POSIX.4)
SEE ALSO
sched_setscheduler(2), sched_getscheduler(2), sched_setparam(2), sched_getparam(2)
sched_setscheduler(2) hasa description of the Linux scheduling scheme.
831
Programmingfor theReal WorldPOSIX.4 by Bill O. Gallmeister, OReilly & Associates, Inc., ISBN 1-56592-074-0
IEEE Std 1003.1b-1003 (POSIX.1b standard)
ISO/IEC 9945-1:1996
Linux 1.3.81, 10 April 1996
sched_rr_get_interval
sched_rr_get_intervalGetsthe SCHED_RR interval for the named process
SYNOPSIS
#include <sched.h>
int sched_rr_get_interval(pid_t pi d, struct timespec *t p);
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
DESCRIPTION
sched_rr_get_interval writesinto the t i mespec structure pointed to by t p the round-robin time quantum for the process
identified by pi d. If pi d is0, the time quantum for the calling processiswritten into *t p. The identified processshould be
running under the SCHED_RR scheduling policy.
The round robin time quantum value isnot alterable under Linux 1.3.81.
POSIX systemson which sched_rr_get_interval isavailable define _POSIX_PRIORITY_SCHEDULING in <unistd.h>.
RETURN VALUE
On success, sched_rr_get_interval returns0. On error, 1 isreturned, and errno isset appropriately.
ERRORS
ESRCH The processwhose ID ispi d could not be found.
ENOSYS The system call isnot yet implemented.
STANDARDS
POSIX.1b (formerly POSIX.4)
BUGS
Asof Linux 1.3.81, sched_rr_get_interval returnswith error ENOSYS, because SCHED_RR hasnot yet been fully implemented or
tested properly.
SEE ALSO
sched_setscheduler(2) hasa description of the Linux scheduling scheme.
Programmingfor theReal WorldPOSIX.4 by Bill O. Gallmeister, OReilly & Associates, Inc., ISBN 1-56592-074-0
IEEE Std 1003.1b-1993 (POSIX.1b standard)
ISO/IEC 9945-1:1996
Linux 1.3.81, 10 April 1996
sched_rr_get_interval
Part II: SystemCalls
832
sched_setparam, sched_getparam
sched_setparam, sched_getparamSetsand get scheduling parameters
SYNOPSIS
#include <sched.h>
int sched_setparam(pid_t pi d, const struct sched_param *p);
int sched_getparam(pid_t pi d, struct sched_param *p);
struct sched_param {
...
int sched_pr i or i t y;
...
};
DESCRIPTION
sched_setparam setsthe scheduling parametersassociated with the scheduling policy for the processidentified by pi d. If pi d is
0, the parametersof the current processare set. The interpretation of the parameter p dependson the selected policy.
Currently, the following three scheduling policiesare supported under Linux: SCHED_FIFO, SCHED_RR, and SCHED_OTHER.
sched_getparam retrievesthe scheduling parametersfor the processidentified by pi d. If pi d is0, the parametersof the current
processare retrieved.
sched_setparam checksthe validity of p for the scheduling policy of the process. The parameter p->sched_priority must lie
within the range given by sched_get_priority_min and sched_get_priority_max.
POSIX systemson which sched_setparam and sched_getparam are available define _POSIX_PRIORITY_SCHEDULING in <unistd.h>.
RETURN VALUE
On success, sched_setparam and sched_getparam return 0. On error, 1 isreturned, and errno isset appropriately.
ERRORS
ESRCH The processwhose ID ispi d could not be found.
EPERM The calling processdoesnot have appropriate privileges. The processcalling sched_setparam needs
an effective UID equal to the UID or UID of the processidentified by pi d, or it must be a
superuser process.
EINVAL The parameter p doesnot make sense for the current scheduling policy.
STANDARDS
POSIX.1b (formerly POSIX.4)
SEE ALSO
sched_setscheduler(2), sched_getscheduler(2), sched_get_priority_max(2), sched_get_priority_min(2), nice(2),
setpriority(2), getpriority(2)
sched_setscheduler(2) hasa description of the Linux scheduling scheme.
Programmingfor theReal WorldPOSIX.4 by Bill O. Gallmeister, OReilly & Associates, Inc., ISBN 1-56592-074-0
IEEE Std 1003.1b-1993 (POSIX.1b standard)
ISO/IEC 9945-1:1996
Linux 1.3.81, 10 April 1996
833
sched_setscheduler, sched_getscheduler
sched_setscheduler, sched_getschedulerSetsand getsscheduling algorithm/parameters
SYNOPSIS
#include <sched.h>
int sched_setscheduler(pid_t pi d,intpol i cy, const struct sched_param *p);
int sched_getscheduler(pid_t pi d);
struct sched_param {
...
int sched_pr i or i t y;
...
};
DESCRIPTION
sched_setscheduler setsboth the scheduling policy and the associated parametersfor the processidentified by pi d. If pi d is0,
the scheduler of the calling processwill be set. The interpretation of the parameter p dependson the selected policy.
Currently, the following three scheduling policiesare supported under Linux: SCHED_FIFO, SCHED_RR, and SCHED_OTHER; their
respective semanticsare described in the following section.
sched_getscheduler queriesthe scheduling policy currently applied to the processidentified by pi d. If pi d is0, the policy of
the calling processwill be retrieved.
SCHEDULING POLICIES
The scheduler isthe kernel part that decideswhich runnable processwill be executed next by the CPU. The Linux scheduler
offersthree different scheduling policies, one for normal processesand two for real-time applications. A static priority value,
sched_pr i or i t y, isassigned to each process, and thisvalue can be changed only via system calls. Conceptually, the scheduler
maintainsa list of runnable processesfor each possible sched_pr i or i t y value, and sched_pr i or i t y can have a value in the
range 0 to 99. To determine the processthat runsnext, the Linux scheduler looksfor the non-empty list with the highest
static priority and takesthe processat the head of thislist. The scheduling policy determines, for each process, where it will
be inserted into the list of processeswith equal static priority and how it will move inside thislist.
SCHED_OTHER isthe default universal time-sharing scheduler policy used by most processes; SCHED_FIFO and SCHED_RR are
intended for special, time-critical applicationsthat need precise control over the way in which runnable processesare selected
for execution. Processesscheduled with SCHED_OTHER must be assigned the static priority 0; processesscheduled under
SCHED_FIFO or SCHED_RR can have a static priority in the range 1 to 99. Only processeswith superuser privilegescan get a static
priority higher than 0 and can therefore be scheduled under SCHED_FIFO or SCHED_RR. The system callssched_get_priority_min
and sched_get_priority_max can be used to find out the valid priority range for a scheduling policy in a portable way on all
POSIX.1b-conforming systems.
All scheduling ispreemptive: If a processwith a higher static priority getsready to run, the current processwill be preempted
and returned into itswait list. The scheduling policy determinesthe ordering within the list of runnable processesonly
among those with equal static priority.
SCHED_FIFO: FIRST INFIRST OUT SCHEDULING
SCHED_FIFO can only be used with static prioritieshigher than 0, which meansthat when a SCHED_FIFO processbecomes
runnable, it will alwayspreempt immediately any currently running normal SCHED_OTHER process. SCHED_FIFO isa simple
scheduling algorithm without time slicing.
For processesscheduled under the SCHED_FIFO policy, the following rulesare applied: A SCHED_FIFO processthat hasbeen
preempted by another processof higher priority will stay at the head of the list for itspriority and will resume execution as
soon asall processesof higher priority are blocked again. When a SCHED_FIFO processbecomesrunnable, it will be inserted at
the end of the list for itspriority. A call to sched_setscheduler or sched_setparam will put the SCHED_FIFO processidentified by
sched_setscheduler, sched_getscheduler
Part II: SystemCalls
834
pi d at the end of the list if it wasrunnable. A processcalling sched_yield will be put at the end of the list. No other events
will move a processscheduled under the SCHED_FIFO policy in the wait list of runnable processeswith equal static priority. A
SCHED_FIFO processrunsuntil it isblocked by an I/O request, it ispreempted by a higher-priority process, or it calls
sched_yield.
SCHED_RR: ROUND-ROBIN SCHEDULING
SCHED_RR isa simple enhancement of SCHED_FIFO. Everything described in the preceding section for SCHED_FIFO also appliesto
SCHED_RR, except that each processisonly allowed to run for a maximum time quantum. If a SCHED_RR processhasbeen
running for a time period equal to or longer than the time quantum, it will be put at the end of the list for itspriority. A
SCHED_RR processthat hasbeen preempted by a higher-priority processand subsequently resumesexecution asa running
processwill complete the unexpired portion of itsround-robin time quantum. The length of the time quantum can be
retrieved by sched_rr_get_interval.
SCHED_OTHER: DEFAULT LINUX TIME-SHARING SCHEDULING
SCHED_OTHER can only be used at static priority 0. SCHED_OTHER isthe standard Linux time-sharing scheduler that isintended
for all processesthat do not require special static-priority real-time mechanisms. The processto run ischosen from the static
priority 0 list based on a dynamic priority that isdetermined only inside thislist. The dynamic priority isbased on the nice
level (set by the nice or setpriority system call) and isincreased for each time quantum the processisready to run but is
denied to run by the scheduler. Thisensuresfair progressamong all SCHED_OTHER processes.
RESPONSE TIME
A blocked high-priority processwaiting for the I/O hasa certain response time before it isscheduled again. The device driver
writer can greatly reduce thisresponse time by using a slow interrupt interrupt handler, asdescribed in request irq(9).
MISCELLANEOUS
Child processesinherit the scheduling algorithm and parametersacrossa fork.
Memory locking isusually needed for real-time processesto avoid paging delays; thiscan be done with mlock or mlockall.
Because a non-blocking endlessloop in a processscheduled under SCHED_FIFO or SCHED_RR will block all processeswith lower
priority forever, a software developer should alwayskeep available on the console a shell scheduled under a higher static
priority than the tested application. Thiswill allow an emergency kill of tested real-time applicationsthat do not block or
terminate asexpected. Because SCHED_FIFO and SCHED_RR processescan preempt other processesforever, only root processes
are allowed to activate these policiesunder Linux.
POSIX systemson which sched_setscheduler and sched_getscheduler are available define _POSIX_PRIORITY_SCHEDULING in
<unistd.h>.
RETURN VALUE
On success, sched_setscheduler returns0. On success, sched_getscheduler returnsthe policy for the process(a non-negative
integer). On error, 1 isreturned, and errno isset appropriately.
ERRORS
ESRCH The processwhose ID ispi d could not be found.
EPERM The calling processdoesnot have appropriate privileges. Only root processesare allowed to activate
the SCHED_FIFO and SCHED_RR policies. The processcalling sched_setscheduler needsan effective
UID equal to the EUID or UID of the processidentified by pi d, or it must be a superuser process.
EINVAL The scheduling policy isnot one of the recognized policies, or the parameter p doesnot make sense
for the policy.
STANDARDS
POSIX.1b (formerly POSIX.4)
835
BUGS
Asof Linux 1.3.81, SCHED_RR hasnot yet been tested carefully and might not behave exactly asdescribed or required by
POSIX.1b.
SEE ALSO
sched_setparam(2), sched_getparam(2), sched_yield(2), sched_get_priority_max(2), sched_get_priority_min(2), nice(2),
setpriority(2), getpriority(2), mlockall(2), munlockall(2), mlock(2), munlock(2).
Programmingfor theReal WorldPOSIX.4 by Bill O. Gallmeister, OReilly & Associates, Inc., ISBN 1-56592-074-0
IEEE Std 1003.1b-1003 (POSIX.1b standard)
ISO/IEC 9945-1:1996Thisisthe new 1996 revision of POSIX.1, which containsin one single standard POSIX.1(1990),
POSIX.1b(1993), POSIX.1c(1995), and POSIX.1i(1995).
Linux 1.3.81, 10 April 1996
sched_yield
sched_yieldYieldsthe processor
SYNOPSIS
#include <sched.h>
int sched_yield(void);
DESCRIPTION
A processcan relinquish the processor voluntarily without blocking by calling sched_yield. The processwill then be moved
to the end of the queue for itsstatic priority and a new processgetsto run.
Note: If the current processisthe only processin the highest priority list at that time, thisprocesswill continue to run after a
call to sched_yield.
POSIX systemson which sched_yield isavailable define _POSIX_PRIORITY_SCHEDULING in <unistd.h>.
RETURN VALUE
On success, sched_yield returns0. On error, 1 isreturned, and errno isset appropriately.
STANDARDS
POSIX.1b (formerly POSIX.4)
SEE ALSO
sched_setscheduler(2) for a description of Linux scheduling
Programmingfor theReal WorldPOSIX.4 by Bill O. Gallmeister, OReilly & Associates, Inc., ISBN 1-56592-074-0
IEEE Std 1003.1b-1993 (POSIX.1b standard)
ISO/IEC 9945-1:1996
Linux 1.3.81, 10 April 1996
select, FD_CLR, FD_ISSET, FD_SET, FD_ZERO
select, FD_CLR, FD_ISSET, FD_SET, FD_ZEROSynchronousI/O multiplexing
select, FD_CLR, FD_ISSET, FD_SET, FD_ZERO
Part II: SystemCalls
836
SYNOPSIS
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
int select(int n,fd_set *r eadf ds ,fd_set *wr i t ef ds,fd_set *except f ds,
struct timeval *t i meout );
FD_CLR(int f d,fd_set *set );
FD_ISSET(int f d,fd_set *set );
FD_SET(int f d,fd_set *set );
FD_ZERO(fd_set *set )
DESCRIPTION
select waitsfor a number of file descriptorsto change status.
Three independent setsof descriptorsare watched. Those listed in r eadf ds will be watched to see if charactersbecome
available for reading, those in wr i t ef ds will be watched to see if it isokay to immediately write on them, and those in
except f ds will be watched for exceptions. On exit, the setsare modified in place to indicate which descriptorsactually
changed status.
Four macrosare provided to manipulate the sets. FD_ZERO will clear a set. FD_SET and FD_CLR add or remove a given descriptor
from a set. FD_ISSET teststo see if a descriptor ispart of the set; thisisuseful after select returns.
n isthe highest-numbered descriptor in any of the three sets, plus1.
t i meout isan upper bound on the amount of time elapsed before select returns. It may be 0, which causesselect to return
immediately. If timeout isNULL (no timeout), select can block indefinitely.
RETURN VALUE
On success, select returnsthe number of descriptorscontained in the descriptor sets, which may be 0 if the timeout expires
before anything interesting happens. On error, 1 isreturned, and errno isset appropriately; the setsand t i meout become
undefined, so do not rely on their contentsafter an error.
ERRORS
EBADF An invalid file descriptor wasgiven in one of the sets.
EINTR A non-blocked signal wascaught.
EINVAL n isnegative.
ENOMEM select wasunable to allocate memory for internal tables.
NOTES
Some code callsselect with all three setsempty, n=0, and a non-null timeout; thisisa fairly portable way to sleep with
subsecond precision.
On Linux, t i meout ismodified to reflect the amount of time not slept; most other implementationsdo not do this. This
causesproblemsboth when Linux code that readst i meout isported to other operating systemsand when code isported to
Linux that reusesa struct timeval for multiple selectsin a loop without reinitializing it. Consider t i meout to be undefined
after select returns.
EXAMPLE
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
837
int
main(void)
{
fd_set rfds;
struct timeval tv;
int retval;
/* Watch stdin (fd 0) to see when it has input. */
FD_ZERO(&rfds);
FD_SET(0, &rfds);
/* Wait up to five seconds. */
tv.tv_sec = 5;
tv.tv_usec = 0;
retval = select(1, &rfds, NULL, NULL, &tv);
/* Dont rely on the value of tv now! */
if (retval)
printf(Data is available now.nn);
/* FD_ISSET(0, &rfds) will be true. */
else
printf(No data within five seconds.nn);
exit(0);
}
SEE ALSO
accept(2), connect(2), read(2), recv(2), send(2), write(2)
Linux 1.2, 11 February1996
semctl
semctlSemaphore-control operations
SYNOPSIS
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int semctl ( int semi d,int semnun,int cmd, union semun ar g );
DESCRIPTION
The function performsthe control operation specified by cmd on the semaphore set (or on the sumun-nth semaphore of the
set) identified by semi d. The first semaphore of the set isindicated by a value of 0 for semun.
The type of ar g isthe union
union semun {
int val; /* used for SETVAL only */
struct semid_ds *buf; /* for IPC_STAT and IPC_SET */
ushort *array; /* used for GETALL and SETALL */
};
Legal valuesfor cmd are
IPC_STAT Copiesinfo from the semaphore set data structure into the structure pointed to by ar g.buf. The
argument semnum isignored. The calling processmust have read accessprivilegeson the semaphore set.
semctl
Part II: SystemCalls
838
IPC_SET Writesthe valuesof some membersof the semid_ds structure pointed to by ar g.buf to the semaphore
set data structure, updating also itssem_ctime member. Considered membersfrom the user-supplied
struct semid_ds pointed to by arg.buf are
sem_perm.uid
sem_perm.gid
sem_perm.mode /* only lowest 9-bits */
The calling processseffective user ID must be superuser, creator, or owner of the semaphore set. The
argument semnum isignored.
IPC_RMID Removesthe semaphore set and itsdata structuresimmediately, awakening all waiting processes(with
an error return and errno set to EIDRM). The calling processseffective user ID must be superuser,
creator, or owner of the semaphore set. The argument semnum isignored.
GETALL Returnssemval for all semaphoresof the set into ar g.array. The argument semnum isignored. The
calling processmust have read accessprivilegeson the semaphore set.
GETNCNT The system call returnsthe value of semncnt for the semnoth semaphore of the set (that is, the number
of processeswaiting for an increase of semval for the semnoth semaphore of the set). The calling
processmust have read accessprivilegeson the semaphore set.
GETPID The system call returnsthe value of sempid for the semnoth semaphore of the set (that is, the pid of the
processthat executed the last semop call for the semnoth semaphore of the set). The calling process
must have read accessprivilegeson the semaphore set.
GETVAL The system call returnsthe value of semval for the semnoth semaphore of the set. The calling process
must have read accessprivilegeson the semaphore set.
GETZCNT The system call returnsthe value of semzcnt for the semnoth semaphore of the set (that is, the number
of processeswaiting for the semval of the semnoth semaphore of the set to become 0). The calling
processmust have read accessprivilegeson the semaphore set.
SETALL Setssemval for all semaphoresof the set using ar g.array, updating also the sem_ctime member of the
semid_ds structure associated with the set. Undo entriesare cleared for altered semaphoresin all
processes. Processessleeping on the wait queue are awakened if some semval becomes0 or increases.
The argument semnum isignored. The calling processmust have alter accessprivilegeson the semaphore
set.
SETVAL Setsthe value of semval to ar g.val for the semnumth semaphore of the set, updating also the sem_ctime
member of the semid_ds structure associated to the set. The undo entry iscleared for the altered
semaphore in all processes. Processessleeping on the wait queue are awakened if semval becomes0 or
increases. The calling processmust have alter accessprivilegeson the semaphore set.
RETURN VALUE
On fail, the system call returns1, with errno indicating the error. Otherwise the system call returnsa non-negative value,
depending on cmd, asfollows:
GETNCNT The value of semncnt.
GETPID The value of sempid.
GETVAL The value of semval.
GETZCNT The value of semzcnt.
ERRORS
For a failing return, errno will be set to one of the following values:
EACCESS The calling processhasno accesspermissionsneeded to execute cmd.
EFAULT The addresspointed to by ar g.buf or ar g.array isnt accessible.
EIDRM The semaphore set wasremoved.
EINVAL Invalid value for cmd or semi d.
839
EPERM The argument cmd hasthe value IPC_SET or IPC_RMID, but the calling processseffective user ID has
insufficient privilegesto execute the command.
ERANGE The argument cmd hasthe value SETALL or SETVAL, and the value to which semval hasto be set (for some
semaphore of the set) islessthan 0 or greater than the implementation value SEMVMX.
NOTES
The IPC_INFO, SEM_STAT, and SEM_INFO control callsare used by the ipcs(1) program to provide information on allocated
resources. In the future these can be modified asneeded or moved to a proc filesystem interface.
The following system limit on semaphore setsaffectsa semctl call:
SEMVMX Maximum value for semval; implementation dependent (32767).
SEE ALSO
ipc(5), shmget(2), shmat(2), shmdt(2)
Linux 0.99.13, 1 November 1993
semget
semgetGetsa semaphore set identifier
SYNOPSIS
# include <sys/types.h>
# include <sys/ipc.h>
# include <sys/sem.h>
int semget ( key_t key,int nsems ,int semf l g );
DESCRIPTION
Thisfunction returnsthe semaphore set identifier associated with the value of the argument key. A new set of nsems
semaphoresiscreated if key hasthe value IPC_PRIVATE or key isnt IPC_PRIVATE, if no existing message queue isassociated to
key, and if IPC_CREAT isasserted in semf l g (that is, semflg&IPC_CREAT isnt 0). The presence in semf l g of the fieldsIPC_CREAT
and IPC_EXCL playsthe same role, with respect to the existence of the semaphore set, asthe presence of O_CREAT and O_EXCL in
the mode argument of the open(2) system callthat is, the msgget function failsif semf l g assertsboth IPC_CREAT and IPC_EXCL
and a semaphore set already existsfor key.
Upon creation, the lower 9 bitsof the argument semf l g define the accesspermissions(for owner, group, and others) to the
semaphore set in the same format, and with the same meaning, asfor the accesspermissionsparameter in the open(2) or
creat(2) system call (although the execute permissionsare not used by the system, and the term writepermissions, for a
semaphore set, effectively meansalter permissions).
Furthermore, while creating, the system call initializesthe system semaphore set data structure semid_ds asfollows:
I sem_perm.cuid and sem_perm.uid are set to the effective user ID of the calling process.
I sem_perm.cgid and sem_perm.gid are set to the effective group ID of the calling process.
I The lowest-order 9 bitsof sem_perm.mode are set to the lowest-order 9 bitsof semf l g.
I sem_nsems isset to the value of nsems.
I sem_otime isset to 0.
I sem_ctime isset to the current time.
The argument nsems can be 0 (a dont care) when the system call isnt create(2). Otherwise, nsems must be greater than 0
and lessor equal to the maximum number of semaphoresper semid (SEMMSL).
If the semaphore set already exists, the accesspermissionsare verified, and a check ismade to see if it ismarked for destruc-
tion.
semget
Part II: SystemCalls
840
RETURN VALUE
If successful, the return value will be the semaphore set identifier (a positive integer); otherwise it will be 1, with errno
indicating the error.
ERRORS
For a failing return, errno will be set to one of the following values:
EACCES A semaphore set existsfor key , but the calling processhasno accesspermissionsto the set.
EEXIST A semaphore set existsfor key, and semf l g wasasserting both IPC_CREAT and IPC_EXCL.
EIDRM The semaphore set ismarked to be deleted.
ENOENT No semaphore set existsfor key, and semflg wasnt asserting IPC_CREAT.
ENOMEM A semaphore set hasto be created, but the system doesnot have enough memory for the new data
structure.
ENOSPC A semaphore set hasto be created, but the system limit for the maximum number of semaphore
sets(SEMMNI) or the system-wide maximum number of semaphores(SEMMNS) would be exceeded.
NOTES
IPC_PRIVATE isnt a flag field but a key_t type. If thisspecial value isused for key, the system call ignoreseverything but the
lowest-order 9 bitsof semf l g and createsa new semaphore set (on success).
The followingsare limitson semaphore set resourcesaffecting a semget call:
SEMMNI System-wide maximum number of semaphore sets; policy dependent.
SEMMSL Maximum number of semaphoresper semid; implementation dependent (500 currently).
SEMMNS System-wide maximum number of semaphores; policy dependent. A value greater than
SEMMSLSEMMNI makesit irrelevant.
BUGS
Use of IPC_PRIVATE doesnt inhibit other processes accessto the allocated semaphore set.
Asfor the files, there iscurrently no intrinsic way for a processto ensure exclusive accessto a semaphore set. Asserting both
IPC_CREAT and IPC_EXCL in semf l g only ensures(on success) that a new semaphore set will be created; it doesnt imply
exclusive accessto the semaphore set.
The data structure associated with each semaphore in the set isnt initialized by the system call. In order to initialize those
data structures, you have to execute a subsequent call to semctl(2) to perform a SETVAL or a SETALL command on the
semaphore set.
SEE ALSO
ftok(3), ipc(5), semctl(2), semop(2)
Linux 0.99.13, 1 November 1993
semop
semopSemaphore operations
SYNOPSIS
# include <sys/types.h>
# include <sys/ipc.h>
# include <sys/sem.h>
int semop ( int semi d,struct sembuf *sops, unsigned nsops );
841
DESCRIPTION
The function performsoperationson selected membersof the semaphore set indicated by semi d. Each of the nsops elements
in the array pointed to by sops specifiesan operation to be performed on a semaphore by a struct sembuf including the
following members:
short sem_num; /* semaphore number: 0 = first */
short sem_op; /* semaphore operation */
short sem_flg; /* operation flags */
Flagsrecognized in sem_flg are IPC_NOWAIT and SEM_UNDO. If an operation assertsSEM_UNDO, it will be undone when the process
exits.
The system call semantic assuresthat the operationswill be performed if and only if all of them will succeed. Each operation
isperformed on the sem_numth semaphore of the semaphore set, where the first semaphore of the set issemaphore 0 and is
one of the following three:
I If sem_op isa positive integer, the operation addsthisvalue to semval. Furthermore, if SEM_UNDO isasserted for this
operation, the system updatesthe processundo count for thissemaphore. The operation alwaysgoesthrough, so no
processsleeping can happen. The calling processmust have alter permissionson the semaphore set.
I If sem_op is0, the processmust have read accesspermissionson the semaphore set. If semval is0, the operation goes
through. Otherwise, if IPC_NOWAIT isasserted in sem_flg, the system call fails(undoing all previousactionsperformed),
with errno set to EAGAIN. Otherwise, semzcnt isincremented by 1, and the processsleepsuntil one of the following
occurs:
I semval becomes0, at which time the value of semzcnt isdecremented.
I The semaphore set isremoved, causing the system call to fail with errno set to EIDRM.
I The calling processreceivesa signal that hasto be caught; which causesthe value of semzcnt to be decremented and
the system call to fail with errno set to EINTR.
I If sem_op islessthan 0, the processmust have alter permissionson the semaphore set. If semval isgreater than or equal to
the absolute value of sem_op, the absolute value of sem_op issubtracted by semval. Furthermore, if SEM_UNDO isasserted for
thisoperation, the system updatesthe processundo count for thissemaphore. Then the operation goesthrough.
Otherwise, if IPC_NOWAIT isasserted in sem_flg, the system call fails(undoing all previousactionsperformed), with errno
set to EAGAIN. Otherwise, semncnt isincremented by 1 and the processsleepsuntil one of the following occurs:
I semval becomesgreater than or equal to the absolute value of sem_op, at which time the value of semncnt is
decremented, the absolute value of sem_op issubtracted from semval and, if SEM_UNDO isasserted for thisoperation,
the system updatesthe processundo count for thissemaphore.
I The semaphore set isremoved from the system: the system call fails, with errno set to EIDRM.
I The calling processreceivesa signal that hasto be caught; the value of semncnt isdecremented, and the system call
failswith errno set to EINTR.
In case of success, the sempid member of the structure sem for each semaphore specified in the array pointed to by sops isset
to the processID of the calling process. Furthermore both sem_otime and sem_ctime are set to the current time.
RETURN VALUE
If successful, the system call returns0; otherwise, it returns1, with errno indicating the error.
ERRORS
For a failing return, errno will be set to one of the following values:
E2BIG The argument nsops isgreater than SEMOPM, the maximum number of operationsallowed per system
call.
EACCES The calling processhasno accesspermissionson the semaphore set asrequired by one of the specified
operations.
EAGAIN An operation could not go through, and IPC_NOWAIT wasasserted in itssem_f l g.
EFAULT The addresspointed to by sops isnt accessible.
semop
Part II: SystemCalls
842
EFBIG For some operation, the value of sem_num islessthan 0 or greater than or equal to the number of
semaphoresin the set.
EIDRM The semaphore set wasremoved.
EINTR Sleeping on a wait queue, the processreceived a signal that had to be caught.
EINVAL The semaphore set doesnt exist, or semi d islessthan 0, or nsops hasa non-positive value.
ENOMEM The sem_flg of some operation asserted SEM_UNDO, and the system doesnot have enough memory to
allocate the undo structure.
ERANGE For some operation, semop+semvalis isgreater than SEMVMX, the implementation-dependent maximum
value for semval.
NOTES
The sem_undo structuresof a processarent inherited by itschild on execution of a fork(2) system call. They are instead
inherited by the substituting processresulting from the execution of the exec(2) system call.
The following are limitson semaphore set resourcesaffecting a semop call:
SEMOPM Maximum number of operationsallowed for one semop call; policy dependent.
SEMVMX Maximum allowable value for semval; implementation dependent (32767).
The implementation hasno intrinsic limitsfor the adjust on exit maximum value (SEMAEM), the system-wide maximum
number of undo structures(SEMMNU), or the per-processmaximum number of undo entriessystem parameters.
BUGS
The system maintainsa per-processsem_undo structure for each semaphore altered by the processwith undo requests. Those
structuresare free at processexit. One major cause for unhappinesswith the undo mechanism isthat it doesnot fit in with
the notion of having an atomic set of operationsin an array of semaphores. The undo requestsfor an array and each
semaphore therein might have been accumulated over many semopt calls. Should the processsleep when exiting, or should all
undo operationsbe applied with the IPC_NOWAIT flag in effect?Currently those undo operationsthat go through immediately
are applied, and those that require a wait are ignored silently. Therefore harmlessundo usage isguaranteed with private
semaphoresonly.
SEE ALSO
ipc(5), semctl(2), semget(2)
Linux 0.99.13, 1 November 1993
send, sendto, sendmsg
send, sendto, sendmsgSendsa message from a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int send(int s, const void *msg,int l en, unsigned int f l ags);
int sendto(int s, const void *msg, int l en, unsigned int f l ags,
const struct sockaddr *t o, int t ol en);
int sendmsg(int s, const struct msghdr *msg , unsigned int f l ags);
DESCRIPTION
Warning: Thisisa BSD man page. Asof Linux 0.99.11, sendmsg wasnot implemented.
send, sendto, and sendmsg are used to transmit a message to another socket. send may be used only when the socket isin a
connected state, whereassendto and sendmsg may be used at any time.
843
The addressof the target isgiven by t o, with t ol en specifying itssize. The length of the message isgiven by l en. If the
message istoo long to passatomically through the underlying protocol, the error EMSGSIZE isreturned, and the message isnot
transmitted.
No indication of failure to deliver isimplicit in a send. Locally detected errorsare indicated by a return value of 1.
If no message space isavailable at the socket to hold the message to be transmitted, send normally blocks, unlessthe socket
hasbeen placed in non-blocking I/O mode. The select(2) call may be used to determine when it ispossible to send more
data.
The f l ags parameter may include one or more of the following:
#define MSG_OOB 0x1 /* process out-of-band data */
#define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */
The flag MSG_OOB isused to send out-of-band data on socketsthat support thisnotion (for example, SOCK_STREAM); the
underlying protocol must also support out-of-band data. MSG_DONTROUTE isusually used only by diagnostic or routing
programs.
See recv(2) for a description of the msghdr structure.
RETURN VALUES
The call returnsthe number of characterssent, or 1 if an error occurred.
ERRORS
EBADF An invalid descriptor wasspecified.
ENOTSOCK The argument s isnot a socket.
EFAULT An invalid user space addresswasspecified for a parameter.
EMSGSIZE The socket requiresthat message be sent atomically, and the size of the message to be sent made
thisimpossible.
EWOULDBLOCK The socket ismarked non-blocking, and the requested operation would block.
ENOBUFS The system wasunable to allocate an internal buffer. The operation might succeed when buffers
become available.
ENOBUFS The output queue for a network interface wasfull. Thisgenerally indicatesthat the interface has
stopped sending, but it might be caused by transient congestion.
HISTORY
These function callsappeared in BSD 4.2.
SEE ALSO
fcntl(2), recv(2), select(2), getsockopt(2), socket(2), write(2)
BSD Man Page, 24 July1993
setfsgid
setfsgidSetsgroup identity used for filesystem checks
SYNOPSIS
int setfsgid(uid_t f sgi d);
DESCRIPTION
setfsgid setsthe group ID that the Linux kernel usesto check for all accessesto the filesystem. Normally, the value of f sgi d
will shadow the value of the effective group ID. In fact, whenever the effective group ID ischanged, f sgi d will also be
changed to the new value of the effective group ID.
setfsgid
Part II: SystemCalls
844
An explicit call to setfsgid isusually only used by programssuch asthe Linux NFS server that need to change what group
ID isused for file accesswithout a corresponding change in the real and effective group IDs. A change in the normal group
IDsfor a program such asthe NFSserver isa security hole that can expose it to unwanted signalsfrom other group IDs.
setfsgid will succeed only if the caller isthe superuser or if f sgi d matcheseither the real group ID, effective group ID, saved
group ID, or the current value of f sgi d.
RETURN VALUE
On success, the previousvalue of f sgi d isreturned. On error, the current value of f sgi d isreturned.
CONFORMS TO
setfsgid isLinux specific.
BUGS
No error messagesof any kind are returned to the caller. At the very least, EPERM should be returned when the call fails.
SEE ALSO
setfsuid(2)
Linux 1.3.15, 6 August 1995
setfsuid
setfsuidSetsuser identity used for filesystem checks
SYNOPSIS
int setfsuid(uid_t f sui d);
DESCRIPTION
setfsuid setsthe user ID that the Linux kernel usesto check for all accessesto the filesystem. Normally, the value of f sui d
will shadow the value of the effective user ID. In fact, whenever the effective user ID ischanged, f sui d will also be changed
to the new value of the effective user ID.
An explicit call to setfsuid isusually used only by programssuch asthe Linux NFS server that need to change what user ID
isused for file accesswithout a corresponding change in the real and effective user IDs. A change in the normal user IDsfor a
program such asthe NFS server isa security hole that can expose it to unwanted signalsfrom other user IDs.
setfsuid will succeed only if the caller isthe superuser or if f sui d matcheseither the real user ID, effective user ID, saved user
ID, or the current value of f sui d.
RETURN VALUE
On success, the previousvalue of f sui d isreturned. On error, the current value of f sui d isreturned.
CONFORMS TO
setfsuid isLinux specific.
BUGS
No error messagesof any kind are returned to the caller. At the very least, EPERM should be returned when the call fails.
SEE ALSO
setfsgid(2)
Linux 1.3.15, 6 August 1995
845
setgid
setgidSetsgroup identity
SYNOPSIS
#include <unistd.h>
int setgid(gid_t gi d);
DESCRIPTION
setgid setsthe effective group ID of the current process. If the caller isthe superuser, the real and saved group IDsare also
set.
Under Linux, setgid isimplemented like SYSV, with SAVED_IDS. Thisallowsa setgid (other than root) program to drop all its
group privileges, do some unprivileged work, and then re-engage the original effective group ID in a secure manner.
If the user isroot or the program issetgid root, special care must be taken. The setgid function checksthe effective gid of
the caller and, if it isthat of the superuser, all process-related group IDsare set to gi d. After thishasoccurred, it isimpossible
for the program to regain root privileges.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM The user isnot the superuser, and gi d doesnot match the effective or saved group ID of the calling process.
CONFORMS TO
System V
SEE ALSO
getgid(2), setregid(2), setegid(2)
Linux 1.1.36, 29 July1994
setpgid, getpgid, setpgrp, getpgrp
setpgid, getpgid, setpgrp, getpgrpSets/getsprocessgroup
SYNOPSIS
#include <unistd.h>
int setpgid(pid_t pi d, pid_t pgi d);
pid_t getpgid(pid_t pi d);
int setpgrp(void);
pid_t getpgrp(void);
DESCRIPTION
setpgid setsthe processgroup ID of the processspecified by pi d to pgi d. If pi d is0, the processID of the current processis
used. If pgi d is0, the processID of the processspecified by pi d isused.
getpgid returnsthe processgroup ID of the processspecified by pi d. If pi d is0, the processID of the current processisused.
In the Linux DLL 4.4.1 library, setpgrp simply callssetpgid(0,0).
getpgrp isequivalent to getpgid(0).
setpgid, getpgid, setpgrp, getpgrp
Part II: SystemCalls
846
Processgroupsare used for distribution of signals, and by terminalsto arbitrate requestsfor their input; processesthat have
the same processgroup asthe terminal are foreground and may read, whereasotherswill block with a signal if they attempt
to read.
These callsare thusused by programssuch ascsh(1) to create processgroupsin implementing job control. The TIOCGPGRP
and TIOCSPGRP callsdescribed in termios(4) are used to get/set the processgroup of the control terminal.
RETURN VALUE
On success, setpgid and setpgrp return 0. On error, 1 isreturned, and errno isset appropriately.
getpgid returnsa processgroup on success. On error, 1 isreturned, and errno isset appropriately.
getpgrp alwaysreturnsthe current processgroup.
ERRORS
EINVAL pgi d islessthan 0.
EPERM Variouspermission violations.
ESRCH pi d doesnot match any process.
CONFORMS TO
The functionssetpgid and getpgrp conform to POSIX.1. The function setpgrp isfrom BSD 4.2. I have no information on
the source of getpgid.
SEE ALSO
getuid(2), setsid(2), tcsetpgrp(3), termios(4)
Linux 1.2.4, 15 April 1995
setregid, setegid
setregid, setegidSetsreal and/or effective group ID
SYNOPSIS
#include <unistd.h>
int setregid(gid_t r gi d, gid_t egi d);
int setegid(gid_t egi d);
DESCRIPTION
setregid setsreal and effective group IDsof the current process. Unprivileged usersmay change the real group ID to the
effective group ID, and vice versa.
Prior to Linux 1.1.38, the saved ID paradigm, when used with setregid or setegid, wasbroken. Starting at 1.1.38, it isalso
possible to set the effective group ID from the saved user ID.
Only the superuser may make other changes.
Supplying a value of 1 for either the real or effective group ID forcesthe system to leave that ID unchanged.
Currently (libc-4.x.x), setegid(egi d) isfunctionally equivalent to setregid(- 1, egi d).
If the real group ID ischanged or the effective group ID isset to a value not equal to the previousreal group ID, the saved
group ID will be set to the new effective group ID.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
847
ERRORS
EPERM The current processisnot the superuser, and changesother than swapping the effective group ID
with the real group ID, setting one to the value of the other, or setting the effective group ID to the
value of the saved group ID wasspecified.
HISTORY
The setregid function call appeared in BSD 4.2.
CONFORMS TO
BSD 4.3
SEE ALSO
getgid(2), setgid(2)
Linux 1.1.38, 2 August 1994
setreuid, seteuid
setreuid, seteuidSetsreal and / or effective user ID
SYNOPSIS
#include <unistd.h>
int setreuid(uid_t r ui d, uid_t eui d);
int seteuid(uid_t eui d);
DESCRIPTION
setreuid setsreal and effective user IDsof the current process. Unprivileged usersmay change the real user ID to the
effective user ID, and vice versa.
Prior to Linux 1.1.37, the saved ID paradigm, when used with setreuid or seteuid, wasbroken.
Starting at 1.1.37, it isalso possible to set the effective user ID from the saved user ID.
Only the superuser may make other changes.
Supplying a value of 1 for either the real or effective user ID forcesthe system to leave that ID unchanged.
Currently (libc-4.x.x), seteuid(eui d) isfunctionally equivalent to setreuid(- 1, eui d).
If the real user ID ischanged or the effective user ID isset to a value not equal to the previousreal user ID, the saved user ID
will be set to the new effective user ID.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM The current processisnot the superuser, and changesother than swapping the effective user ID
with the real user ID, setting one to the value of the other, or setting the effective user ID to the
value of the saved user ID wasspecified.
HISTORY
The setreuid function call appeared in BSD 4.2.
CONFORMS TO
BSD 4.3
setreuid, seteuid
Part II: SystemCalls
848
SEE ALSO
getuid(2), setuid(2)
Linux 1.1.38, 2 August 1994
setsid
setsidCreatesa session and setsthe processgroup ID
SYNOPSIS
#include <unistd.h>
pid_t setsid(void);
DESCRIPTION
setsid() createsa new session if the calling processisnot a processgroup leader. The calling processisthe leader of the new
session, the processgroup leader of the new processgroup, and hasno controlling tty. The processgroup ID and session ID
of the calling processare set to the PID of the calling process. The calling processwill be the only processin thisnew process
group and in thisnew session.
RETURN VALUE
It returnsthe session ID of the calling process.
ERRORS
On error, 1 will be returned. The only error that can happen isEPERM, which isreturned when the processgroup ID of any
processequalsthe PID of the calling process. Thus, in particular, setsid failsif the calling processisalready a processgroup
leader.
NOTES
A processgroup leader isa processwith processgroup ID equal to itsPID. In order to be sure that setsid will succeed, fork,
and exit, and have the child do setsid().
CONFORMS TO
POSIX
SEE ALSO
setpgid(2), setpgrp(2)
27 August 1994
setuid
setuidSetsuser identity
SYNOPSIS
#include <unistd.h>
int setuid(uid_t ui d);
DESCRIPTION
setuid setsthe effective user ID of the current process. If the caller isthe superuser, the real and saved user IDsare also set.
849
Under Linux, setuid isimplemented like SYSV, with SAVED_IDS. Thisallowsa setuid (other than root) program to drop all its
user privileges, do some unprivileged work, and then re-engage the original effective user ID in a secure manner.
If the user isroot or the program issetuid root, special care must be taken. The setuid function checksthe effective UID of
the caller, and, if it isthe superuser, all process-related user IDsare set to ui d. After thishasoccurred, it isimpossible for the
program to regain root privileges.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM The user isnot the superuser, and ui d doesnot match the effective or saved user ID of the calling
process.
CONFORMS TO
System V
SEE ALSO
getuid(2), setreuid(2), seteuid(2)
Linux 1.1.36 29 July1994
setup
setupSetsup devicesand filesystems, mount root filesystem
SYNOPSIS
#include <unistd.h>
syscall0(int, setup);
int setup(void);
DESCRIPTION
setup iscalled once from within linux/init/main.c. It callsinitialization functionsfor devicesand filesystemsconfigured into
the kernel and then mountsthe root filesystem.
No user processmay call setup. Any user process, even a processwith superuser permission, will receive EPERM.
RETURN VALUE
setup alwaysreturns1 for a user process.
ERRORS
EPERM Always, for a user process.
CONFORMS TO
Thisfunction isLinux specific.
Linux 1.2.9, 3 May1996
shmctl
shmctlShared memory control
shmctl
Part II: SystemCalls
850
SYNOPSIS
#include <sys/ipc.h>
#include <sys/shm.h>
int shmctl(int shmi d,int cmd, struct shmid ds *buf );
DESCRIPTION
shmctl() allowsthe user to receive information on a shared memory segment, set the owner, group, and permissionsof a
shared memory segment, or destroy a segment. The information about the segment identified by shmi d isreturned in a
shmi d_ds structure:
struct shmid_ds {
struct ipc_perm shm_perm; /* operation perms */
int shm_segsz; /* size of segment (bytes) */
time_t shm_atime; /* last attach time */
time_t shm_dtime; /* last detach time */
time_t shm_ctime; /* last change time */
unsigned short shm_cpid; /* pid of creator */
unsigned short shm_lpid; /* pid of last operator */
short shm_nattch; /* no. of current attaches */
/* the following are private */
unsigned short shm_npages; /* size of segment (pages) */
unsigned long *shm_pages;
struct shm_desc *attaches; /* descriptors for attaches */
};
The fieldsin the member shm_per m can be set:
struct ipc_perm
{
key_t key;
ushort uid;/*owner euid and egid */
ushort gid;
ushort cuid; /* creator euid and egid */
ushort cgid;
ushort mode; /* lower 9 bits of access modes */
ushort seq; /* sequence number */
};
The following cmdsare available:
IPC_STAT Used to copy the information about the shared memory segment into the buffer, buf . The user
must have read accessto the shared memory segment.
IPC_SET Used to apply the changesthe user hasmade to the ui d, gi d, or mode membersof the shm_per ms
field. Only the lowest 9 bitsof mode are used. The shm_ct i me member isalso updated. The user
must be the owner, the creator, or the superuser.
IPC_RMID Used to mark the segment asdestroyed. It will actually be destroyed after the last detach. (That is,
when the shm_nat t ch member of the associated structure shmi d_ds iszero.)The user must be the
owner, the creator, or the superuser.
The user must ensure that a segment iseventually destroyed; otherwise the pagesthat were faulted in will remain in memory
or swap.
In addition, the superuser can prevent or allow swapping of a shared memory segment with the following cmds: (Linux only)
SHM_LOCK Preventsswapping of a shared memory segment. The user must fault in any pagesthat are required
to be present after locking isenabled.
SHM_UNLOCK Allowsthe shared memory segment to be swapped out.
The IPC_INFO, SHM_STAT, and SHM_INFO control callsare used by the ipcs(1) program to provide information on allocated
resources. In the future, these may be modified asneeded or moved to a proc filesystem interface.
851
SYSTEM CALLS
fork() After a fork(), the child inheritsthe attached shared memory segments.
exec() After an exec(), all attached shared memory segmentsare detached (not destroyed).
exit() On exit(), all attached shared memory segmentsare detached (not destroyed).
RETURN VALUE
0 isreturned on success; 1 on error.
ERRORS
On error, errno will be set to one of the following:
EACCESS Returned if IPC_STAT isrequested and shm_perm.modes doesnot allow read accessfor msqid.
EFAULT The argument cmd hasthe value IPC_SET or IPC_STAT, but the addresspointed to by buf isnt
accessible.
EINVAL Returned if shmid isnot a valid identifier, or cmd isnot a valid command.
EIDRM Returned if shmid pointsto a removed identifier.
EPERM Returned if IPC_SET or IPC_RMID isattempted, if the user isnot the creator, the owner, or the
superuser, and if the user doesnot have permission granted to hisgroup or to the world.
SEE ALSO
shmget(2), shmop(2)
Linux 0.99.11, 28 November 1993
shmget
shmgetAllocatesa shared memory segment
SYNOPSIS
#include <sys/ipc.h>
#include <sys/shm.h>
int shmget(key_t key,int si ze, int shmf l g);
DESCRIPTION
shmget() returnsthe identifier of the shared memory segment associated with the value of the argument key. A new shared
memory segment, with itssize equal to the rounding up of si ze to a multiple of PAGE_SIZE, iscreated if key hasthe value
IPC_PRIVATE or if key isnt IPC_PRIVATE, if no shared memory segment isassociated to key, and if IPC_CREAT isasserted in
shmflg (that is, shmflg&IPC_CREAT isnt 0). The presence in shmflg iscomposed of
IPC_CREAT Createsa new segment. If thisflag isnot used, shmget() will find the segment associated with key ,
check to see if the user haspermission to receive the shmid associated with the segment, and ensure
the segment isnot marked for destruction.
IPC_EXCL Used with IPC_CREAT to ensure failure if the segment exists.
mode_flags (lowest 9 bits) Specifiesthe permissionsgranted to the owner, group, and world. Presently, the
execute permissionsare not used by the system.
If a new segment iscreated, the accesspermissionsfrom shmflg are copied into the shm_perm member of the shmid_ds
structure that definesthe segment. Following isthe shmid_ds structure:
struct shmid_ds {
struct ipc_perm shm_perm; /* operation perms */
int shm_segsz; /* size of segment (bytes) */
shmget
Part II: SystemCalls
852
time_t shm_atime; /* last attach time */
time_t shm_dtime; /* last detach time */
time_t shm_ctime; /* last change time */
unsigned short shm_cpid; /* pid of creator */
unsigned short shm_lpid; /* pid of last operator */
short shm_nattch; /* no. of current attaches */
};
struct ipc_perm
{
key_t key;
ushort uid; /* owner euid and egid */
ushort gid;
ushort cuid; /* creator euid and egid */
ushort cgid;
ushort mode; /* lower 9 bits of shmf l g */
ushort seq; /* sequence number */
};
Furthermore, while creating, the system call initializesthe system shared memory segment data structure shmid_ds asfollows:
I shm_perm.cuid and shm_perm.uid are set to the effective user ID of the calling process.
I shm_perm.cgid and shm_perm.gid are set to the effective group ID of the calling process.
I The lowest-order 9 bitsof shm_perm.mode are set to the lowest-order 9 bit of shmflg.
I shm_segsz isset to the value of si ze.
I shm_lpid, shm_nattch, shm_atime, and shm_dtime are set to 0.
I shm_ctime isset to the current time.
If the shared memory segment already exists, the accesspermissionsare verified, and a check ismade to see if it ismarked for
destruction.
SYSTEM CALLS
fork() After a fork(), the child inheritsthe attached shared memory segments.
exec() After an exec(), all attached shared memory segmentsare detached (not destroyed).
exit() On exit(), all attached shared memory segmentsare detached (not destroyed).
RETURN VALUE
A valid segment identifier, shmid, isreturned on success, 1 on error.
ERRORS
On failure, errno isset to one of the following:
EINVAL Returned if SHMMIN isgreater than si ze, if si ze isgreater than SHMMAX, or if si ze isgreater than the
size of the segment.
EEXIST Returned if IPC_CREAT | IPC_EXCL wasspecified and the segment exists.
EIDRM Returned if the segment ismarked asdestroyed or wasremoved.
ENOSPC Returned if all possible shared memory IDshave been taken (SHMMNI) or if allocating a segment of
the requested size would cause the system to exceed the system-wide limit on shared memory
(SHMALL).
ENOENT Returned if no segment existsfor the given key , and IPC_CREAT wasnot specified.
EACCES Returned if the user doesnot have permission to accessthe shared memory segment.
ENOMEM Returned if no memory could be allocated for segment overhead.
853
NOTES
IPC_PRIVATE isnt a flag field but a key_t type. If thisspecial value isused for key, the system call ignoreseverything but the
lowest order 9 bitsof shmf l g and createsa new shared memory segment (on success).
The following are limitson shared memory segment resourcesaffecting a shmget call:
SHMALL System-wide maximum of shared memory pages; policy dependent.
SHMMAX Maximum size, in bytes, for a shared memory segment; implementation dependent (currently
4MB).
SHMMIN Minimum size, in bytes, for a shared memory segment; implementation dependent (currently 1
byte, although PAGE_SIZE isthe effective minimum size).
SHMMNI System-wide maximum number of shared memory segments; implementation dependent (currently
4096).
The implementation hasno specific limitsfor the per-processmaximum number of shared memory segments(SHMSEG).
BUGS
Use of IPC_PRIVATE doesnot inhibit other processes accessto the allocated shared memory segment.
Asfor the files, there iscurrently no intrinsic way for a processto ensure exclusive accessto a shared memory segment.
Asserting both IPC_CREAT and IPC_EXCL in shmf l g only ensures(on success) that a new shared memory segment will be
created; it doesnt imply exclusive accessto the segment.
SEE ALSO
ftok(3), ipc(5), shmctl(2), shmat(2), shmdt(2)
Linux 0.99.11, 28 November 1993
shmop
shmopShared memory operations
SYNOPSIS
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
char *shmat ( int shmi d, char *shmaddr , int shmf l g );
int shmdt ( char *shmaddr );
DESCRIPTION
The function shmat attachesthe shared memory segment identified by shmid to the data segment of the calling process. The
attaching addressisspecified by shmaddr with one of the following criteria:
I If shmaddr is0, the system triesto find an unmapped region in the range 11.5GB, starting from the upper value and
coming down from there.
I If shmaddr isnt 0 and SHM_RND isasserted in shmflg, the attach occursat the addressequal to the rounding down of
shmaddr to a multiple of SHMLBA. Otherwise, shmaddr must be a page-aligned addressat which the attach occurs.
If SHM RDONLY isasserted in shmf l g, the segment isattached for reading, and the processmust have read accesspermissionsto
the segment. Otherwise the segment isattached for read and write, and the processmust have read and write access
permissionsto the segment. There isno notion of a write-only shared memory segment.
The brk value of the calling processisnot altered by the attach. The segment will automatically be detached at processexit.
The same segment may be attached asa read and asa read-write segment, more than once, in the processsaddressspace.
shmop
Part II: SystemCalls
854
On a successful shmat call, the system updatesthe membersof the structure shmid_ds associated to the shared memory
segment asfollows:
I shm_atime isset to the current time.
I shm_lpid isset to the processID of the calling process.
I shm_nattch isincremented by 1.
Note that the attachment will also succeed if the shared memory segment ismarked to be deleted.
The function shmdt detachesfrom the calling processsdata segment the shared memory segment located at the address
specified by shmaddr. The detaching shared memory segment must be one among the currently attached ones(to the
processsaddressspace) with shmaddr equal to the value returned by itsattaching shat call.
On a successful shmdt call, the system updatesthe membersof the structure shmid_ds associated to the shared memory
segment asfollows:
I shm_dtime isset to the current time.
I shm_lpid isset to the processID of the calling process.
I shm_nattch isdecremented by 1. If it becomes0 and the segment ismarked for deletion, the segment isdeleted.
The occupied region in the user space of the calling processisunmapped.
SYSTEM CALLS
fork() After a fork(), the child inheritsthe attached shared memory segments.
exec() After an exec(), all attached shared memory segmentsare detached (not destroyed).
exit() On exit(), all attached shared memory segmentsare detached (not destroyed).
RETURN VALUE
On a failure, both functionsreturn 1 with errno indicating the error; otherwise, shmat returnsthe addressof the attached
shared memory segment, and shmdt returns0.
ERRORS
When shmat fails, at return errno will be set to one of the following values:
EACCES The calling processhasno accesspermissionsfor the requested attach type.
EINVAL Invalid shmi d value, unaligned (that is, not page-aligned and SHM_RND wasnot specified) or invalid
shmaddr value, or failing attach at brk.
ENOMEM Could not allocate memory for the descriptor or for the page tables.
The function shmdt can fail only if there isno shared memory segment attached at shmaddr ; in such a case, errno will be set to
EINVAL at return.
NOTES
On executing a fork(2) system call, the child inheritsall the attached shared memory segments.
The shared memory segmentsattached to a processexecuting anexec(2) system call will not be attached to the resulting
process.
The following isa system parameter affecting a shmat system call:
SHMLBA Segmentslow-boundary addressmultiple. Must be page aligned. For the current implementation,
the SHMBLA value isPAGE_SIZE.
The implementation hasno intrinsic limit to the per-processmaximum number of shared memory segments(SHMSEG)
SEE ALSO
ipc(5), shmctl(2), shmget(2)
Linux 0.99.13, 28 November 1993
855
shutdown
shutdownShutsdown part of a full-duplex connection
SYNOPSIS
#include <sys/socket.h>
int shutdown(int s,int how);
DESCRIPTION
The shutdown call causesall or part of a full-duplex connection on the socket associated with s to be shut down. If how is0,
further receiveswill be disallowed. If how is1, further sendswill be disallowed. If how is2, further sendsand receiveswill be
disallowed.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EBADF s isnot a valid descriptor.
ENOTSOCK s isa file, not a socket.
ENOTCONN The specified socket isnot connected.
HISTORY
The shutdown function call appeared in BSD 4.2.
SEE ALSO
connect(2), socket(2)
BSD Man Page, 24 July1993
sigaction, sigprocmask, sigpending, sigsuspend
sigaction, sigprocmask, sigpending, sigsuspendPOSIX signal-handling functions.
SYNOPSIS
#include <signal.h>
int sigaction(int si gnum, const struct sigaction *act , struct sigaction *ol dact );
int sigprocmask(int how, const sigset_t *set , sigset_t *ol dset );
int sigpending(sigset_t *set );
int sigsuspend(const sigset_t *mask);
DESCRIPTION
The sigaction system call isused to change the action taken by a processon receipt of a specific signal.
si gnum specifiesthe signal and can be any valid signal except SIGKILL and SIGSTOP.
If act isnonnull, the new action for signal signum isinstalled from act . If ol dact isnonnull, the previousaction issaved in
ol dact .
The sigaction structure isdefined as
struct sigaction {
void (*sa_handler)(int);
sigset_t sa_mask;
int sa_flags;
sigaction, sigprocmask, sigpending, sigsuspend
Part II: SystemCalls
856
void (*sa_restorer)(void);
}
sa_handler specifiesthe action to be associated with si gnum and can be SIG_DFL for the default action, SIG_IGN to ignore this
signal, or a pointer to a signal-handling function.
sa_mask givesa mask of signalsthat should be blocked during execution of the signal handler. In addition, the signal that
triggered the handler will be blocked unlessthe SA_NODEFER or SA_NOMASK flag isused.
sa_flags specifiesa set of flagsthat modify the behavior of the signal-handling process. It isformed by the bitwise OR of zero
or more of the following:
SA_NOCLDSTOP If si gnum isSIGCHLD, do not receive notification when child processesstop (that is, when
child processesreceive one of SIGSTOP, SIGTSTP, SIGTTIN, or SIGTTOU).
SA_ONESHOT or SA_RESETHAND Restoresthe signal action to the default state once the signal handler hasbeen called.
(Thisisthe default behavior of the signal(2) system call.)
SA_RESTART Providesbehavior compatible with BSD signal semanticsby making certain system calls
restartable acrosssignals.
SA_NOMASK or SA_NODEFER Doesnot prevent the signal from being received from within itsown signal handler.
The sa_restorer element isobsolete and should not be used.
The sigprocmask call isused to change the list of currently blocked signals. The behavior of the call isdependent on the value
of how, asfollows:
SIG_BLOCK The set of blocked signalsisthe union of the current set and the set argument.
SIG_UNBLOCK The signalsin set are removed from the current set of blocked signals. It islegal to
attempt to unblock a signal that isnot blocked.
SIG_SETMASK The set of blocked signalsisset to the argument set .
If ol dset isnonnull, the previousvalue of the signal mask isstored in ol dset .
The sigpending call allowsthe examination of pending signals(those that have been raised while blocked). The signal mask
of pending signalsisstored in set .
The sigsuspend call temporarily replacesthe signal mask for the processwith that given by mask and then suspendsthe
processuntil a signal isreceived.
RETURN VALUES
sigaction, sigprocmask, sigpending, and sigsuspend return 0 on successand -1 on error.
ERRORS
EINVAL An invalid signal wasspecified. Thiswill also be generated if an attempt ismade to
change the action for SIGKILL or SIGSTOP, which cannot be caught.
EFAULT act , ol dact , set , or ol dset pointsto memory that isnot a valid part of the process
addressspace.
EINTR System call wasinterrupted.
NOTES
It isnot possible to block SIGKILL or SIGSTOP with the sigprocmask call. Attemptsto do so will be silently ignored.
Setting SIGCHLD to SIG_IGN providesautomatic reaping of child processes.
The POSIX spec only definesSA_NOCLDSTOP. Use of other sa flagsisnonportable.
The SA_RESETHAND flag iscompatible with the SVR4 flag of the same name.
857
The SA_NODEFER flag iscompatible with the SVR4 flag of the same name under kernels1.3.9 and newer. On older kernels, the
Linux implementation will allow the receipt of any signal, not just the one you are installing (effectively overriding any
sa_mask settings).
The SA_RESETHAND and SA_NODEFER namesfor SVR4 compatibility are present only in library versions3.0.9 and greater.
sigaction can be called with a null second argument to query the current signal handler. It can also be used to check whether
a given signal isvalid for the current machine by calling it with null second and third arguments.
See sigsetops(3) for detailson manipulating signal sets.
CONFORMS TO
POSIX, SVR4
SEE ALSO
kill(1), kill(2), killpg(2), pause(2), raise(3), siginterrupt(3), signal(2), signal(7), sigse-tops(3), sigvec(2)
Linux 1.3, 24 August 1995
signal
signalANSI C signal handling
SYNOPSIS
#include <signal.h>
void (*signal(int si gnum,void (*handl er )(int)))(int);
DESCRIPTION
The signal system call installsa new signal handler for the signal with number si gnum. The signal handler isset to handl er ,
which can be a user-specified function or one of the following:
SIG_IGN Ignoresthe signal.
SIG_DFL Resetsthe signal to itsdefault behavior.
The integer argument that ishanded over to the signal-handling routine isthe signal number. Thismakesit possible to use
one signal handler for several signals.
RETURN VALUE
signal returnsthe previousvalue of the signal handler, or SIG_ERR on error.
NOTES
Signal handlerscannot be set for SIGKILL or SIGSTOP.
Unlike on BSD systems, signalsunder Linux are reset to their default behavior when raised. However, if you include <bsd/
signal.h> instead of <signal.h>, signal isredefined as_bsd_signal, and signal hasthe BSD semantics. Both versionsof
signal are library routinesbuilt on top of sigaction(2).
If youre confused by the prototype at the top of thisman page, it may help to see it separated out like this:
typedef void (*sighandler_t)(int);
sighandler_t signal(int si gnum, sighandler_t handl er );
According to POSIX, the behavior of a processisundefined after it ignoresa SIGFPE, SIGILL, or SIGSEGV signal that wasnot
generated by the kill() or raise() function. Integer division by 0 hasundefined result. On some architecturesit will
generate a SIGFPE signal. Ignoring thissignal might lead to an endlessloop.
signal
Part II: SystemCalls
858
CONFORMS TO
ANSI C
SEE ALSO
kill(1), kill(2), killpg(2), pause(2), raise(3), sigaction(2), signal(7), sigsetops(3), sigvec(2), alarm(2)
Linux 2.0, 21 July1996
sigblock, siggetmask, sigsetmask, sigmask
sigblock, siggetmask, sigsetmask, sigmaskManipulate the signal mask
SYNOPSIS
#include <signal.h>
int sigblock(int mask);
int siggetmask(void);
int sigsetmask(int mask);
int sigmask(int si gnum);
DESCRIPTION
Thisinterface ismade obsolete by sigprocmask(2).
The sigblock system call addsthe signalsspecified in mask to the set of signalscurrently being blocked from delivery.
The sigsetmask system call replacesthe set of blocked signalstotally with a new set specified in mask. Signalsare blocked if
the corresponding bit in mask isa 1.
The current set of blocked signalscan be obtained using siggetmask.
The sigmask macro isprovided to construct the mask for a given si gnum.
RETURN VALUES
siggetmask returnsthe current set of masked signals.
sigsetmask and sigblock return the previousset of masked signals.
NOTES
Prototypesfor these functionsare only available if __USE_BSD isdefined before <signal.h> isincluded.
It isnot possible to block SIGKILL or SIGSTOPthisrestriction issilently imposed by the system.
HISTORY
These function callsappeared in BSD 4.3 and are deprecated.
SEE ALSO
kill(2), sigprocmask(2), signal(7)
Linux 1.3, 31 August 1995
sigpause
sigpauseAtomically releasesblocked signalsand waitsfor interrupt
859
SYNOPSIS
#include <signal.h>
int sigpause(int si gmask );
DESCRIPTION
Thisinterface ismade obsolete by sigsuspend(2).
sigpause assignssi gmask to the set of masked signalsand then waitsfor a signal to arrive; on return, the set of masked signals
isrestored.
sigmask isusually 0 to indicate that no signalsare to be blocked. sigpause alwaysterminatesby being interrupted, returning
1 with errno set to EINTR.
HISTORY
The sigpause function call appeared in BSD 4.3 and isdeprecated.
SEE ALSO
sigsuspend(2), kill(2), sigaction(2), sigprocmask(2), sigblock(2), sigvec(2)
Linux 1.3, 24 July1993
sigreturn
sigreturnReturnsfrom the signal handler and cleansup the stack frame
SYNOPSIS
int sigreturn(unsigned long __unused);
DESCRIPTION
When the Linux kernel createsthe stack frame for a signal handler, a call to sigreturn isinserted into the stack frame so that
the signal handler will call sigreturn upon return. Thisinserted call to sigreturn cleansup the stack so that the processcan
restart from where it wasinterrupted by the signal.
RETURN VALUE
sigreturn never returns.
WARNING
The sigreturn call isused by the kernel to implement signal handlers. It should never be called directly. Better yet, the
specific use of the unused argument variesdepending on the architecture.
CONFORMS TO
sigreturn isspecific to Linux.
FILES
/usr/src/linux/arch/i386/kernel/signal.c
/usr/src/linux/arch/alpha/kernel/entry.S
SEE ALSO
kill(2), signal(2), signal(7)
Linux 1.3.20, 21 August 1995
sigreturn
Part II: SystemCalls
860
sigvec
sigvecBSD software signal facilities
SYNOPSIS
#include <bsd/signal.h>
int sigvec(int si g, struct sigvec *vec, struct sigvec *ovec);
DESCRIPTION
Thisinterface ismade obsolete by sigaction(2).
Under Linux, sigvec is#defined to sigaction, and providesat best a rough approximation of the BSD sigvec interface.
SEE ALSO
sigaction(2), signal(2)
Linux 1.3 31 August 1995
socket
socketCreatesan endpoint for communication
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int socket(int domai n,intt ype, int pr ot ocol );
DESCRIPTION
socket createsan endpoint for communication and returnsa descriptor.
The domai n parameter specifiesa communicationsdomain within which communication will take place; thisselectsthe
protocol family that should be used. These familiesare defined in the include file sys/socket.h. The currently understood
formatsare
AF_UNIX UNIX internal protocols
AF_INET ARPA Internet protocols
AF_ISO ISO protocols
AF_NS Xerox Network Systemsprotocols
AF_IMPLINK IMP host at IMP link layer
The socket hasthe indicated type, which specifiesthe semanticsof communication. The currently defined typesare
SOCK_STREAM
SOCK_DGRAM
SOCK_RAW
SOCK_SEQPACKET
SOCK_RDM
A SOCK_STREAM type providessequenced, reliable, two-way connectionbased byte streams. An out-of-band data transmission
mechanism may be supported. A SOCK_DGRAM socket supportsdatagrams(connectionless, unreliable messagesof a fixed,
typically small, maximum length). A SOCK_SEQPACKET socket may provide a sequenced, reliable, two-way connectionbased
data transmission path for datagramsof fixed maximum length; a consumer might be required to read an entire packet with
each read system call. Thisfacility isprotocol specific, and presently isimplemented only for PF_NS. SOCK_RAW socketsprovide
861
accessto internal network protocolsand interfaces. The typesSOCK_RAW, which isavailable only to the superuser, and
SOCK_RDM, which isplanned but not yet implemented, are not described here.
The pr ot ocol specifiesa particular protocol to be used with the socket. Normally only a single protocol existsto support a
particular socket type within a given protocol family. However, it ispossible that many protocolsmay exist, in which case a
particular protocol must be specified in thismanner. The protocol number to use isparticular to the communication domain
in which communication isto take place; see protocols(5).
Socketsof type SOCK_STREAM are full-duplex byte streams, similar to pipes. A stream socket must be in a connected state before
any data can be sent or received on it. A connection to another socket iscreated with a connect(2) call. Once connected, data
may be transferred using read(2) and write(2) callsor some variant of the send(2) and recv(2) calls. When a session hasbeen
completed, a close(2) may be performed. Out-of-band data can also be transmitted asdescribed in send(2) and received as
described in recv(2).
The communicationsprotocolsused to implement a SOCK_STREAM ensure that data isnot lost or duplicated. If a piece of data
for which the peer protocol hasbuffer space cannot be successfully transmitted within a reasonable length of time, the
connection isconsidered broken, and callswill indicate an error with 1 returnsand with ETIMEDOUT asthe specific code in the
global variable errno. The protocolsoptionally keep socketswarm by forcing transmissionsroughly every minute in the
absence of other activity. An error isthen indicated if no response can be elicited on an otherwise idle connection for a
extended period (for example, 5 minutes). A SIGPIPE signal israised if a processsendson a broken stream; thiscausesnaive
processes, which do not handle the signal, to exit.
SOCK_SEQPACKET socketsemploy the same system callsasSOCK_STREAM sockets. The only difference isthat read(2) callswill
return only the amount of data requested, and any that isremaining in the arriving packet will be discarded.
SOCK_DGRAM and SOCK_RAW socketsallow the sending of datagramsto correspondentsnamed in send(2) calls. Datagramsare
generally received with recvfrom(2), which returnsthe next datagram with itsreturn address.
An fcntl(2) call can be used to specify a processgroup to receive a SIGURG signal when the out-of-band data arrives. It can
also enable non-blocking I/O and asynchronousnotification of I/O eventsvia SIGIO.
The operation of socketsiscontrolled by socket-level options. These optionsare defined in the file sys/socket.h.
setsockopt(2) and getsockopt(2) and are used to set and get options, respectively.
RETURN VALUES
A 1 isreturned if an error occurs; otherwise, the return value isa descriptor referencing the socket.
ERRORS
EPROTONOSUPPORT The protocol type or the specified protocol isnot supported within thisdomain.
EMFILE The per-processdescriptor table isfull.
ENFILE The system file table isfull.
EACCESS Permission to create a socket of the specified type and/or protocol isdenied.
ENOBUFS Insufficient buffer space isavailable. The socket cannot be created until sufficient resourcesare
freed.
HISTORY
The socket function call appeared in BSD 4.2.
SEE ALSO
accept(2), bind(2), connect(2), getprotoent(3), getsockname(2), getsockopt(2), ioctl(2), listen(2), read(2), recv(2),
select(2), send(2), shutdown(2), socketpair(2), write(2)
An Introductory 4.3 BSD InterprocessCommunication Tutorial isreprinted in UNIX ProgrammersSupplementary
DocumentsVolume 1
BSD InterprocessCommunication Tutorial isreprinted in UNIX ProgrammersSupplementary DocumentsVolume 1
BSD Man Page, 24 July1993
socket
Part II: SystemCalls
862
socketcall
socketcallSocket system calls
SYNOPSIS
int socketcall(int cal l , unsigned long *ar gs );
DESCRIPTION
socketcall isa common kernel entry point for the socket system calls. cal l determineswhich socket function to invoke. ar gs
pointsto a block containing the actual arguments, which are passed through to the appropriate call.
User programsshould call the appropriate functionsby their usual names. Only standard library implementorsand kernel
hackersneed to know about socketcall.
SEE ALSO
accept(2), bind(2), connect(2), getpeername(2), getsockname(2), getsockopt(2), listen(2), recv(2), recvfrom(2), send(2),
sendto(2), setsockopt(2), shutdown(2), socket(2), socketpair(2)
Linux 1.2.4, 15 April 1995
socketpair
socketpairCreatesa pair of connected sockets
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int socketpair(int d, int t ype, int pr ot ocol , int sv[2]);
DESCRIPTION
The call createsan unnamed pair of connected socketsin the specified domain d, of the specified t ype, and using the
optionally specified pr ot ocol . The descriptorsused in referencing the new socketsare returned in sv[0] and sv[1]. The two
socketsare indistinguishable.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EMFILE Too many descriptorsare in use by thisprocess.
EAFNOSUPPORT The specified addressfamily isnot supported on thismachine.
EPROTONOSUPPORT The specified protocol isnot supported on thismachine.
EOPNOSUPPORT The specified protocol doesnot support creation of socket pairs.
EFAULT The addresssv doesnot specify a valid part of the processsaddressspace.
HISTORY
The socketpair function call appeared in BSD 4.2.
BUGS
Thiscall iscurrently implemented only for the UNIX domain.
863
SEE ALSO
read(2), write(2), pipe(2)
BSD Man Page, 24 July1993
stat, fstat, lstat
stat, fstat, lstatGet file status
SYNOPSIS
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *f i l e_name,struct stat *buf );
int fstat(int f i l edes ,struct stat *buf );
int lstat(const char *f i l e_name, struct stat *buf );
DESCRIPTION
These functionsreturn information about the specified file. You do not need any accessrightsto the file to get this
information, but you need search rightsto all directoriesnamed in the path leading to the file.
stat statsthe file pointed to by f i l e_name and fillsin buf .
lstat isidentical to stat, except that the link itself isstated, not the file that isobtained by tracing the links.
fstat isidentical to stat, except that the open file pointed to by f i l edes (asreturned by open(2)) isstated in place of
f i l e_name.
They all return a stat structure, which isdeclared asfollows:
struct stat
{
dev_t st _dev; /* device */
ino_t st _i no; /* inode */
umode_t st _mode; /*protection */
nlink_t st _nl i nk ; /* number of hard links */
uid_t st _ui d; /* user ID of owner */
gid_t st _gi d; /* group ID of owner */
dev_t st _r dev; /* device type (if inode device) */
off_t st _si ze; /* total size, in bytes */
unsigned long st _bl ksi ze; /* blocksize for filesystem I/O */
unsigned long st _bl ocks; /* number of blocks allocated */
time_t st _at i me; /* time of last access */
time_t st _mt i me; /* time of last modification */
time_t st _ct i me; /* time of last change */
};
Note that st _bl ocks may not alwaysbe in termsof blocksof size st _bl ksi ze, and that st _bl ksi ze may instead provide a
notion of the preferred block size for efficient filesystem I/O.
Not all the Linux filesystemsimplement all the time fields. Traditionally, st _at i me ischanged by mknod(2), utime(2), read(2),
write(2), and truncate(2).
Traditionally, st _mt i me ischanged by mknod(2), utime(2), and write(2). st _mt i me isnot changed for changesin owner, group,
hard link count, or mode.
Traditionally, st _ct i me ischanged by writing or by setting inode information (that is, owner, group, link count, mode, and
so on).
stat, fstat, lstat
Part II: SystemCalls
864
The following macrosare defined to check the file type:
S_ISLNK(m) Isit a symbolic link?
S_ISREG(m) Isit a regular file?
S_ISDIR(m) Isit a directory?
S_ISCHR(m) Isit a character device?
S_ISBLK(m) Isit a block device?
S_ISFIFO(m) Isit fifo?
S_ISSOCK(m) Isit a socket?
The following flagsare defined for the st _mode field:
S_IFMT 00170000 Bitmask for the file type bitfields
S_IFSOCK 0140000 Socket
S_IFLNK 0120000 Symbolic link
S_IFREG 0100000 Regular file
S_IFBLK 0060000 Block device
S_IFDIR 0040000 Directory
S_IFCHR 0020000 Character device
S_IFIFO 0010000 Fifo
S_ISUID 0004000 Set UID bit
S_ISGID 0002000 Set GID bit
S_ISVTX 0001000 Sticky bit
S_IRWXU 00700 User (file owner) hasread, write, and execute permission
S_IRUSR (S_IREAD) 00400 User hasread permission
S_IWUSR (S_IWRITE) 00200 User haswrite permission
S_IXUSR (S_IEXEC) 00100 User hasexecute permission
S_IRWXG 00070 Group hasread, write, and execute permission
S_IRGRP 00040 Group hasread permission
S_IWGRP 00020 Group haswrite permission
S_IXGRP 00010 Group hasexecute permission
S_IRWXO 00007 othershave read, write, and execute permission
S_IROTH 00004 Othershave read permission
S_IWOTH 00002 Othershave write permission
S_IXOTH 00001 Othershave execute permission
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EBADF f i l edes isbad.
ENOENT File doesnot exist.
CONFORMS TO
SVID (not lstat()), AT&T (not lstat()), POSIX (not lstat()), X/OPEN (not lstat()), BSD 4.3
SEE ALSO
chmod(2), chown(2), readlink(2), utime(2)
Linux 1.1.75, 1 January1995
865
statfs, fstatfs
statfs, fstatfsGet filesystem statistics
SYNOPSIS
#include <sys/vfs.h>
int statfs(const char *pat h, struct statfs *buf );
int fstatfs(int f d, struct statfs *buf );
DESCRIPTION
statfs returnsinformation about a mounted filesystem. pat h isthe pathname of any file within the mounted filesystem. buf
isa pointer to a statfs structure defined asfollows:
struct statfs {
long f_type; /* type of filesystem (see below) */
long f_bsize; /* optimal transfer block size */
long f_blocks; /* total data blocks in filesystem */
long f_bfree; /* free blocks in fs */
long f_bavail; /* free blocks avail to non-superuser */
long f_files; /* total file nodes in filesystem */
long f_ffree; /* free file nodes in fs */
fsid_t f_fsid; /* filesystem id */
long f_namelen; /* maximum length of filenames */
long f_spare[6]; /* spare for later */
};
Filesystem types:
linux/ext2_fs.h: EXT2_OLD_SUPER_MAGIC 0xEF51
linux/ext2_fs.h: EXT2_SUPER_MAGIC 0xEF53
linux/ext_fs.h: EXT_SUPER_MAGIC 0x137D
linux/iso_fs.h: ISOFS_SUPER_MAGIC 0x9660
linux/minix_fs.h: MINIX_SUPER_MAGIC 0x137F /* orig. minix */
linux/minix_fs.h: MINIX_SUPER_MAGIC2 0x138F /* 30 char minix */
linux/minix_fs.h: NEW_MINIX_SUPER_MAGIC 0x2468 /* minix V2 */
linux/msdos_fs.h: MSDOS_SUPER_MAGIC 0x4d44
linux/nfs_fs.h: NFS_SUPER_MAGIC 0x6969
linux/proc_fs.h: PROC_SUPER_MAGIC 0x9fa0
linux/xia_fs.h: XIAFS_SUPER_MAGIC 0x012FD16D
Fieldsthat are undefined for a particular filesystem are set to 1. fstatfs returnsthe same information about an open file
referenced by descriptor f d.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
For statfs:
ENOTDIR A component of the path prefix of pat h isnot a directory.
EINVAL pat h containsa character with the high-order bit set.
ENAMETOOLONG The length of a component of pat h exceeds255 characters, or the length of pat h exceeds1,023
characters.
ENOENT The file referred to by pat h doesnot exist.
EACCES Search permission isdenied for a component of the path prefix of pat h.
ELOOP Too many symbolic linkswere encountered in translating pat h.
statfs, fstatfs
Part II: SystemCalls
866
EFAULT buf or pat h pointsto an invalid address.
EIO An I/O error occurred while reading from or writing to the filesystem.
For fstatfs:
EBADF f d isnot a valid open file descriptor.
EFAULT buf pointsto an invalid address.
EIO An I/O error occurred while reading from or writing to the filesystem.
SEE ALSO
stat(2)
Linux 0.99.11, 24 July1993
stime
stimeSet time
SYNOPSIS
#include <time.h>
int stime(time_t *t );
DESCRIPTION
stime setsthe systemsidea of the time and date. time, pointed to by t , ismeasured in secondsfrom 00:00:00 GMT January
1, 1970. stime() may only be executed by the superuser.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM The caller isnot the superuser.
CONFORMS TO
SVID, AT&T, X/OPEN
SEE ALSO
date(1)
Linux 0.99.11, 24 July1993
swapon, swapoff
swapon, swapoffStart/stop swapping to file/device
SYNOPSIS
#include <unistd.h>
#include <linux/swap.h>
int swapon(const char *pat h, int swapf l ags);
int swapoff(const char *pat h);
867
DESCRIPTION
swapon setsthe swap area to the file or block device specified by pat h. swapoff stopsswapping to the file or block device
specified by pat h.
swapon takesa swapf l ags argument. If swapf l ags hasthe SWAP_FLAG_PREFER bit turned on, the new swap area will have a higher
priority than default. The priority isencoded as(prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK. These functions
may only be used by the superuser.
PRIORITY
Each swap area hasa priority, either high or low. The default priority islow. Within the low-priority areas, newer areasare of
even lower priority than older areas.
All prioritiesset with swapf l ags are high priority, higher than the default. They may have any non-negative value chosen by
the caller. Higher numbersmean higher priority.
Swap pagesare allocated from areasin priority order, highest priority first. For areaswith different priorities, a higher-
priority area isexhausted before using a lower-priority area. If two or more areashave the same priority, and that isthe
highest priority available, pagesare allocated on a round-robin basisbetween them.
Asof Linux 1.3.6, the kernel usually followsthese rules, but there are exceptions.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
Many other errorsbesidesthe following can occur if path isnot valid:
EPERM The user isnot the superuser, or more than MAX_SWAPFILES (defined to be 8 in Linux 1.3.6) are in
use.
EINVAL Returned if pat h exists, but isneither a regular path nor a block device.
ENOENT Returned if pat h doesnot exist.
ENOMEM Returned if there isinsufficient memory to start swapping.
CONFORMS TO
These functionsare Linux specific.
NOTES
The partition or path must be prepared with mkswap(8).
HISTORY
The second (swapflags) argument wasintroduced in Linux 1.3.2.
SEE ALSO
mkswap(8), swapon(8), swapoff(8)
Linux 1.3.6, 22 July1995
symlink
symlinkMakesa new name for a file
symlink
Part II: SystemCalls
868
SYNOPSIS
#include <unistd.h>
int symlink(const char *ol dpat h, const char *newpat h);
DESCRIPTION
symlink createsa symbolic link named ol dpat h that containsnewpat h.
Symbolic linksare interpreted at runtime, asif the contentsof the link were substituted into the path being followed to find
a file or directory.
Symbolic linksmay contain .. path componentsthat (if used at the start of the link) refer to the parent directoriesof the one
in which the link resides.
A symbolic link (also known asa soft link) can point to an existing file or to a nonexistent one; the latter case isknown asa
danglinglink.
The permissionsof a symbolic link are irrelevant; the ownership isignored when following the link, but ischecked when
removal or renaming of the link isrequested and the link isin a directory with the sticky bit set.
If newpat h exists, it will not be overwritten.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM The filesystem containing pat hname doesnot support the creation of symbolic links.
EFAULT ol dpat h or newpat h pointsoutside your accessible addressspace.
EACCES Write accessto the directory containing newpat h isnot allowed for the processseffective UID, or
one of the directoriesin newpat h did not allow search (execute) permission.
ENAMETOOLONG ol dpat h or newpat h wastoo long.
ENOENT A directory component in newpat h doesnot exist or isa dangling symbolic link, or ol dpat h isthe
empty string.
ENOTDIR A component used asa directory in newpat h isnot, in fact, a directory.
ENOMEM Insufficient kernel memory wasavailable.
EROFS The file ison a read-only filesystem.
EEXIST newpat h already exists.
ELOOP newpat h containsa reference to a circular symbolic linkthat is, a symbolic link whose expansion
containsa reference to itself.
ENOSPC The device containing the file hasno room for the new directory entry.
NOTES
No checking of ol dpat h isdone.
Deleting the name referred to by a symlink will actually delete the file (unlessit also hasother hard links). If thisbehavior is
not desired, use link.
CONFORMS TO
SVID, AT&T, POSIX, BSD 4.3
BUGS
See open(2) regarding multiple fileswith the same name, and NFS.
869
SEE ALSO
link(2), unlink(2), rename(2), open(2), lstat(2), ln(1), link(8)
Linux, 24 July1993
sync
syncCommitsbuffer cache to disk
SYNOPSIS
#include <unistd.h>
int sync(void);
DESCRIPTION
sync first commitsinodesto buffers, and then buffersto disk.
RETURN VALUE
sync alwaysreturns0.
CONFORMS TO
SVID, AT&T, X/OPEN, BSD 4.3
BUGS
According to the standard specification (for example, SVID), sync() schedulesthe writes, but it might return before the
actual writing isdone. However, since version 1.3.20, Linux doesactually wait. (Thisstill doesnot guarantee data integrity;
modern diskshave large caches.)
SEE ALSO
bdflush(2), fsync(2), fdatasync(2), update(8), sync(8)
Linux 1.3.88, 15 April 1995
sysctl
sysctlReads/writessystem parameters
SYNOPSIS
#include <unistd.h>
#include <linux/unistd.h>
#include <linux/sysctl.h>
_syscall1(int_sysct l , struct __sysctl_args *ar gs);
int sysctl(struct __sysctl_args *ar gs);
DESCRIPTION
The sysctl call readsand/or writeskernel parametersfor example, the hostname or the maximum number of open files.
The argument hasthe form
struct __sysctl__args {
int *name; /* integer vector describing variable */
int nlen; /* length of this vector */
void *oldval; /* 0 or address where to store old value */
size_t *oldlenp; /* available room for old value,
sysctl
Part II: SystemCalls
870
overwritten by actual size of old value */
void *newval; /* 0 or address of new value */
size_t newlen; /* size of new value */
};
Thiscall doesa search in a tree structure, possibly resembling a directory tree under /proc/sys, and, if the requested item is
found, callssome appropriate routine to read or modify the value.
EXAMPLE
#include <linux/unistd.h>
#include <linux/types.h>
#include <linux/sysctl.h>
_syscall1(int, _sysctl, struct __sysctl args *, args);
int sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
void *newval, size_t newlen)
{
struct __sysctl__args args={name,nlen,oldval,oldlenp,newval,newlen};
return _sysctl(&args);
}
#define SIZE(x) sizeof(x)/sizeof(x[0])
#define OSNAMESZ 100
char osname[OSNAMESZ];
int osnamelth;
int name[] = { CTL_KERN, KERN_OSTYPE };
main(){
osnamelth = SIZE(osname);
if (sysctl(name, SIZE(name), osname, &osnamelth, 0, 0))
perror(sysctl);
else
printf(This machine is running %*s\n, osnamelth, osname);
return 0;
}
RETURN VALUES
Upon successful completion, sysctl returns0. Otherwise, a value of 1 isreturned, and errno isset to indicate the error.
ERRORS
ENOTDIR name wasnot found.
EPERM No search permission for one of the encountered directories, or no read permission where ol dval
wasnonzero, or no write permission where newval wasnonzero.
EFAULT The invocation asked for the previousvalue by setting ol dval non-NULL, but allowed zero room
in ol dl enp.
CONFORMS TO
Thiscall isLinux specific.
HISTORY
A sysctl call hasbeen present in Linux since version 1.3.57. It originated in BSD-4.4. Only Linux hasthe /proc/sys mirror,
and the object-naming schemesdiffer between Linux and BSD 4.4, but the declaration of the sysctl(2) function isthe same
in both.
871
BUGS
Not all available objectsare properly documented.
It isnot yet possible to change operating system by writing to /proc/sys/kernel/ostype.
SEE ALSO
proc(5)
Linux 1.3.85, 11 April 1996
sysfs
sysfsGetsfilesystem type information
SYNOPSIS
int sysfs(int opt i on, const char * f sname);
int sysfs(int opt i on, unsigned int f s_i ndex , char * buf );
int sysfs(int opt i on);
DESCRIPTION
sysfs returnsinformation about the filesystem typescurrently present in the kernel. The specific form of the sysfs call and
the information returned depend on the option in effect. You can
I Translate the filesystem identifier string f sname into a filesystem type index.
I Translate the filesystem type index f s_i ndex into a null-terminated filesystem identifier string. Thisstring will be written
to the buffer pointed to by buf . Make sure that buf hasenough space to accept the string.
I Return the total number of filesystem typescurrently present in the kernel.
The numbering of the filesystem type indexesbeginswith 0.
RETURN VALUE
On success, sysfs returnsthe filesystem index for the first option, 0 for the second option, and the number of currently
configured filesystemsfor the third option. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EINVAL f sname isnot a valid filesystem type identifier; f s_i ndex isout of bounds; opt i on isinvalid.
EFAULT Either f sname or buf isoutside your accessible addressspace.
CONFORMS TO
System V
Linux 1.3.16, 9 August 1995
sysinfo
sysinfoReturnsinformation on overall system statistics
SYNOPSIS
Asof Linux 0.99.10 and image release 4.4,
#include <linux/kernel.h>
#include <linux/sys.h>
int sysinfo(struct sysinfo *i nf o);
sysinfo
Part II: SystemCalls
872
DESCRIPTION
sysinfo returnsinformation in the following structure:
struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
char _f[22]; /* Pads structure to 64 bytes */
};
sysinfo providesa simple way of getting overall system statistics. Thisismore portable than reading /dev/kmem.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EFAULT The pointer to st r uct sysi nf o isinvalid.
CONFORMS TO
Thisfunction isLinux specific.
BUGS
The Linux DLL 4.4.1 librariesdo not contain a proper prototype for thisfunction.
Linux 0.99.10, 24 July1993
syslog
syslogReadsand/or clearskernel message ring buffer; setsconsole_loglevel
SYNOPSIS
#include <unistd.h>
#include <linux/unistd.h>
_syscall3(int sysl og, int t ype, char *buf p, int l en);
int syslog(int t ype, char *buf p, int l en);
DESCRIPTION
Thisisprobably not the function you are interested in. Look at syslog(3) for the C library interface. Thispage only
documentsthe bare kernel system call interface.
The t ype argument determinesthe action taken by syslog.
From kernel/printk.c:/*
Valid commandsto syslog are
0Close the log. Currently a NOP.
1Open the log. Currently a NOP.
2Read from the log.
873
3Read up to the last 4KB of messagesin the ring buffer.
4Read and clear last 4KB of messagesin the ring buffer.
5Clear ring buffer.
6Disable printksto console.
7Enable printksto console.
8Set level of messagesprinted to console.
Only function 3 isallowed to non-root processes.
THE KERNEL LOG BUFFER
The kernel hasa cyclic buffer of length LOG_BUF_LEN (4096) in which messagesgiven asargument to the kernel function
printk() are stored (regardlessof their loglevel).
The call syslog (2,buf ,l en) waitsuntil thiskernel log buffer isnonempty, and then readsat most l en bytesinto the buffer
buf . It returnsthe number of bytesread. Bytesread from the log disappear from the log buffer; the information can only be
read once. Thisisthe function executed by the kernel when a user program reads/proc/kmsg.
The call syslog (3,buf ,l en) will read the last l en bytesfrom the log buffer (nondestructively), but will not read more than
waswritten into the buffer since the last clear ring buffer command (which doesnot clear the buffer at all). It returnsthe
number of bytesread.
The call syslog (4,buf ,l en) doesprecisely the same, but also executesthe clear ring buffer command.
The call syslog (5,dummy ,i dummy) only executesthe clear ring buffer command.
THE LOGLEVEL
The kernel routine printk() will print a message on the console only if it hasa loglevel lessthan the value of the variable
consol e_l ogl evel (initially DEFAULT_CONSOLE_LOGLEVEL (7), but set to 10 if the kernel command line containsthe word debug,
and to 15 in case of a kernel faultthe 10 and 15 are just silly, and are equivalent to 8). Thisvariable isset (to a value in the
range 18) by the call syslog (8,dummy,val ue). The call syslog (type,dummy,i dummy ) with type equal to 6 or 7, setsit to 1
(kernel panicsonly) or 7 (all except debugging messages), respectively.
Every text line in a message hasitsown loglevel. Thislevel isDEFAULT_MESSAGE_LOGLEVEL-1 (6) unlessthe line startswith <d>
where d isa digit in the range 17, in which case the level isd. The conventional meaning of the loglevel isdefined in <linux/
kernel.h> asfollows:
#define KERN_EMERG <0> /* system is unusable */
#define KERN_ALERT <1> /* action must be taken immediately */
#define KERN_CRIT <2> /* critical conditions */
#define KERN_ERR <3> /* error conditions */
#define KERN_WARNING <4> /* warning conditions */
#define KERN_NOTICE <5> /* normal but significant condition */
#define KERN_INFO <6> /* informational */
#define KERN_DEBUG <7> /* debug-level messages */
RETURN VALUE
In case of error, -1 isreturned, and errno isset. On success, for t ype equal to 2, 3, or 4, syslog() returnsthe number of bytes
read; otherwise, it returns0.
ERRORS
EPERM An attempt wasmade to change console_loglevel or clear the kernel message ring buffer by a
processwithout root permissions.
EINVAL Bad parameters.
ERESTARTSYS System call wasinterrupted by a signalnothing wasread.
syslog
Part II: SystemCalls
874
CONFORMS TO
Thissystem call isLinux specific.
SEE ALSO
syslog(3)
Linux 1.2.9, 11 June1995
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush,
tcflow, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed,
tcgetpgrp, tcsetpgrp
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed,
tcgetpgrp, tcsetpgrpGet and set terminal attributes, do line control, get and set baud rate, get and set terminal foreground
processgroup ID
SYNOPSIS
#include <termios.h>
#include <unistd.h>
int tcgetattr ( int f d, struct termios *t er mi os_p );
int tcsetattr ( int f d, int opt i onal _act i ons, struct termios *t er mi os_p );
int tcsendbreak ( int f d, int dur at i on );
int tcdrain ( int f d );
int tcflush ( int f d, int queue_sel ect or );
int tcflow ( int f d, int act i on );
speed_t cfgetospeed ( struct termios *t er mi os_p );
int cfsetospeed ( struct termios *t er mi os_p, speed_t speed );
speed_t cfgetispeed ( struct termios *t er mi os_p );
int cfsetispeed ( struct termios *t er mi os_p, speed_t speed );
pid_t tcgetpgrp ( int f d );
int tcsetpgrp ( int f d, pid_t pgr pi d );
DESCRIPTION
The termiosfunctionsdescribe a general terminal interface that isprovided to control asynchronouscommunicationsports.
Many of the functionsdescribed here have a t er mi os_p argument that isa pointer to a termios structure. Thisstructure
containsthe following members:
tcflag_t c_i f l ag; /* input modes */
tcflag_t c_of l ag; /* output modes */
tcflag_t c_cf l ag; /* control modes */
tcflag_t c_l f l ag;/*local modes*/
cc_t c_cc[NCCS]; /* control chars */
The following are the c_i f l ag flag constants:
IGNBRK Ignore BREAK condition on input.
BRKINT If IGNBRK isnot set, generate SIGINT on BREAK condition; otherwise, read BREAK ascharacter \0.
IGNPAR Ignore framing errorsand parity errors.
PARMRK If IGNPAR isnot set, prefix a character with a parity error or framing error with \377 \0. If neither
IGNPAR nor PARMRK isset, read a character with a parity error or framing error as\0.
INPCK Enable input parity checking.
875
ISTRIP Strip off the eighth bit.
INLCR Translate NL to CR on input.
IGNCR Ignore carriage return on input.
ICRNL Translate carriage return to newline on input (unlessIGNCR isset).
IUCLC Map uppercase charactersto lowercase on input.
IXON Enable XON/XOFF flow control on output.
IXANY Enable any character to restart output.
IXOFF Enable XON/XOFF flow control on input IMAXBEL ring bell when input queue isfull.
The following are the c_oflag flag constants:
OPOST Enable implementation-defined output processing.
OLCUC Map lowercase charactersto uppercase on output.
ONLCR Map NL to CR-NL on output.
OCRNL Map CR to NL on output.
ONOCR Dont output CR at column 0.
ONLRET Dont output CR.
OFILL Send fill charactersfor a delay rather than use a timed delay.
OFDEL Fill character isASCII DEL. If unset, fill character isASCII NUL.
NLDLY Newline delay mask. Valuesare NL0 and NL1.
CRDLY Carriage-return delay mask. Valuesare CR0, CR1, CR2, and CR3.
TABDLY Horizontal-tab delay mask. Valuesare TAB0, TAB1, TAB2, TAB3, and XTABS. A value of XTABS expands
tabsto spaces(with tab stopsevery eight columns).
BSDLY Backspace delay mask. Valuesare BS0 and BS1.
VTDLY Vertical-tab delay mask. Valuesare VT0 and VT1.
FFDLY Form-feed delay mask. Valuesare FF0 and FF1.
The following are the c_cflag flag constants:
CSIZE Character size mask. Valuesare CS5, CS6, CS7,and CS8.
CSTOPB Set two stop bitsrather than one.
CREAD Enable receiver.
PARENB Enable parity generation on output and parity checking for input.
PARODD Parity for input and output isodd.
HUPCL Lower modem control linesafter last processclosesthe device (hangsup).
CLOCAL Ignore modem control lines.
CIBAUD Mask for input speeds(not used).
CRTSCTS Flow control.
The following are the c_lflag flag constants:
ISIG When any of the charactersINTR, QUIT, SUSP, or DSUSP are received, generate the corresponding
signal.
ICANON Enablescanonical mode. Thisallowsthe special charactersEOF, EOL, EOL2, ERASE, KILL, REPRINT,
STATUS, and WERASE, and also buffersby lines.
XCASE If ICANON isalso set, terminal isuppercase only. Input isconverted to lowercase, except for
characterspreceded by \. On output, uppercase charactersare preceded by \, and lowercase
charactersare converted to uppercase.
ECHO Echo input characters.
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfgetospeed, cfgetispeed, cfsetispeed,
cfsetospeed, tcgetpgrp, tcsetpgrp
Part II: SystemCalls
876
ECHOE If ICANON isalso set, the ERASE character erasesthe preceding input character, and WERASE erasesthe
preceding word.
ECHOK If ICANON isalso set, the KILL character erasesthe current line.
ECHONL If ICANON isalso set, echo the NL character even If ECHO isnot set.
ECHOCTL If ECHO isalso set, ASCII control signalsother than TAB, NL, START, and STOP are echoed asCtrl+X,
where X isthe character with ASCII code 0x10 greater than the control signal. For example,
character 0x28 (BS) isechoed asCtrl+H.
ECHOPRT If ICANON and IECHO are also set, charactersare printed asthey are being erased.
ECHOKE If ICANON isalso set, KILL isechoed by erasing each character on the line, asspecified by ECHOE and
ECHOPRT.
FLUSHO Output isbeing flushed. Thisflag istoggled by typing the DISCARD character.
NOFLSH Disablesflushing of the input and output queueswhen generating the SIGINT and SIGQUIT signals,
and flushing of the input queue when generating the SIGSUSP signal.
TOSTOP Sendsthe SIGTTOU signal to the processgroup of a background processthat triesto write to its
controlling terminal.
PENDIN All charactersin the input queue are reprinted when the next character isread. (bash handles
typeahead thisway.)
IEXTEN Enable implementation-defined input processing.
tcgetattr() getsthe parametersassociated with the object referred by f d and storesthem in the termios structure referenced
by t er mi os_p. Thisfunction may be invoked from a background process; however, the terminal attributesmay be subse-
quently changed by a foreground process.
tcsetattr() setsthe parametersassociated with the terminal (unlesssupport isrequired from the underlying hardware that is
not available) from the termios structure referred to by t er mi os_p. opt i onal _act i ons specifieswhen the changestake effect:
TCSANOW The change occursimmediately.
TCSADRAIN The change occursafter all output written to f d hasbeen transmitted. Thisfunction should be used
when changing parametersthat affect output.
TCSAFLUSH The change occursafter all output written to the object referred to by f d hasbeen transmitted, and
all input that hasbeen received but not read will be discarded before the change ismade.
tcsendbreak() transmitsa continuousstream of zero-valued bitsfor a specific duration, if the terminal isusing asynchronous
serial data transmission. If dur at i on is0, it transmitszero-valued bitsfor at least 0.25 seconds, and not more than 0.5
seconds. If dur at i on isnot 0, it sendszero-valued bitsfor dur at i on*N seconds, where N isat least 0.25, and not more
than 0.5.
If the terminal isnot using asynchronousserial data transmission, tcsendbreak() returnswithout taking any action.
tcdrain() waitsuntil all output written to the object referred to by f d hasbeen transmitted.
tcflush() discardsdata written to the object referred to by f d but not transmitted, or data received but not read, depending
on the value of queue_sel ect or :
TCIFLUSH Flushesdata received but not read.
TCOFLUSH Flushesdata written but not transmitted.
TCIOFLUSH Flushesboth data received but not read and data written but not transmitted.
tcflow() suspendstransmission or reception of data on the object referred to by f d, depending on the value of act i on:
TCOOFF Suspendsoutput.
TCOON Restartssuspended output.
TCIOFF Transmitsa STOP character, which stopsthe terminal device from transmitting data to the system.
TCION Transmitsa START character, which startsthe terminal device transmitting data to the system.
877
The default on open of a terminal file isthat neither itsinput nor itsoutput issuspended.
The baud rate functionsare provided for getting and setting the valuesof the input and output baud ratesin the termios
structure. The new valuesdo not take effect until tcsetattr() issuccessfully called.
Setting the speed to B0 instructsthe modem to hang up. The actual bit rate corresponding to B38400 may be altered with
setserial(8).
The input and output baud ratesare stored in the termios structure.
cfgetospeed() returnsthe output baud rate stored in the termios structure pointed to by t er mi os_p.
cfsetospeed() setsthe output baud rate stored in the termios structure pointed to by t er mi os_p to speed, which must be one
of these constants:
B0
B50
B75
B110
B134
B150
B200
B300
B600
B1200
B1800
B2400
B4800
B9600
B19200
B38400
B57600
B115200
B230400
The zero baud rate, B0, isused to terminate the connection. If B0 isspecified, the modem control lineswill no longer be
asserted. Normally, thiswill disconnect the line. CBAUDEX isa mask for the speedsbeyond those defined in POSIX.1 (57600
and later). Thus, B57600 & CBAUDEX isnonzero.
cfgetispeed() returnsthe input baud rate stored in the termios structure.
cfsetispeed() setsthe input baud rate stored in the termios structure to speed. If the input baud rate isset to 0, it will be
equal to the output baud rate.
tcgetpgrp() returnsthe processgroup ID of the foreground processing group, or -1 on error.
tcsetpgrp() setsthe processgroup ID to pgrpid. pgrpid must be the ID of a processgroup in the same session.
RETURN VALUES
cfgetispeed() returnsthe input baud rate stored in the termios structure.
cfgetospeed() returnsthe output baud rate stored in the termios structure.
tcgetpgrp() returnsthe processgroup ID of foreground processing group, or -1 on error.
All other functionsreturn
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfgetospeed, cfgetispeed, cfsetispeed,
cfsetospeed, tcgetpgrp, tcsetpgrp
Part II: SystemCalls
878
0 On success.
-1 on failure (and set errno to indicate the error).
SEE ALSO
setserial(8)
Linux, 25 February1995
time
timeGetstime in seconds
SYNOPSIS
#include <time.h>
time_t time(time_t *t );
DESCRIPTION
time returnsthe time since 00:00:00 GMT, January 1, 1970, measured in seconds.
If t isnon null, the return value isalso stored in the memory pointed to by t .
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
(Under BSD 4.3, thiscall ismade obsolete by gettimeofday(2).)
SEE ALSO
ctime(3), date(1), ftime(3), gettimeofday(2)
Linux, 24 July1993
times
timesGetsprocesstimes
SYNOPSIS
#include <sys/times.h>
clock_t times(struct tms *buf );
DESCRIPTION
times storesthe current processtimesin buf .
st r uct tms isasdefined in /usr/include/sys/times.h:
struct tms {
time_t tms_utime; /* user time */
time_t tms_stime; /* system time */
time_t tms_cutime; /* user time of children */
time_t tms_cstime; /* system time of children */
};
times returnsthe number of clock ticksthat have elapsed since the system hasbeen up.
879
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
time(1), getrusage(2), wait(2)
Linux 0.99.11, 24 July1993
truncate, ftruncate
truncate, ftruncateTruncate a file to a specified length
SYNOPSIS
#include <unistd.h>
int truncate(const char *pat h, size_t l engt h);
int ftruncate(int f d, size_t l engt h);
DESCRIPTION
truncate causesthe file named by pat h or referenced by f d to be truncated to at most l engt h bytesin size. If the file
previously waslarger than thissize, the extra data islost. With ftruncate, the file must be open for writing.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
The errorsfor truncate are
ENOTDIR A component of the path prefix isnot a directory.
EINVAL The pathname containsa character with the high-order bit set.
ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire pathname exceeded 1,023
characters.
ENOENT The named file doesnot exist.
EACCES Search permission isdenied for a component of the path prefix.
EACCES The named file isnot writeable by the user.
ELOOP Too many symbolic linkswere encountered in translating the pathname.
EISDIR The named file isa directory.
EROFS The named file resideson a read-only filesystem.
ETXTBSY The file isa pure procedure (shared text) file that isbeing executed.
EIO An I/O error occurred updating the inode.
EFAULT pat h pointsoutside the processsallocated addressspace.
The errorsfor ftruncate are
EBADF f d isnot a valid descriptor.
EINVAL f d referencesa socket, not a file.
EINVAL f d isnot open for writing.
HISTORY
These function callsappeared in BSD 4.2.
truncate, ftruncate
Part II: SystemCalls
880
BUGS
These callsshould be generalized to allow rangesof bytesin a file to be discarded.
SEE ALSO
open(2)
BSD Man Page, 24 July1993
umask
umaskSetsa file-creation mask
SYNOPSIS
#include <sys/stat.h>
int umask(int mask);
DESCRIPTION
umask setsthe umask to mask & 0777.
RETURN VALUE
The previousvalue of the mask isreturned.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
creat(2), open(2)
Linux 24 July93
uname
unameGetsname and information about the current kernel
SYNOPSIS
#include <sys/utsname.h>
int uname(struct utsname *buf );
DESCRIPTION
uname returnssystem information in buf . The ut sname struct isasdefined in /usr/include/sys/utsname.h:
struct utsname {
char sysname[65];
char nodename[65];
char release[65];
char version[65];
char machine[65];
char domainname[65];
};
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
881
ERRORS
EFAULT buf isnot valid.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN
SEE ALSO
uname(1), getdomainname(2), gethostname(2)
Linux 0.99.11 24 July93
none
noneUndocumented system calls
SYNOPSIS
Undocumented system calls.
DESCRIPTION
Asof Linux 1.3.88, there are 163 system callslisted in /usr/include/asm/unistd.h. Thisman page mentionsthose callsthat
are implemented in the kernel but not yet documented in man pages. Some of these callsdo not yet have prototypesin the
libc include files.
SOLICITATION
If you have information about these system calls, please look in the kernel source code, write a man page (using a style similar
to that of the other Linux section 2 man pages), and send it to aeb@cwi.nl for inclusion in the next man page release from the
Linux Documentation Project.
STATUS
Undocumented are msync, readv, writev, getsid, fdatasync, sysctl, sched_setparam, sched_getparam, sched_setscheduler,
sched_getscheduler, sched_yield, sched_get_priority_max, sched_get_priority_min, sched_rr_get_interval.
SEE ALSO
obsolete(2), unimplemented(2)
Linux 1.3.86 12 April 1996
afs_syscall, break, gtty, lock, mpx, prof, quotactl, stty, ustat
afs_syscall, break, gtty, lock, mpx, prof, quotactl, stty, ustatUnimplemented system calls
SYNOPSIS
Unimplemented system calls.
DESCRIPTION
These system callsare not implemented in the Linux 1.2.4 kernel.
RETURN VALUE
These system callsalwaysreturn 1 and set errno to ENOSYS.
afs_syscall, break, gtty, lock, mpx, prof, quotactl, stty, ustat
Part II: SystemCalls
882
SEE ALSO
obsolete(2), undocumented(2)
Linux 1.2.4, 15 April 1995
unlink
unlinkDeletesa name and possibly the file it refersto
SYNOPSIS
#include <unistd.h>
int unlink(const char *pat hname);
DESCRIPTION
unlink deletesa name from the filesystem. If that name wasthe last link to a file and no processeshave the file open, the file
isdeleted, and the space it wasusing ismade available for reuse.
If the name wasthe last link to a file but any processesstill have the file open, the file will remain in existence until the last
file descriptor referring to it isclosed.
If the name referred to a symbolic link, the link isremoved.
If the name referred to a socket, fifo, or device, the name for it isremoved but processesthat have the object open can
continue to use it.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EFAULT pat hname pointsoutside your accessible addressspace.
EACCES Write accessto the directory containing pat hname isnot allowed for the processseffective UID, or
one of the directoriesin pat hname did not allow search (execute) permission.
EPERM The directory containing pat hname hasthe sticky bit (S_ISVTX) set, and the processseffective UID is
neither the UID of the file to be deleted nor that of the directory containing it, or pat hname isa
directory.
ENAMETOOLONG pat hname wastoo long.
ENOENT A directory component in pat hname doesnot exist or isa dangling symbolic link.
ENOTDIR A component used asa directory in pat hname isnot, in fact, a directory.
EISDIR pat hname refersto a directory.
ENOMEM Insufficient kernel memory wasavailable.
EROFS pat hname refersto a file on a read-only filesystem.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
BUGS
Infelicitiesin the protocol underlying NFS can cause the unexpected disappearance of filesthat are still being used.
SEE ALSO
link(2), rename(2), open(2), rmdir(2), mknod(2), mkfifo(3), remove(3), rm(1), unlink(8).
Linux, 24 July1993
883
uselib
uselibSelectsshared library
SYNOPSIS
#include <unistd.h>
int uselib(const char *l i br ar y);
DESCRIPTION
uselib selectsthe shared library binary that will be used by thisprocess.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
In addition to all the error codesreturned by open(2) and mmap(2), the following may also be returned:
ENOEXEC The file specified by l i br ar y isnot executable, or doesnot have the correct magic numbers.
EACCES The library specified by l i br ar y isnot readable.
CONFORMS TO
uselib() isLinux specific.
SEE ALSO
open(2), mmap(2), ldd(1), gcc(1), ar(1), ld(1)
Linux 0.99.11, 24 July1993
ustat
ustatGetsfilesystem statistics
SYNOPSIS
#include <sys/types.h>
int ustat(dev_t dev , struct ustat * ubuf );
DESCRIPTION
ustat returnsinformation about a mounted filesystem. dev isa device number identifying a device containing a mounted
filesystem. ubuf isa pointer to a ustat structure that containsthe following members:
daddr_t f_tfree; /* Total free blocks */
ino_t f_tinode; /* Number of free inodes */
char f_fname[6]; /* Filsys name */
char f_fpack[6]; /* Filsys pack name */
The last two fields, f_fname and f_fpack, are not implemented and will alwaysbe filled with null characters.
RETURN VALUE
On success, 0 isreturned, and the ustat structure pointed to by ubuf will be filled in. On error, 1 isreturned, and errno is
set appropriately.
ustat
Part II: SystemCalls
884
ERRORS
EINVAL dev doesnot refer to a device containing a mounted filesystem.
EFAULT ubuf pointsoutside of your accessible addressspace.
ENOSYS The mounted filesystem referenced by dev doesnot support thisoperation, or any version of Linux
before 1.3.16.
NOTES
ustat hasbeen provided for compatibility only. All new programsshould use statfs(2) instead.
HISTORY
ustat wasfirst implemented in Linux 1.3.16. All versionsof Linux before 1.3.16 will return ENOSYS.
CONFORMS TO
System V
SEE ALSO
statfs(2), stat(2)
Linux 1.3.16, 9 August 1995
utime, utimes
utime, utimesChange accessand/or modification timesof an inode
SYNOPSIS
#include <sys/types.h>
#include <utime.h>
int utime(const char *f i l ename, struct utimbuf *buf );
#include <sys/time.h>
int utimes(char *f i l ename, struct timeval *t vp);
DESCRIPTION
utime changesthe accessand modification timesof the inode specified by f i l ename to the act i me and modt i me fieldsof buf ,
respectively. If buf isNULL, the accessand modification timesof the file are set to the current time. The utimbuf structure is
struct utimbuf {
time_t actime; /* access time */
time_t modtime; /* modification time */
};
In the Linux DLL 4.4.1 libraries, utimes isjust a wrapper for utime, t vp[0].t v_sec isact i me, and t vp[1].t v_sec ismodt i me.
The timeval structure is
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
885
ERRORS
Other errorsmay occur.
EACCESS Permission to write the file isdenied.
ENOENT f i l ename doesnot exist.
CONFORMS TO
utime: SVID, POSIX
utimes:BSD4.3
SEE ALSO
stat(2)
Linux, 10 June1995
vhangup
vhangupVirtually hangsup the current tty
SYNOPSIS
#include <unistd.h>
int vhangup(void);
DESCRIPTION
vhangup simulatesa hangup on the current terminal. Thiscall arrangesfor other usersto have a clean tty at login time.
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM The user isnot the superuser.
SEE ALSO
init(8)
Linux 0.99.11, 24 July1993
vm86
vm86Entersvirtual 8086 mode
SYNOPSIS
#include <sys/vm86.h>
int vm86(struct vm86_struct * i nf o);
DESCRIPTION
Enter VM86 mode with information asspecified in i nf o:
struct vm86_struct {
struct vm86_regs regs;
unsigned long flags;
vm86
Part II: SystemCalls
886
unsigned long screen_bitmap;
};
struct vm86_regs {
/*
* normal regs, with special meaning for the segment descriptors..
*/
long ebx;
long ecx;
long edx;
long esi;
long edi;
long ebp;
long eax;
long __null_ds;
long __null_es;
long __null_fs;
long __null_gs;
long orig_eax;
long eip;
long cs;
long eflags;
long esp;
long ss;
/*
* these are specific to v86 mode:
*/
long es;
long ds;
long fs;
long gs;
};
these are specific to v86 mode:
/
long es;
long ds;
long fs;
long gs;
};
RETURN VALUE
On success, 0 isreturned. On error, 1 isreturned, and errno isset appropriately.
ERRORS
EPERM Saved kernel stack exists.
Linux 0.99.11, 24 July1993
wait, waitpid
wait, waitpidWait for processtermination
SYNOPSIS
#include <sys/types.h>
#include <sys/wait.h>
887
pid_t wait(int *st at us )
pid_t waitpid(pid_t pi d,int*st at us ,int opt i ons );
DESCRIPTION
The wait function suspendsexecution of the current processuntil a child hasexited, or until a signal isdelivered whose
action isto terminate the current processor to call a signal-handling function. If a child hasalready exited by the time of the
call (a socalled zombieprocess), the function returnsimmediately. Any system resourcesused by the child are freed.
The waitpid function suspendsexecution of the current processuntil a child asspecified by the pi d argument hasexited, or
until a signal isdelivered whose action isto terminate the current processor to call a signal-handling function. Just aswith
wait, if a child requested by pi d hasalready exited by the time of the call, the function returnsimmediately. Any system
resourcesused by the child are freed.
The value of pi d can be one of the following:
< 1 Wait for any child processwhose processgroup ID isequal to the absolute value of pi d.
1 Wait for any child process; thisisthe same behavior that wait exhibits.
0 Wait for any child processwhose processgroup ID isequal to that of the calling process.
> 0 Wait for the child whose processID isequal to the value of pi d.
The value of opt i ons isan OR of zero or more of the following constants:
WNOHANG Return immediately if no child hasexited.
WUNTRACED Also return for children that are stopped and whose statushasnot been reported.
If st at us isnot NULL, wait or waitpid storesstatusinformation in the location pointed to by st at l oc.
Thisstatuscan be evaluated with the following macros(these macrostake the stat buffer asan argumentnot a pointer to
the buffer!):
WIFEXITED(st at us) Isnonzero if the child exited normally.
WEXITSTATUS(st at us) Evaluatesto the least significant eight bitsof the return code of the child that terminated, which
may have been set asthe argument to a call to exit() or asthe argument for a return statement
in the main program. Thismacro can only be evaluated if WIFEXITED returned nonzero.
WIFSIGNALED(st at us) Returnstrue if the child processexited because of a signal that wasnot caught.
WTERMSIG(st at us) Returnsthe number of the signal that caused the child processto terminate. Thismacro can
only be evaluated if WIFSIGNALED returned nonzero.
WIFSTOPPED(st at us) Returnstrue if the child processthat caused the return iscurrently stopped; thisisonly possible
if the call wasdone using WUNTRACED.
WSTOPSIG(st at us) Returnsthe number of the signal that caused the child to stop. Thismacro can only be
evaluated if WIFSTOPPED returned nonzero.
RETURN VALUE
The processID of the child that exited returns1 on error or 0 if WNOHANG wasused and no child wasavailable (in which case
errno isset to an appropriate value).
ERRORS
ECHILD If the child processspecified in pi d doesnot exist.
EPERM If the effective user ID of the calling processdoesnot match that of the processbeing waited
for, and the effective user ID of the calling processisnot that of the superuser.
ERESTARTSYS If WNOHANG wasnot set and an unblocked signal or a SIGCHLD wascaught; thisisan extension to
the POSIX.1 standard.
wait, waitpid
Part II: SystemCalls
888
CONFORMS TO
POSIX.1
SEE ALSO
signal(2), wait4(2), signal(7)
Linux, 24 July1993
wait3, wait4
wait3, wait4Wait for processtermination, BSD style
SYNOPSIS
#define _USE_BSD
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/wait.h>
pid_t wait3(int *st at us ,int opt i ons ,
struct rusage *r usage);
pid_t wait4(pid_t pi d,int*st at us ,int opt i ons ,
struct rusage *r usage);
DESCRIPTION
The wait3 function suspendsexecution of the current processuntil a child hasexited, or until a signal isdelivered whose
action isto terminate the current processor to call a signal-handling function. If a child hasalready exited by the time of the
call (a zombie process), the function returnsimmediately. Any system resourcesused by the child are freed.
The wait4 function suspendsexecution of the current processuntil a child asspecified by the pi d argument hasexited, or
until a signal isdelivered whose action isto terminate the current processor to call a signal-handling function. If a child as
requested by pi d hasalready exited by the time of the call (a zombie process), the function returnsimmediately. Any system
resourcesused by the child are freed.
The value of pi d can be one of the following:
< 1 Wait for any child processwhose processgroup ID isequal to the absolute value of pi d.
1 Wait for any child process; thisisequivalent to calling wait3.
0 Wait for any child processwhose processgroup ID isequal to that of the calling process.
> 0 Wait for the child whose processID isequal to the value of pi d.
The value of opt i ons isan exclusive OR of zero or more of the following constants:
WNOHANG Return immediately if no child isthere to be waited for.
WUNTRACED Also return for children that are stopped and whose statushasnot been reported.
If st at us isnot NULL, wait3 and wait4 store statusinformation in the location pointed to by st at l oc.
Thisstatuscan be evaluated with the following macros:
WIFEXITED(*st at us) Isnonzero if the child exited normally.
WEXITSTATUS(*st at us) Evaluatesto the least significant eight bitsof the return code of the child that terminated, which
may have been set asthe argument to a call to exit or asthe argument for a return statement in
the main program. Thismacro can only be evaluated if WIFEXITED returned nonzero.
WIFSIGNALED(*st at us) Returnstrue if the child processexited because of a signal that wasnot caught.
WTERMSIG(*st at us) Returnsthe number of the signal that caused the child processto terminate. Thismacro can
only be evaluated if WIFSIGNALED returned nonzero.
889
WIFSTOPPED(*st at us) Returnstrue if the child processthat caused the return iscurrently stopped; thisisonly possible
if the call wasdone using WUNTRACED.
WSTOPSIG(*st at us) Returnsthe number of the signal that caused the child to stop. Thismacro can only be
evaluated if WIFSTOPPED returned nonzero. If r usage isnot NULL, the struct rusage asdefined in
<sys/resource.h> it pointsto will be filled with accounting information. See getrusage(2) for
details.
RETURN VALUE
These callsreturn the processID of the child that exited, 1 on error, or 0 if WNOHANG wasused and no child wasavailable (in
which case errno will be set appropriately).
ERRORS
ECHILD If the child processspecified in pi d doesnot exist.
EPERM If the effective user ID of the calling processdoesnot match that of the processbeing waited
for, and the effective user ID of the calling processisnot that of the superuser.
ERESTARTSYS If WNOHANG wasnot set and an unblocked signal or a SIGCHLD wascaught; thisisan extension to
the POSIX.1 standard.
CONFORMS TO
POSIX.1
SEE ALSO
signal(2), getrusage(2), wait(2), signal(7)
Linux, 24 July1993
write
writeWritesto a file descriptor
SYNOPSIS
#include <unistd.h>
ssize_t write(int f d, const void *buf , size_t count );
DESCRIPTION
write writesup to count bytesto the file referenced by the file descriptor f d from the buffer starting at buf . POSIX requires
that a read() that can be proved to occur after a write() returned returnsthe new data. Note that not all filesystemsare
POSIX conforming.
RETURN VALUE
On success, the number of byteswritten isreturned (0 indicatesnothing waswritten). On error, 1 isreturned, and errno is
set appropriately. If count is0 and the file descriptor refersto a regular file, 0 will be returned without causing any other
effect. For a special file, the resultsare not portable.
ERRORS
EBADF f d isnot a valid file descriptor or isnot open for writing.
EINVAL f d isattached to an object that isunsuitable for writing.
EFAULT buf isoutside your accessible addressspace.
write
Part II: SystemCalls
890
EPIPE f d isconnected to a pipe or socket whose reading end isclosed. When thishappens, the writing
processwill receive a SIGPIPE signal; if it catches, blocks, or ignoresthis, the error EPIPE is
returned.
EAGAIN Non-blocking I/O hasbeen selected using O_NONBLOCK, and there wasno room in the pipe or
socket connected to f d to write the data immediately.
EINTR The call wasinterrupted by a signal before any data waswritten.
ENOSPC The device containing the file referred to by f d hasno room for the data.
Other errorsmay occur, depending on the object connected to f d.
CONFORMS TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3
SEE ALSO
open(2), read(2), fcntl(2), close(2), lseek(2), select(2), ioctl(2), fsync(2), fwrite(3)
Linux, 13 January1996
891
Library Functions
Part III:
Part III: Library Functions
892
Intro
DESCRIPTION
Thischapter describesall the library functions, excluding the library functionsdescribed in Part 2, which implement system
calls. The variousfunction groupsare identified by a letter that isappended to the chapter number:
(3C) These functionsthe functionsfrom Chapter 2 and from Chapter 3Sare contained in the C standard
library libc, which will be used by cc(1) by default.
(3S) These functionsare partsof the stdio(3S) library. They are contained in the standard C library libc.
(3M) These functionsare contained in the arithmetic library libm. They are used by the f77(1) FORTRAN
compiler by default, but not by the cc(1) C compiler, which needsthe option l m.
(3F) These functionsare part of the FORTRAN library libF77. There are no special compiler flagsneeded to
use these functions.
(3X) Variousspecial libraries. The manual pagesdocumenting their functionsspecify the library names.
AUTHORS
Look at the header of the manual page for the author(s) and copyright conditions. Note that these can be different from page
to page!
Linux, 13 December 1995
abort
abortCausesabnormal program termination
SYNOPSIS
#include <stdlib.h>
void abort(void);
DESCRIPTION
The abort() function causesabnormal program termination unlessthe signal SIGABORT iscaught and the signal handler does
not return. If the abort() function causesprogram termination, all open streamsare closed and flushed.
If the SIGABORT function isblocked or ignored, the abort() function will still override it.
RETURN VALUE
The abort() function never returns.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
sigaction(2), exit(3)
GNU, 12 April 1993
abs
absComputesthe absolute value of an integer
893
SYNOPSIS
#include <stdlib.h>
int abs(int j );
DESCRIPTION
The abs() function computesthe absolute value of the integer argument j .
RETURN VALUE
Returnsthe absolute value of the integer argument.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
NOTES
Trying to take the absolute value of the most negative integer isnot defined.
SEE ALSO
ceil(3), floor(3), fabs(3), labs(3), rint(3)
GNU, 6 June1993
acos
acosArc cosine function
SYNOPSIS
#include <math.h>
double acos(double x);
DESCRIPTION
The acos() function calculatesthe arc cosine of x; that isthe value whose cosine isx. If x fallsoutside the range 1 to 1,
acos() failsand errno isset.
RETURN VALUE
The acos() function returnsthe arc cosine in radians; the value ismathematically defined to be between 0 and pi (inclusive).
ERRORS
EDOM x isout of range.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
asin(3), atan(3), atan2(3), cos(3), sin(3), tan(3)
8 June1993
acosh
acoshInverse hyperbolic cosine function
acosh
Part III: Library Functions
894
SYNOPSIS
#include <math.h>
double acosh(double x);
DESCRIPTION
The acosh() function calculatesthe inverse hyperbolic cosine of x ; that isthe value whose hyperbolic cosine isx. If x isless
than 1.0, acosh() returnsnot-a-number (NaN), and errno isset.
ERRORS
EDOM x isout of range.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
asinh(3), atanh(3), cosh(3), sinh(3), tanh(3)
13 June1993
alloca
allocaMemory allocator
SYNOPSIS
#include <stdlib.h>
void *alloca( size_t si ze);
DESCRIPTION
The alloca function allocatessi ze bytesof space in the stack frame of the caller. Thistemporary space isautomatically freed
on return.
RETURN VALUES
The alloca function returnsa pointer to the beginning of the allocated space. If the allocation fails, a NULL pointer is
returned.
CONFORMS TO
There isevidence that the alloca function appeared in 32v, pwb, pwb.2, 3bsd, and 4bsd. There isa man page for it in BSD
4.3. Linux usesthe GNU version.
BUGS
The alloca function ismachine dependent.
SEE ALSO
brk(2), pagesize(2), calloc(3), malloc(3), realloc(3)
GNU, 29 November 1993
asin
asinArc sine function
895
SYNOPSIS
#include <math.h>
double asin(double x);
DESCRIPTION
The asin() function calculatesthe arc sine of x, which isthe value whose sine isx. If x fallsoutside the range 1 to 1, asin()
failsand errno isset.
RETURN VALUE
The asin() function returnsthe arc sine in radians, and the value ismathematically defined to be between -PI/2 and PI/2
(inclusive).
ERRORS
EDOM x isout of range.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
acos(3), atan(3), atan2(3), cos(3), sin(3), tan(3)
8 June1993
asinh
asinhInverse hyperbolic sine function
SYNOPSIS
#include <math.h>
double asinh(double x);
DESCRIPTION
The asinh() function calculatesthe inverse hyperbolic sine of xthat is, the value whose hyperbolic sine isx.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
acosh(3), atanh(3), cosh(3), sinh(3), tanh(3)
13 June1993
assert
assertAbort the program if assertion isfalse
SYNOPSIS
#include <assert.h>
void assert (int expr essi on);
assert
Part III: Library Functions
896
DESCRIPTION
assert() printsan error message to standard output and terminatesthe program by calling abort() if expr essi on isfalse (that
is, evaluatesto 0). Thisonly happenswhen the macro NDEBUG isundefined.
RETURN VALUE
No value isreturned.
CONFORMS TO
ISO9899 (ANSI C)
BUGS
assert() isimplemented asa macro; if the expression tested hasside effects, program behavior will be different depending on
whether NDEBUG isdefined. Thismay create Heisenbugs, which go away when debugging isturned on.
SEE ALSO
exit(3), abort(3)
GNU, 4 April 1993
atan
atanArc tangent function
SYNOPSIS
#include <math.h>
double atan(double x);
DESCRIPTION
The atan() function calculatesthe arc tangent of xthat is, the value whose tangent isx.
RETURN VALUE
The atan() function returnsthe arc tangent in radians, and the value ismathematically defined to be between -PI/2 and PI/2
(inclusive).
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
acos(3), asin(3), atan2(3), cos(3), sin(3), tan(3)
8 June1993
atan2
atan2Arc tangent function of two variables
SYNOPSIS
#include <math.h>
double atan2(double y, double x);
897
DESCRIPTION
The atan2() function calculatesthe arc tangent of the two variables, x and y. It issimilar to calculating the arc tangent of y/ x,
except that the sinesof both argumentsare used to determine the quadrant of the result.
RETURN VALUE
The atan2() function returnsthe result in radians, which isbetween -PI and PI (inclusive).
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
acos(3), asin(3), atan(3), cos(3), sin(3), tan(3)
8 June1993
atanh
atanhInverse hyperbolic tangent function
SYNOPSIS
#include <math.h>
double atanh(double x);
DESCRIPTION
The atanh() function calculatesthe inverse hyperbolic tangent of x; that isthe value whose hyperbolic tangent isx. If the
absolute value of x isgreater than 1.0, acosh() returnsnot-a-number (NaN), and errno isset.
ERRORS
EDOM x isout of range.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
asinh(3), acosh(3), cosh(3), sinh(3), tanh(3)
13 June1993
atexit
atexitRegister a function to be called at normal program termination
SYNOPSIS
#include <stdlib.h>
int atexit(void *f unct i on)(void));
DESCRIPTION
The atexit() function registersthe given function to be called at normal program termination, whether via exit(2) or via
return from the programsmain. Functionsso registered are called in the reverse order of their registration; no argumentsare
passed.
atexit
Part III: Library Functions
898
RETURN VALUE
The atexit()function returnsthe value 0 if successful; otherwise, the value 1 isreturned, and the global variable errno isset
to indicate the error.
ERRORS
ENOMEM Insufficient memory available to add the function.
CONFORMS TO
SVID 3, BSD 4.3, ISO 9899
SEE ALSO
exit(3), on exit(3)
GNU, 29 March 1993
atof
atofConvert a string to a double
SYNOPSIS
#include <stdlib.h>
double atof(const char *npt r );
DESCRIPTION
The atof() function convertsthe initial portion of the string pointed to by npt r to double. The behavior isthe same as
strtod(nptr, (char **)NULL);
except that atof() doesnot detect errors.
RETURN VALUE
The converted value.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
atoi(3), atol(3), strtod(3), strtol(3), strtoul(3)
GNU, 29 March 1993
atoi
atoiConvert a string to an integer
SYNOPSIS
#include <stdlib.h>
int atoi(const char *npt r );
899
DESCRIPTION
The atoi() function convertsthe initial portion of the string pointed to by npt r to int. The behavior isthe same as
strtol(nptr, (char **)NULL, 10);
except that atoi() doesnot detect errors.
RETURN VALUE
The converted value.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
atof(3), atol(3), strtod(3), strtol(3), strtoul(3)
GNU, 29 March 1993
atol
atolConvert a string to a long integer
SYNOPSIS
#include <stdlib.h>
long atol(const char *npt r );
DESCRIPTION
The atol() function convertsthe initial portion of the string pointed to by npt r to long. The behavior isthe same as
strtol(nptr, (char **)NULL, 10);
except that atol() doesnot detect errors.
RETURN VALUE
The converted value.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
atof(3), atoi(3), strtod(3), strtol(3), strtoul(3)
GNU, 29 March 1993
bcmp
bcmpCompare byte strings
SYNOPSIS
#include <string.h>
int bcmp(const void *s1, const void *s2, int n);
bcmp
Part III: Library Functions
900
DESCRIPTION
The bcmp() function comparesthe first n bytesof the stringss1 and s2. If the two stringsare equal, bcmp() returns0;
otherwise, it returnsa nonzero result. If n is0, the two stringsare assumed to be equal.
RETURN VALUE
The bcmp() function returns0 if the stringsare equal; otherwise, a nonzero result isreturned.
CONFORMS TO
4.3BSD. Thisfunction isdeprecateduse memcmp in new programs.
SEE ALSO
memcmp(3), strcasecmp(3), strcmp(3), strcoll(3), strncmp(3), strncasecmp(3)
GNU, 9 April 1993
bcopy
bcopyCopy byte strings
SYNOPSIS
#include <string.h>
void bcopy (const void *sr c, void*dest , int n);
DESCRIPTION
The bcopy() function copiesthe first n bytesof the source string sr c to the destination string dest . If n is0, no bytesare
copied.
RETURN VALUE
The bcopy() function returnsno value.
CONFORMS TO
4.3BSD. Thisfunction isdeprecateduse memcpy in new programs.
SEE ALSO
memccpy(3), memcpy(3), memmove(3), strcpy(3), strncpy(3)
GNU, 9 April 1993
bsearch
bsearchBinary search of a sorted array.
SYNOPSIS
#include <stdlib.h>
void *bsearch(const void *key, const void *base, size_t nmemb,
size_t si ze,int(*compar )(const void *, const void *));
DESCRIPTION
The bsearch() function searchesan array of nmemb objects, the initial member of which ispointed to by base, for a member
that matchesthe object pointed to by key. The size of each member of the array isspecified by si ze.
The contentsof the array should be in ascending sorted order according to the comparison function referenced by compar .
901
The compar routine isexpected to have two argumentsthat point to the key object and to an array member, in that order, and
should return an integer lessthan, equal to, or greater than 0, respectively, if the key object isfound to be lessthan, match, or
be greater than the array member.
RETURN VALUE
The bsearch() function returnsa pointer to a matching member of the array, or NULL if no match isfound. If there are
multiple elementsthat match the key, the element returned isunspecified.
CONFORMS TO
SVID 3, BSD 4.3, ISO 9899
SEE ALSO
qsort(3)
GNU, 29 March 1993
bcmp, bcopy, bzero, memccpy, memchr, memcmp, memcpy, memfrob,
memmem, memmove, memset
bcmp, bcopy, bzero, memccpy, memchr, memcmp, memcpy, memfrob, memmem, memmove, memsetByte string operations
SYNOPSIS
#include <string.h>
int bcmp(const void *s1, const void *s2, int n);
void bcopy(const void *sr c, void *dest , int n);
void bzero(void *s, int n);
void *memccpy(void *dest , const void *sr c, int c, size_t n);
void *memchr(const void *s, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *dest , const void *sr c, size_t n);
void *memfrob(void *s, size_t n);
void *memmem(const void *needl e, size_t needl el en,
const void *hayst ack , size_t hayst ackl en);
void *memmove(void *dest , const void *sr c, size_t n);
void *memset(void *s, int c, size_t n);
DESCRIPTION
The byte string functionsperform operationson stringsthat are not NULL terminated. See the individual man pagesfor
descriptionsof each function.
SEE ALSO
bcmp(3), bcopy(3), bzero(3), memccpy(3), memchr(3), memcmp(3), memcpy(3), memfrob(3), memmem(3), memmove(3), memset(3)
GNU, 12 April 1993
htonl, htons, ntohl, ntohs
htonl, htons, ntohl, ntohsConvert valuesbetween host and network byte order
SYNOPSIS
#include <netinet/in.h>
unsigned long int htonl(unsigned long int host l ong);
unsigned short int htons(unsigned short int host shor t );
htonl, htons, ntohl, ntohs
Part III: Library Functions
902
unsigned long int ntohl(unsigned long int net l ong);
unsigned short int ntohs(unsigned short int net shor t );
DESCRIPTION
The htonl() function convertsthe long integer host l ong from host byte order to network byte order.
The htons() function convertsthe short integer host shor t from host byte order to network byte order.
The ntohl() function convertsthe long integer net l ong from network byte order to host byte order.
The ntohs() function convertsthe short integer net shor t from network byte order to host byte order.
On the i80x86, the host byte order isleast significant byte first, whereasthe network byte order, asused on the Internet, is
most significant byte first.
CONFORMS TO
BSD 4.3
SEE ALSO
gethostbyname(3), getservent(3)
BSD, 15 April 1993
bzero
bzeroWrites0sto a byte string
SYNOPSIS
#include <string.h>
void bzero(void *s, int n);
DESCRIPTION
The bzero() function setsthe first n bytesof the byte string s to 0.
RETURN VALUE
The bzero() function returnsno value.
CONFORMS TO
4.3BSD. Thisfunction isdeprecateduse memset in new programs.
SEE ALSO
memset(3), swab(3)
GNU, 9 April 1993
catgets
catgetsGetsmessage from a message catalog
SYNOPSIS
#include <features.h>
#include <nl_types.h>
char *catgets(nl_catd catalog, int set_number, int
message_number, char *message);
903
DESCRIPTION
catgets() readsthe message message_number, in set set_number, from the message catalog identified by cat al og. (cat al og isa
catalog descriptor returned from an earlier call to catopen(3).) The fourth argument message pointsto a default message
string that will be returned by catgets() if the identified message catalog isnot currently open or isdamaged. The message
text iscontained in an internal buffer area and should be copied by the application if it isto be saved or modified. The return
string isalwaysterminated with a null byte.
RETURN VALUES
On success, catgets() returnsa pointer to an internal buffer area containing the null-terminated message string. catgets()
returnsa pointer to message if it failsbecause the message catalog specified by catalog isnot currently open. Otherwise,
catgets() returnsa pointer to an empty string if the message catalog isavailable but doesnot contain the specified message.
NOTES
These functionsare only available in libc.so.4.4.4c and above.
SEE ALSO
catopen(3), setlocale(3)
29 November 1993
catopen, catclose
catopen, catcloseOpen/close a message catalog
SYNOPSIS
#include <features.h>
#include <nl_types.h>
nl catd catopen(char *name, int f l ag);
void catclose(nl_catd cat al og);
DESCRIPTION
catopen() opensa message catalog and returnsa catalog descriptor. name specifiesthe name of the message catalog to be
opened. If name specifiesan absolute path (that is, containsa /), name specifiesa pathname for the message catalog. Otherwise,
the environment variable NLSPATH isused, with name substituted for %N (see locale(5)). If NLSPATH doesnot exist in the
environment, or if a message catalog cannot be opened in any of the pathsspecified by NLSPATH, the following pathsare
searched in order:
/etc/locale/LC_MESSAGES
/usr/lib/locale/LC_MESSAGES
/usr/lib/locale/name/LC_MESSAGES
In all cases, LC_MESSAGES standsfor the current setting of the LC_MESSAGES category of locale from a previouscall to
setlocale() and defaultsto the C locale. In the last search path, name refersto the catalog name.
The f l ag argument to catopen isused to indicate the type of loading desired. Thisshould be either MCLoadBySet or MCLoadAll.
The former value indicatesthat only the required set from the catalog isloaded into memory when needed, whereasthe latter
causesthe initial call to catopen() to load the entire catalog into memory.
catclose() closesthe message catalog identified by cat al og. It invalidatesany subsequent referencesto the message catalog
defined by cat al og.
RETURN VALUES
catopen() returnsa message catalog descriptor of type nl_catd on success. On failure, it returns1.
catclose() returns0 on success, or -1 on failure.
catopen, catclose
Part III: Library Functions
904
NOTES
These functionsare only available in libc.so.4.4.4c and above. In the case of Linux, the catalog descriptor nl_catd isactually
an area of memory assigned by mmap() and not a file descriptor, thusallowing catalogsto be shared.
SEE ALSO
catgets(3), setlocale(3)
30 November 1993
ceil
ceilSmallest integral value not lessthan x
SYNOPSIS
#include <math.h>
double ceil (double x);
DESCRIPTION
The ceil() function roundsup x to the nearest integer, returning that value asa double.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
abs(3), fabs(3), floor(3), labs(3), rint(3)
6 June1993
clientlib
clientlibNNTP clientlib part of InterNetNewslibrary
SYNOPSIS
extern FILE *ser_rd_fp;
extern FILE *ser_wr_fp;
extern char ser_line[];
char * getserverbyfile(f i l e);
char *file; int server_init(host );
char *host;
int handle_server_response(r esponse, host );
int reponse;
char *host ;
void put_server(t ext );
char *t ext ;
int get_server(buf f , buf f si ze);
char *buf f ;
int buf f si ze;
void close_server();
DESCRIPTION
The routinesdescribed in thismanual page are part of the InterNetNewslibrary, libinn(3). They are replacementsfor the
clientlib part of the NNTP distribution, and are intended to be used in building programssuch asrrn.
905
getserverbyfile callsGetConfigValue to get the name of the local NNTP server. It returnsa pointer to static space. The f i l e
parameter isignored.
server_init opensa connect to the NNTP server at the specified host . It returnsthe serversresponse code or 1 on error. If
a connection wasmade, ser_rd_fp and ser_wr_fp can be used to read from and write to the server, respectively, and ser_line
will contain the serversresponse. ser_line can also be used in other routines.
handle_server_response decodesthe response, which comesfrom the server on host . If the client isauthorized, it returns0. A
client that isonly allowed to read isauthorized, but handle_server_response will print a message on the standard output. If
the client isnot authorized to talk to the server, a message isprinted, and the routine returns1.
put_server sendsthe text in buf f to the server, adding the necessary NNTP line terminatorsand flushing the I/O buffer.
get_server readsa line of text from the server into buf f , reading at most buf f si ze characters. Any trailing \r\n terminators
are stripped off. get_server returns1 on error.
close_server sendsa quit command to the server and closesthe connection.
HISTORY
Written by Rich $alz (rsalz@uunet.uu.net) for InterNetNews.
SEE ALSO
libinn(3)
clock
clockDetermine processor time
SYNOPSIS
#include <time.h>
clock_t clock(void);
DESCRIPTION
The clock() function returnsan approximation of processor time used by the program.
RETURN VALUE
The value returned isthe CPU time used so far asa clock_t; to get the number of secondsused, divide by CLOCKS_PER_SEC.
CONFORMS TO
ANSI C
BUGS
The C standard allowsfor arbitrary valuesat the start of the program; take the difference between the value returned from a
call to clock() at the start of the program and the value returned at the end for maximum portability.
The times() function call returnsmore information.
SEE ALSO
times(2)
GNU, 21 April 1993
closedir
closedirClose a directory
closedir
Part III: Library Functions
906
SYNOPSIS
#include <sys/types.h>
#include <dirent.h>
int closedir(DIR *di r );
DESCRIPTION
The closedir() function closesthe directory stream associated with di r . The directory stream descriptor di r isnot available
after thiscall.
RETURN VALUE
The closedir() function returns0 on successor 1 on failure.
ERRORS
EBADF Invalid directory stream descriptor di r .
CONFORMS TO
SVID 3, POSIX, BSD 4.3
SEE ALSO
close(2), opendir(3), readdir(3), rewinddir(3), seekdir(3), telldir(3), scandir(3)
11 June1995
confstr
confstrGet configuration-dependent string variables
SYNOPSIS
#define __USE_POSIX_2
#include <unistd.h>
size_t confstr(int name, char *buf , size_t l en);
DESCRIPTION
confstr() getsthe value of configuration-dependent string variables.
The name argument isthe system variable to be queried. The following variablesare supported:
CS_PATH A value for the PATH variable that indicateswhere all the POSIX.2 standard utilitiescan be found.
If buf isnot NULL, and l en isnot 0, confstr() copiesthe value of the string to buf truncated to len1 charactersif necessary,
with a null character astermination. Thiscan be detected by comparing the return value of confstr() against l en.
If l en is0 and buf isNULL, confstr() just returnsthe value in Return Value.
RETURN VALUE
If name doesnot correspond to a valid configuration variable, confstr() returns0.
EXAMPLES
The following code fragment determinesthe path where you can find the POSIX.2 system utilities:
char *pathbuf; size_t n;
n = confstr(_CS_PATH,NULL,(size_t)0);
if ((pathbuf = malloc(n)) == NULL) abort();
confstr(_CS_PATH, pathbuf, n);
907
ERRORS
If the value of name isinvalid, errno isset to EINVAL.
CONFORMS TO
Proposed POSIX.2
BUGS
POSIX.2 isnot yet an approved standard; the information in thisman page issubject to change.
SEE ALSO
sh(1), exec(2), system(3)
GNU, 17 April 1993
copysign
copysignCopiesthe sign of a number
SYNOPSIS
#include <math.h>
double copysign(double x, double y);
DESCRIPTION
The copysign() function returnsa value whose absolute value matchesx, but whose sign matchesthat of y.
CONFORMS TO
BSD 4.3
GNU, 6 June1993
cos
cosCosine function
SYNOPSIS
#include <math.h>
double cos(double x);
DESCRIPTION
The cos() function returnsthe cosine of x, where x isgiven in radians.
RETURN VALUE
The cos() function returnsa value between 1 and 1.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
acos(3), asin(3), atan(3), atan2(3), sin(3), tan(3)
8 June1993
cos
Part III: Library Functions
908
cosh
coshHyperbolic cosine function
SYNOPSIS
#include <math.h>
double cosh(double x);
DESCRIPTION
The cosh() function returnsthe hyperbolic cosine of x , which isdefined mathematically as(exp(x)+exp(-x))/2.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
acosh(3), asinh(3), atanh(3), sinh(3), tanh(3)
13 June1993
crypt
cryptPassword and data encryption
SYNOPSIS
#include <unistd.h>
char *crypt(const char *key, const char *sal t );
DESCRIPTION
crypt isthe password-encryption function. It isbased on the Data Encryption Standard algorithm, with variationsintended
(among other things) to discourage the use of hardware implementationsof a key search.
key isa userstyped password.
sal t isa two-character string chosen from the set [a-zA-Z0-9./]. Thisstring isused to perturb the algorithm in one of 4,096
different ways.
By taking the lowest seven bitsof each character of the key, a 56-bit key isobtained. This56-bit key isused to repeatedly
encrypt a constant string (usually a string consisting of all 0s). The returned value pointsto the encrypted password, a series
of 13 printable ASCII characters(with the first two charactersrepresenting the salt itself). The return value pointsto static
data whose content isoverwritten by each call.
Warning: The key space consistsof equal 7.2e16 possible values. Exhaustive searchesof thiskey space are possible using
massively parallel computers. Software, such ascrack(1), isavailable to search the portion of thiskey space that isgenerally
used by humansfor passwords. Hence, password selection should, at minimum, avoid common wordsand names. Using a
passwd(1) program that checksfor crackable passwordsduring the selection processisrecommended.
The DESalgorithm itself hasa few quirksthat make using the crypt(3) interface a very poor choice for anything other than
password authentication. If you are planning to use the crypt(3) interface for a cryptography project, dont do it; get a good
book on encryption and one of the widely available DES librariesinstead.
CONFORMS TO
SVID, X/OPEN, BSD 4.3
909
SEE ALSO
login(1), passwd(1), encrypt(3), getpass(3), passwd(5)
3 September 1994
ctermid
ctermidGetscontrolling terminal name
SYNOPSIS
#include <stdio.h>
char *ctermid(char *s);
DESCRIPTION
ctermid() returnsa string that isthe pathname for the current controlling terminal for thisprocess. If s isNULL, a static buffer
isused; otherwise, s pointsto a buffer used to hold the terminal pathname. The symbolic constant L_ctermid isthe
maximum number of charactersin the returned pathname.
RETURN VALUE
Thisfunction returnsthe pointer to the pathname.
CONFORMS TO
POSIX.1
BUGS
The path returned might not uniquely identify the controlling terminal; it might, for example, be /dev/tty.
It isnot assured that the program can open the terminal.
SEE ALSO
ttyname(3)
GNU, 6 April 1993
asctime, ctime, gmtime, localtime, mktime
asctime, ctime, gmtime, localtime, mktimeTransform binary date and time to ASCII
SYNOPSIS
#include <time.h>
char *asctime(const struct tm *t i mept r );
char *ctime(const time_t *t i mep);
struct tm *gmtime(const time_t *t i mep);
struct tm *localtime(const time_t *t i mep);
time_t mktime(struct tm *t i mept r );
extern char *t zname[2];
long int t i mezone;
extern int dayl i ght ;
DESCRIPTION
The ctime(), gmtime(), and localtime()functionsall take an argument of data type time_t, which representscalendar time.
When interpreted asan absolute time value, it representsthe number of secondselapsed since 00:00:00 on January 1, 1970,
Coordinated Universal Time (UTC).
asctime, ctime, gmtime, localtime, mktime
Part III: Library Functions
910
The asctime() and mktime() functionsboth take an argument representing broken-down time, which isa binary representa-
tion separated into year, month, day, and so on. Broken-down time isstored in the structure t m, which isdefined in <time.h>
asfollows:
struct tm
{
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};
The membersof the t m structure are
tm_sec The number of secondsafter the minute, normally in the range 0 to 59, but can be up to 61 to allow for
leap seconds.
tm_min The number of minutesafter the hour, in the range 0 to 59.
tm_hour The number of hourspast midnight, in the range 0 to 23.
tm_mday The day of the month, in the range 1 to 31.
tm_mon The number of monthssince January, in the range 0 to 11.
tm_year The number of yearssince 1900.
tm_wday The number of dayssince Sunday, in the range 0 to 6.
tm_yday The number of dayssince January 1, in the range 0 to 365.
tm_isdst A flag that indicateswhether daylight savingstime isin effect at the time described. The value ispositive if
daylight saving time isin effect, 0 if it isnot, and negative if the information isnot available.
The ctime()function convertsthe calendar time t i mep into a string of the form
Wed Jun 30 21:49:08 1993\n
The abbreviationsfor the daysof the week are Sun, Mon , Tue, Wed, Thu, Fri, and Sat. The abbreviationsfor the monthsare
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec. The return value pointsto a statically allocated string that might
be overwritten by subsequent callsto any of the date and time functions. The function also setsthe external variable tzname
with information about the current time zone.
The gmtime() function convertsthe calendar time timep to broken-down time representation, expressed in Coordinated
Universal Time (UTC).
The localtime() function convertsthe calendar time t i mep to broken-time representation, expressed relative to the users
specified time zone. The function setsthe external variablest zname with information about the current time zone, t i mezone
with the difference between Coordinated Universal Time and local standard time in seconds, and dayl i ght to a nonzero
value if standard U.S. daylight saving time rulesapply.
The asctime() function convertsthe broken-down time value t i mept r into a string with the same format asctime(). The
return value pointsto a statically allocated string that might be overwritten by subsequent callsto any of the date and time
functions.
The mktime() function convertsa broken-down time structure, expressed aslocal time, to calendar time representation. The
function ignoresthe specified contentsof the structure memberstm_wday and tm_yday and recomputesthem from the other
information in the broken-down time structure. Calling mktime() also setsthe external variable t zname with information
about the current time zone. If the specified broken-down time cannot be represented ascalendar time, mktime() returnsa
value of (time_t)(1) and doesnot alter the t m_wday and t m_yday membersof the broken-down time structure.
911
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
date(1), gettimeofday(2), time(2), tzset(3), difftime(3), strftime(3), newctime(3)
BSD, 26 April 1996
difftime
difftimeCalculatestime difference
SYNOPSIS
#include <time.h>
double difftime(time_t t i me1, time_t t i me0);
DESCRIPTION
The difftime() function returnsthe number of secondselapsed between time t i me1 and time t i me0. The two timesare
specified in calendar time, which representsthe time elapsed since 00:00:00 on January 1, 1970, Coordinated Universal
Time (UTC).
CONFORMS TO
SVID 3, BSD 4.3, ISO 9899
SEE ALSO
date(1), gettimeofday(2), time(2), ctime(3), gmtime(3), localtime(3)
GNU, 2 July1993
div
divComputesthe quotient and remainder of integer division
SYNOPSIS
#include <stdlib.h>
div_t div(int numer , int denom);
DESCRIPTION
The div() function computesthe value numer / denom and returnsthe quotient and remainder in a structure named div_t that
containstwo integer membersnamed quot and r em.
RETURN VALUE
The div_t structure.
CONFORMS TO
SVID 3, BSD 4.3, ISO 9899
SEE ALSO
ldiv(3)
6 June1993
div
Part III: Library Functions
912
drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48,
seed48, lcong48
drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48Generate uniformly distributed pseudo-
random numbers
SYNOPSIS
#include <stdlib.h>
double drand48(void);
double erand48(unsigned short int xsubi [3]);
long int lrand48(void);
long int nrand48(unsigned short int xsubi [3]);
long int mrand48(void);
long int jrand48(unsigned short int xsubi [3]);
void srand48(long int seedval );
unsigned short int * seed48(unsigned short int seed16v [3]);
void lcong48(unsigned short int par am[7]);
DESCRIPTION
These functionsgenerate pseudo-random numbersusing the linear congruential algorithm and 48-bit integer arithmetic.
The drand48() and erand48() functionsreturn non-negative double-precision floating-point valuesuniformly distributed
between [0.0, 1.0].
The lrand48() and nrand48() functionsreturn non-negative long integersuniformly distributed between 0 and 2^31.
The mrand48() and jrand48() functionsreturn signed long integersuniformly distributed between 2^31 and 2^31.
The srand48(),seed48(), and lcong48() functionsare initialization functions, one of which should be called before using
drand48(), lrand48(), or mrand49(). The functionserand48(), nrand48(), and jrand48() do not require an initialization
function to be called first.
All the functionswork by generating a sequence of 48-bit integers, Xi, according to the linear congruential formula
Xi+1=(aXi+c) mod m, where i >=0
The parameter m=2^48; hence 48-bit integer arithmetic isperformed. Unlesslcong48() iscalled, a and care given by
a = 0x5DEECE66D
c = 0xB
The value returned by any of the functionsdrand48(), erand48(), lrand48(), nrand48(), mrand48(), or jrand48() iscomputed
by first generating the next 48-bit Xi in the sequence. Then the appropriate number of bits, according to the type of data
item to be returned, iscopied from the high-order bitsof Xi and transformed into the returned value.
The functionsdrand48(), lrand48(), and mrand48() store the last 48-bit Xi generated in an internal buffer. The functions
erand48(), nrand48(), and jrand48() require the calling program to provide storage for the successive Xi valuesin the array
argument xsubi . The functionsare initialized by placing the initial value of Xi into the array before calling the function for
the first time.
The initializer function srand48() setsthe high-order 32 bitsof Xi to the argument seedval . The low-order 16 bitsare set to
the arbitrary value 0x330E.
The initializer function seed48() setsthe value of Xi to the 48-bit value specified in the array argument seed16v. The
previousvalue of Xi iscopied into an internal buffer and a pointer to thisbuffer isreturned by seed48().
The initialization function lcong48() allowsthe user to specify initial valuesfor Xi , a and c. Array argument elements
param[0-2] specify Xi , param[3-5] specify a, and param[6] specifiesc. After lcong48() hasbeen called, a subsequent call to
either srand48() or seed48() will restore the standard valuesof a and c.
913
CONFORMS TO
SVID 3
NOTES
These functionsare declared obsolete by SVID 3, which statesthat rand(3) should be used instead.
SEE ALSO
rand(3), random(3)
2 July1993
drem
dremFloating-point remainder function
SYNOPSIS
#include <math.h>
double drem(double x, double y);
DESCRIPTION
The drem() function computesthe remainder of dividing x by y. The return value isxn*y, where n isthe quotient of x
divided by y, rounded to the nearest integer. If the quotient is
1
2, it isrounded to the even number.
RETURN VALUE
The drem() function returnsthe remainder unlessy is0, in which case the function failsand errno isset.
ERRORS
EDOM The denominator y is0.
CONFORMS TO
BSD 4.3
SEE ALSO
fmod(3)
6 June1993
ecvt, fcvt
ecvt, fcvtConvert a floating-point number to a string
SYNOPSIS
#include <stdlib.h>
char *ecvt(double number , size_t ndi gi t s,int*decpt ,int*si gn);
char *fcvt(double number , size_t ndi gi t s,int*decpt ,int*si gn);
DESCRIPTION
The ecvt() function convertsnumber to a NULL-terminated string of ndi gi t s digitsand returnsa pointer to the string. The
string itself doesnot contain a decimal point; however, the position of the decimal point relative to the start of the string is
ecvt, fcvt
Part III: Library Functions
914
stored in decpt . A negative value for decpt meansthat the decimal point isto the left of the start of the string. If the sign of
number isnegative, si gn isset to a nonzero value; otherwise, itsset to 0.
The fcvt() function isidentical to ecvt(), except that ndi gi t s specifiesthe number of digitsafter the decimal point.
RETURN VALUE
Both the ecvt()and fcvt() functionsreturn a pointer to a static string containing the ASCII representation of number . The
static string isoverwritten by each call to ecvt() or fcvt().
SEE ALSO
gcvt(3), sprintf(3)
28 March 1993
erf, erfc
erf, erfcError function and complementary error function
SYNOPSIS
#include <math.h>
double erf(double x);
double erfc (double x);
DESCRIPTION
The erf() function returnsthe error function of x, defined as
erf(x) = 2/sqrt(pi)* integral from 0 to x of exp(-t*t) dt
The erfc() function returnsthe complementary error function of xthat is, 1.0erf(x).
CONFORMS TO
SVID 3, BSD 4.3
SEE ALSO
exp(3)
BSD, 25 June1993
execl, execlp, execle, exect, execv, execvp
execl, execlp, execle, exect, execv, execvpExecute a file
SYNOPSIS
#include <unistd.h>
extern char **environ;
int execl(const char *pat h, const char *ar g, ...);
int execlp(const char *f i l e, const char *ar g, ...);
int execle(const char *pat h, const char *ar g, ...);
int execlp(const char *f i l e, const char *ar g, ...);
int execle(const char *pat h, const char *ar g, ...);
int execle(const char *pat h, const char *ar g , ..., char * const envp[]);
int exect(const char *pat h, char *const ar gv []);
int execv(const char *pat h, char *const ar gv []);
int execvp(const char *f i l e, char *const ar gv []);
915
DESCRIPTION
The exec family of functionsreplacesthe current processimage with a new processimage. The functionsdescribed in this
manual page are front endsfor the function execve(2). (See the manual page for execve for detailed information about the
replacement of the current process.)
The initial argument for these functionsisthe pathname of a file that isto be executed.
The const char *ar g and subsequent ellipsesin the execl, execlp, and execle functionscan be thought of asarg0, arg1, ,
argn. Together they describe a list of one or more pointersto null-terminated stringsthat represent the argument list
available to the executed program. The first argument, by convention, should point to the file name associated with the file
being executed. The list of argumentsmust be terminated by a NULL pointer.
The exect, execv, and execvp functionsprovide an array of pointersto null-terminated stringsthat represent the argument
list available to the new program. The first argument, by convention, should point to the filename associated with the file
being executed. The array of pointersmust be terminated by a NULL pointer.
The execle and exect functionsalso specify the environment of the executed processby following the NULL pointer that
terminatesthe list of argumentsin the parameter list or the pointer to the ar gv array with an additional parameter. This
additional parameter isan array of pointersto null-terminated stringsand must be terminated by a NULL pointer. The other
functionstake the environment for the new processimage from the external variable envi r on in the current process.
Some of these functionshave special semantics.
The functionsexeclp and execvp will duplicate the actionsof the shell in searching for an executable file if the specified
filename doesnot contain a slash (/) character. The search path isthe path specified in the environment by the PATH variable.
If thisvariable isnt specified, the default path /bin:/usr/bin: isused (isthistrue for Linux?). In addition, certain errorsare
treated specially.
If permission isdenied for a file (the attempted execve returned EACCES), these functionswill continue searching the rest of
the search path. If no other file isfound, however, they will return with the global variable errno set to EACCES.
If the header of a file isnt recognized (the attempted execve returned ENOEXEC), these functionswill execute the shell with
the path of the file asitsfirst argument. (If thisattempt fails, no further searching isdone.)
If the file iscurrently busy (the attempted execve returned ETXTBUSY), these functionswill sleep for several seconds, periodi-
cally re-attempting to execute the file. (Isthistrue for Linux?)
The function exect executesa file with the program-tracing facilitiesenabled (see ptrace(2)).
RETURN VALUES
If any of the exec functionsreturns, an error will have occurred. The return value is1, and the global variable errno will be
set to indicate the error.
FILES
/bin/sh
ERRORS
execl, execle, execlp, and execvp may fail and set errno for any of the errorsspecified for the library functionsexecve(2) and
malloc(3).
exect and execv may fail and set errno for any of the errorsspecified for the library function execve(2).
SEE ALSO
sh(1), execve(2), fork(2), trace(2), environ(5), ptrace(2)
COMPATIBILITY
Historically, the default path for the execlp and execvp functionswas/bin:/usr/bin. Thiswaschanged to place the current
directory last to enhance system security.
execl, execlp, execle, exect, execv, execvp
Part III: Library Functions
916
The behavior of execlp and execvp when errorsoccur while attempting to execute the file ishistoric practice, but hasnot
traditionally been documented and isnot specified by the POSIX standard.
Traditionally, the functionsexeclp and execvp ignored all errorsexcept for the onesdescribed above and ENOMEM and E2BIG,
upon which they returned. They now return if any error other than the onesdescribed in the Errors section occurs.
STANDARDS
execl, execv, execle, execlp, and execvp conform to IEEE Std1003.1-88 (POSIX.1).
BSD Man Page, 29 November 1993
errno
errnoNumber of last error
SYNOPSIS
#include <errno.h>
extern int errno;
DESCRIPTION
The integer errno isset by system calls(and some library functions) to indicate what went wrong. Itsvalue issignificant only
when the call returnsan error (usually 1), and a library function that doessucceed isallowed to change errno.
Sometimes, when 1 isalso a legal return value, you have to set errno to 0 before the call in order to detect possible errors.
POSIX liststhe following symbolic error names:
E2BIG Arg list too long
EACCES Permission denied
EAGAIN Resource temporarily unavailable
EBADF Bad file descriptor
EBUSY Resource busy
ECHILD No child processes
EDEADLK Resource deadlock avoided
EDOM Domain error
EEXIST File exists
EFAULT Bad address
EFBIG File too large
EINTR Interrupted function call
EINVAL Invalid argument
EIO Input/output error
EISDIR Isa directory
EMFILE Too many open files
EMLINK Too many links
ENAMETOOLONG Filename too long
ENFILE Too many open filesin system
ENODEV No such device
ENOENT No such file or directory
ENOEXEC Exec format error
ENOLCK No locksavailable
ENOMEM Not enough space
917
ENOSPC No space left on device
ENOSYS Function not implemented
ENOTDIR Not a directory
ENOTEMPTY Directory not empty
ENOTTY Inappropriate I/O control operation
ENXIO No such device or address
EPERM Operation not permitted
EPIPE Broken pipe
ERANGE Result too large
EROFS Read-only filesystem
ESPIPE Invalid seek
ESRCH No such process
EXDEV Improper link
SEE ALSO
perror(3)
21 July1996
exit
exitCausesnormal program termination
SYNOPSIS
#include <stdlib.h>
void exit(int st at us );
DESCRIPTION
The exit() function causesnormal program termination, and the value of st at us isreturned to the parent. All functions
registered with atexit() and on exit() are called in the reverse order of their registration, and all open streamsare flushed
and closed.
RETURN VALUE
The exit() function doesnot return.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
_exit(2), atexit(3), on_exit(3)
GNU, 2 April 1993
exp, log, log10, pow
exp, log, log10, powExponential, logarithmic, and power functions
SYNOPSIS
#include <math.h>
double exp(double x);
exp, log, log10, pow
Part III: Library Functions
918
double log(double x);
double log10(double x);
double pow(double x, double y);
DESCRIPTION
The exp() function returnsthe value of e (the base of natural logarithms) raised to the power of x.
The log() function returnsthe natural logarithm of x.
The log10() function returnsthe base-10 logarithm of x.
The pow() function returnsthe value of x raised to the power of y.
ERRORS
The log() and log10() functionscan return the following errors:
EDOM The argument x isnegative.
ERANGE The argument x is0. The log of 0 isnot defined.
The pow() function can return the following error:
EDOM The argument x isnegative and y isnot an integral value. Thiswould result in a complex number.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
sqrt(3), cbrt(3)
GNU June16, 1993
expm1, log1p
expm1, log1pExponential minus1, logarithm of 1 plusargument
SYNOPSIS
#include <math.h>
double expm1 (double x);
double log1p (double x);
DESCRIPTION
expm1(x ) returnsa value equivalent to exp (x)1. It iscomputed in a way that isaccurate even if the value of x isnear 0a
case where exp (x)1 would be inaccurate due to subtraction of two numbersthat are nearly equal.
log1p(x ) returnsa value equivalent to log (1 + x). It iscomputed in a way that isaccurate even if the value of x isnear 0.
CONFORMS TO
BSD
SEE ALSO
exp(3), log(3)
GNU, 16 September 1995
919
fabs
FabsAbsolute value of floating-point number
SYNOPSIS
#include <math.h>
double fabs(double x);
DESCRIPTION
The fabs() function returnsthe absolute value of the floating-point number x.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
abs(3), ceil(3), floor(3), labs(3), rint(3)
25 June1993
fclose
fcloseClosesa stream
SYNOPSIS
#include <stdio.h>
int fclose(FILE *st r eam);
DESCRIPTION
The fclose function dissociatesthe named st r eam from itsunderlying file or set of functions. If the stream wasbeing used for
output, any buffered data iswritten first, using fflush(3).
RETURN VALUES
Upon successful completion, 0 isreturned. Otherwise, EOF isreturned, and the global variable errno isset to indicate the
error. In either case, no further accessto the stream ispossible.
ERRORS
EBADF The argument stream isnot an open stream.
The fclose function may also fail and set errno for any of the errorsspecified for the routinesclose(2) or fflush(3).
SEE ALSO
close(2), fflush(3), fopen(3), setbuf(3)
STANDARDS
The fclose function conformsto ANSI C3.159-1989 (ANSI C).
BSD Man Page, 29 November 1993
clearerr, feof, ferror, fileno
clearerr, feof, ferror, filenoCheck and reset stream status
clearerr, feof, ferror, fileno
Part III: Library Functions
920
SYNOPSIS
#include <stdio.h>
void clearerr( FILE *st r eam);
int feof(FILE *st r eam);
int ferror(FILE *st r eam);
int fileno(FILE *st r eam);
DESCRIPTION
The function clearerr clearsthe end-of-file and error indicatorsfor the stream pointed to by st r eam.
The function feof teststhe end-of-file indicator for the stream pointed to by st r eam, returning nonzero if it isset. The end-
of-file indicator can only be cleared by the function clearerr.
The function ferror teststhe error indicator for the stream pointed to by st r eam, returning nonzero if it isset. The error
indicator can only be reset by the clearerr function.
The function fileno examinesthe argument st r eam and returnsitsinteger descriptor.
ERRORS
These functionsshould not fail and do not set the external variable errno.
SEE ALSO
open(2), stdio(3)
STANDARDS
The functionsclearerr, feof, and ferror conform to C3.159-1989 (ANSI C).
BSD Man Page, 29 November 1993
fflush, fpurge
fflush, fpurgeFlush a stream
SYNOPSIS
#include <stdio.h>
int fflush( FILE *st r eam);
int fpurge( FILE *st r eam);
DESCRIPTION
The function fflush forcesa write of all buffered data for the given output or update stream via the streamsunderlying write
function. The open statusof the stream isunaffected.
If the stream argument isNULL, fflush flushesall open output streams. (Doesthishappen under Linux?)
The function fpurge erasesany input or output buffered in the given stream. For output streams, thisdiscardsany unwritten
output. For input streams, thisdiscardsany input read from the underlying object but not yet obtained via getc(3); this
includesany text pushed back via ungetc.
RETURN VALUES
Upon successful completion, 0 isreturned. Otherwise, EOF isreturned, and the global variable errno isset to indicate the
error.
ERRORS
EBADF Stream isnot an open stream, or, in the case of fflush, not a stream open for writing.
The function fflush may also fail and set errno for any of the errorsspecified for the routine write(2).
921
BUGS
Linux may not support fpurge.
SEE ALSO
write(2), fopen(3), fclose(3), setbuf(3)
STANDARDS
The fflush function conformsto ANSI C3.159-1989 (ANSI C).
BSD Man Page, 29 November 1993
ffs
ffsFindsfirst bit set in a word
SYNOPSIS
#include <string.h>
int ffs(int i );
DESCRIPTION
The ffs() function returnsthe position of the first bit set in the word i . The least significant bit isposition 1, and the most
significant position 32.
RETURN VALUE
The ffs() function returnsthe position of the first bit set, or NULL if no bitsare set.
CONFORMS TO
BSD 4.3
GNU, 13 April 1993
fgetgrent
fgetgrentGetsgroup file entry
SYNOPSIS
#include <grp.h>
#include <stdio.h>
#include <sys/types.h>
struct group *fgetgrent(FILE *st r eam);
DESCRIPTION
The fgetgrent() function returnsa pointer to a structure containing the group information from the file st r eam. The first
time it iscalled it returnsthe first entry; thereafter, it returnssuccessive entries. The file st r eam must have the same format as
/etc/group.
The group structure isdefined in <grp.h> asfollows:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
};
fgetgrent
Part III: Library Functions
922
RETURN VALUE
The fgetgrent()function returnsthe group information structure, or NULL if there are no more entriesor an error occurs.
ERRORS
ENOMEM Insufficient memory to allocate group information structure.
CONFORMS TO
SVID 3
SEE ALSO
getgrnam(3), getgrgid(3), getgrent(3), setgrent(3), endgrent(3)
GNU, 4 April 1993
fgetpwent
fgetpwentGetspassword file entry
SYNOPSIS
#include <pwd.h>
#include <stdio.h>
#include <sys/types.h>
struct passwd *fgetpwent(FILE *st r eam);
DESCRIPTION
The fgetpwent() function returnsa pointer to a structure containing the broken-out fieldsof a line in the file st r eam. The
first time it iscalled it returnsthe first entry; thereafter, it returnssuccessive entries. The file st r eam must have the same
format as/etc/passwd.
The passwd structure isdefined in <pwd.h> asfollows:
struct passwd {
char *pw_name; /* username */
char *pw_passwd; /* user password */
uid_t pw_uid; /* user id */
gid_t pw_gid; /* group id */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
RETURN VALUE
The fgetpwent() function returnsthe passwd structure, or NULL if there are no more entriesor an error occurs.
ERRORS
ENOMEM Insufficient memory to allocate passwd structure.
FILES
/etc/passwd password database file
CONFORMS TO
SVID 3
923
SEE ALSO
getpwnam(3), getpwuid(3), getpwent(3), setpwent(3), endpwent(3), getpw(3), putpwent( 3), passwd(5)
GNU, 17 May1996
floor
floorLargest integral value not greater than x
SYNOPSIS
#include <math.h>
double floor(double x);
DESCRIPTION
The floor() function roundsx downward to the nearest integer, returning that value asa double.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
abs(3), fabs(3), ceil(3), rint(3)
6 June1993
fmod
fmodFloating-point remainder function
SYNOPSIS
#include <math.h>
double fmod(double x, double y);
DESCRIPTION
The modf() function computesthe remainder of dividing x by y. The return value isxn*y, where n isthe quotient of x/y,
rounded toward 0 to an integer.
RETURN VALUE
The fmod() function returnsthe remainder unlessy is0, in which case the function failsand errno isset.
ERRORS
EDOM The denominator y is0.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
drem(3)
6 June1993
fmod
Part III: Library Functions
924
fnmatch
fnmatchMatchesfilename or pathname
SYNOPSIS
#include <fnmatch.h>
int fnmatch(const char *pat t er n, const char *strings,int f l ags);
DESCRIPTION
fnmatch() checksthe st r i ngs argument and checkswhether it matchesthe pat t er n argument, which isa shell wildcard
pattern.
The f l ags argument modifiesthe behavior; it isthe bitwise OR of zero or more of the following flags:
FNM_NOESCAPE If thisflag isset, treat backslash asan ordinary character instead of asan escape character.
FNM_PATHNAME If thisflag isset, match a slash in st r i ng only with a slash in pat t er n and not, for example, with
a [] - sequence containing a slash.
FNM_PERIOD If thisflag isset, a leading period in st r i ng hasto be matched exactly by a period in pat t er n. A
period isconsidered to be leading if it isthe first character in st r i ng, or if both FNM_PATHNAME is
set and the period immediately followsa slash.
RETURN VALUE
Zero if st r i ng matchespat t er n, FNM_NOMATCH if there isno match, or another value if there isan error.
CONFORMS TO
Proposed POSIX.2
BUGS
POSIX.2 isnot yet an approved standard; the information in thisman page issubject to change.
SEE ALSO
sh(1), glob(3), glob(7)
GNU, 19 April 1993
fopen, fdopen, freopen
fopen, fdopen, freopenStream open functions
SYNOPSIS
#include <stdio.h>
FILE *fopen( char *pat h, char *mode);
FILE *fdopen( int f i l des, char *mode);
FILE *freopen( char *pat h, char *mode,FILE*st r eam);
DESCRIPTION
The fopen function opensthe file whose name isthe string pointed to by pat h and associatesa stream with it.
The argument mode pointsto a string beginning with one of the following sequences(additional charactersmay follow these
sequences):
r Open text file for reading. The stream ispositioned at the beginning of the file.
r+ Open for reading and writing. The stream ispositioned at the beginning of the file.
925
w Truncate file to zero length or create a text file for writing. The stream ispositioned at the
beginning of the file.
w+ Open for reading and writing. The file iscreated if it doesnot exist; otherwise it istruncated.
The stream ispositioned at the beginning of the file.
a Open for writing. The file iscreated if it doesnot exist. The stream ispositioned at the end of
the file.
a+ Open for reading and writing. The file iscreated if it doesnot exist. The stream ispositioned at
the end of the file.
The mode string can also include the letter b either asa third character or asa character between the charactersin any of the
two-character stringsdescribed previously. Thisisstrictly for compatibility with ANSI C3.159-1989 (ANSI C) and hasno
effect; the b isignored.
Any created fileswill have mode S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH (0666), asmodified by the processs
umask value. (See umask(2).)
Readsand writesmay be intermixed on read/write streamsin any order. Note that ANSI C requiresthat a file positioning
function intervene between output and input, unlessan input operation encountersend-of-file. (If thiscondition isnot met,
then a read isallowed to return the result of writesother than the most recent.) Therefore it isgood practice (and indeed
sometimesnecessary under Linux) to put an fseek or fgetpos operation between write and read operationson such a stream.
Thisoperation may be an apparent no-op (asin fseek(..., 0L, SEEK_CUR)) called for itssynchronizing side effect.
The fdopen function associatesa stream with the existing file descriptor, fildes. The mode of the stream must be compatible
with the mode of the file descriptor. The file descriptor isnot duplicated.
The freopen function opensthe file whose name isthe string pointed to by pat h and associatesthe stream pointed to by
st r eam with it. The original stream (if it exists) isclosed. The mode argument isused just asin the fopen function. The
primary use of the freopen function isto change the file associated with a standard text stream (stderr, stdin, or stdout).
RETURN VALUES
On successful completion, fopen, fdopen, and freopen return a FILE pointer. Otherwise, NULL isreturned, and the global
variable errno isset to indicate the error.
ERRORS
EINVAL The mode provided to fopen, fdopen, or freopen wasinvalid.
The fopen, fdopen, and freopen functionsmay also fail and set errno for any of the errorsspecified for the routine malloc(3).
The fopen function may also fail and set errno for any of the errorsspecified for the routine open(2).
The fdopen function may also fail and set errno for any of the errorsspecified for the routine fcntl(2).
The freopen function may also fail and set errno for any of the errorsspecified for the routinesopen(2), fclose(3) and
fflush(3).
SEE ALSO
open(2), fclose(3)
STANDARDS
The fopen and freopen functionsconform to ANSI C3.159-1989 (ANSI C). The fdopen function conformsto IEEE
Std1003.1-1988 (POSIX.1).
BSD Man Page, 13 December 1995
fpathconf, pathconf
fpathconf, pathconfGet configuration valuesfor files
fpathconf, pathconf
Part III: Library Functions
926
SYNOPSIS
#include <unistd.h>
long fpathconf(int f i l edes,intname);
long pathconf(char *pat h, int name);
DESCRIPTION
fpathconf() getsa value for the configuration option name for the open file descriptor f i l edes.
pathconf() getsa value for configuration option name for the filename pat h.
The corresponding macrosdefined in <unistd.h> are the minimum values; if an application wantsto take advantage of values
that may change, a call to fpathconf() or pathconf() can be made, which may yield more liberal results.
Setting name equal to one of the following constantsreturnsthe following configuration options:
_PC_LINK_MAX Returnsthe maximum number of linksto the file. If f i l edes or pat h refersto a directory, the
value appliesto the whole directory. The corresponding macro is_POSIX_LINK_MAX.
_PC_MAX_CANON Returnsthe maximum length of a formatted input line, where f i l edes or pat h must refer to a
terminal. The corresponding macro is_POSIX_MAX_CANON.
_PC_MAX_INPUT Returnsthe maximum length of an input line, where f i l edes or pat h must refer to a terminal.
The corresponding macro is_POSIX_MAX_INPUT.
_PC_NAME_MAX Returnsthe maximum length of a filename in the directory path or filedes the processis
allowed to create. The corresponding macro is_POSIX_MAX_.
_PC PATH_MAX Returnsthe maximum length of a relative pathname when pat h or f i l edes isthe current
working directory. The corresponding macro is_POSIX_PATH_MAX.
_PC_PIPE_BUF Returnsthe size of the pipe buffer, where f i l edes must refer to a pipe or FIFO, and pat h must
refer to a FIFO. The corresponding macro is_POSIX_PIPE_BUF.
_PC_CHOWN_RESTRICTED Returnsnonzero if the chown(2) call may not be used on thisfile. If f i l edes or pat h refersto a
directory, thisappliesto all filesin that directory. The corresponding macro is
_POSIX_CHOWN_RESTRICTED.
_PC_NO_TRUNC Returnsnonzero if accessing filenameslonger than _POSIX_NAME_MAX generatesan error. The
corresponding macro is_POSIX_NO_TRUNC.
_PC_VDISABLE Returnsnonzero if special character processing can be disabled, where f i l edes or pat h must
refer to a terminal.
RETURN VALUE
The limit isreturned, if one exists. If the system doesnot have a limit for the requested resource, 1 isreturned, and errno is
unchanged. If there isan error, 1 isreturned, and errno isset to reflect the nature of the error.
CONFORMS TO
POSIX.1. Fileswith name lengthslonger than the value returned for name equal to _PC_NAME_MAX may exist in the given
directory.
Some returned valuesmay be huge; they are not suitable for allocating memory.
SEE ALSO
getconf(1), statfs(2), open(2), sysconf(3)
GNU, 4 April 1993
fread, fwrite
fread, fwriteBinary stream input/output
927
SYNOPSIS
#include <stdio.h>
size_t fread(void *pt r , size_t si ze, size_t nmemb,FILE*st r eam);
size_t fwrite(void *pt r , size_t si ze, size_t nmemb,FILE*st r eam);
DESCRIPTION
The function fread readsnmemb elementsof data, each si ze byteslong, from the stream pointed to by st r eam, storing them at
the location given by pt r .
The function fwrite writesnmemb elementsof data, each si ze byteslong, to the stream pointed to by st r eam, obtaining them
from the location given by pt r .
RETURN VALUES
fread and fwrite return the number of itemssuccessfully read or written (that is, not the number of characters). If an error
occurs, or the end-of-file isreached, the return value isa short item count (or 0).
fread doesnot distinguish between end-of-file and error, and callersmust use feof(3) and ferror(3) to determine which
occurred.
SEE ALSO
feof(3), ferror(3), read(2), write(2)
STANDARDS
The functionsfread and fwrite conform to ANSI C3.159-1989 (ANSI C).
BSD Man Page, 17 May1996
frexp
frexpConvertsfloating-point number to fractional and integral components
SYNOPSIS
#include <math.h>
double frexp(double x, int *exp);
DESCRIPTION
The frexp() function isused to split the number x into a normalized fraction and an exponent that isstored in exp.
RETURN VALUE
The frexp() function returnsthe normalized fraction. If the argument x isnot 0, the normalized fraction isx timesa power
of 2, and isalwaysin the range
1
2 (inclusive) to 1 (exclusive). If x is0, the normalized fraction is0, and 0 isstored in exp.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
ldexp(3), modf(3)
GNU, 6 June1993
fgetpos, fseek, fsetpos, ftell, rewind
fgetpos, fseek, fsetpos, ftell, rewindReposition a stream
fgetpos, fseek, fsetpos, ftell, rewind
Part III: Library Functions
928
SYNOPSIS
#include <stdio.h>
int fseek(FILE *st r eam, longo f f set , int whence);
long ftell(FILE *st r eam);
void rewind(FILE *st r eam);
int fgetpos(FILE *st r eam, fpos_t *pos);
int fsetpos(FILE *st r eam, fpos_t *pos);
DESCRIPTION
The fseek function setsthe file position indicator for the stream pointed to by st r eam. The new position, measured in bytes,
isobtained by adding offset bytesto the position specified by whence. If whence isset to SEEK_SET, SEEK_CUR, or SEEK_END, the
offset isrelative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the fseek
function clearsthe end-of-file indicator for the stream and undoesany effectsof the ungetc(3) function on the same stream.
The ftell function obtainsthe current value of the file position indicator for the stream pointed to by st r eam.
The rewind function setsthe file position indicator for the stream pointed to by st r eam to the beginning of the file. It is
equivalent to
(void)fseek(stream, 0L, SEEK_SET);
except that the error indicator for the stream isalso cleared. (See clearerr(3).)
The fgetpos and fsetpos functionsare alternate interfacesequivalent to ftell and fseek (with whence set to SEEK_SET), setting
and storing the current value of the file offset into or from the object referenced by pos . On some non-UNIX systems, an
fpos_t object may be a complex object, and these routinesmight be the only way to portably reposition a text stream.
RETURN VALUES
The rewind function returnsno value. Upon successful completion, fgetpos, fseek, and fsetpos return 0, and ftell returns
the current offset. Otherwise, 1 isreturned, and the global variable errno isset to indicate the error.
ERRORS
EBADF The stream specified isnot a seekable stream.
EINVAL The whence argument to fseek wasnot SEEK_SET, SEEK_END, or SEEK_CUR.
The function fgetpos, fseek, fsetpos, and ftell might also fail and set errno for any of the errorsspecified for the routines
fflush(3), fstat(2), lseek(2), and malloc(3).
SEE ALSO
lseek(2)
STANDARDS
The fgetpos, fsetpos, fseek, ftell, and rewind functionsconform to ANSI C3.159-1989 (ANSI C).
BSD Man Page, 29 November 1993
ftime
ftimeReturnsdate and time
SYNOPSIS
#include <sys/timeb.h>
int ftime(struct timeb *t p);
929
DESCRIPTION
Return current date and time in t p, which isdeclared asfollows:
struct timeb {
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
RETURN VALUE
Thisfunction alwaysreturns0.
NOTES
Under Linux, thisfunction isimplemented in a compatibility library instead of in the kernel.
CONFORMS TO
Version 7, BSD 4.3
Under BSD 4.3, thiscall isobsoleted by gettimeofday(2).
SEE ALSO
time(2)
Linux, 24 July1993
ftok
ftokConvertsa pathname and a project identifier to a System V IPC key
SYNOPSIS
#include <sys/types.h>
#include <sys/ipc.h>
key_t ftok (char *pat hname, char pr oj );
DESCRIPTION
The function convertsthe pathname of an existing accessible file and a project identifier into a key_t type System V IPC key.
RETURN VALUE
On success, the return value will be the converted key_t value; otherwise it will be 1, with errno indicating the error asfor
the stat(2) system call.
BUGS
The generated key_t value isobtained by stating the disk file corresponding to pat hname in order to get itsinode number
and the minor device number of the filesystem on which the disk file resides, then by combining the 8-bit pr oj value along
with the lower 16 bitsof the inode number with the 8 bitsof the minor device number. The algorithm doesnot guarantee a
unique key value. In fact,
I Two different nameslinking to the same file produce the same key values.
I Using the lower 16 bitsof the inode number givessome chance (although usually small) to have the same key values
for filenamesreferring to different inodes.
I Not discriminating among major device numbersgivessome chance of collision (also usually small) for systemswith
multiple disk controllers.
ftok
Part III: Library Functions
930
SEE ALSO
ipc(5), msgget(2), semget(2), shmget(2), stat(2)
Linux 0.99.13, 1 November 1993
ftw
ftwFile tree walk
SYNOPSIS
#include <ftw.h>
int ftw(const char *di r ect or y,
int(*f uncpt r )(const char *f i l e, struct stat *sb, int f l ag), int dept h);
DESCRIPTION
ftw() walksthrough the directory tree, starting from the indicated di r ect or y. For each found entry in the tree, it callsf uncpt r
with the full pathname of the entry relative to di r ect or y, a pointer to the stat(2) structure for the entry and an int whose
value will be one of the following:
FTW_F Item isa normal file
FTW_D Item isa directory
FTW_NS The stat failed on the item
FTW_DNR Item isa directory which cant be read
Warning: Anything other than directories, such assymbolic links, getsthe FTW_F tag.
ftw() recursively callsitself for traversing found directories. To avoid using up all a programsfile descriptors, dept h specifies
the number of simultaneousopen directories. When the depth isexceeded, ftw() will become slower because directorieshave
to be closed and reopened.
To stop the tree walk, f uncpt r returnsa nonzero value; thisvalue will become the return value of ftp(). Otherwise, ftw() will
continue until it hastraversed the entire tree (in which case it will return 0), or until it hitsan error such asa malloc(3)
failure, in which case it will return 1.
Because ftp() usesdynamic data structures, the only safe way to exit a tree walk isto return a nonzero value. To handle
interrupts, for example, mark that the interrupt occurred and return a nonzero valuedont use longjmp(3) unlessthe
program isgoing to terminate.
SEE ALSO
stat(2)
Linux, 18 July1993
gcvt
gcvtConvertsa floating-point number to a string
SYNOPSIS
#include <stdlib.h>
char *gcvt(double number , size_t ndi gi t , char *buf );
DESCRIPTION
The gcvt() function convertsnumber to a minimal-length, NULL-terminated ASCII string and storesthe result in buf . It
producesndi gi t significant digitsin either printf() F format or E format.
931
RETURN VALUE
The gcvt() function returnsthe addressof the string pointed to by buf .
SEE ALSO
ecvt(3), fcvt(3), sprintf(3)
29 March 1993
getcwd, get_current_dir_name, getwd
getcwd, get_current_dir_name, getwdGet current working directory
SYNOPSIS
#include <unistd.h>
char *getcwd(char *buf , size_t si ze);
char *get_current_working_dir_name(void);
char *getwd(char *buf );
DESCRIPTION
The getcwd() function copiesthe absolute pathname of the current working directory to the array pointed to by buf , which is
of length si ze.
If the current absolute pathname would require a buffer longer than si ze elements, NULL isreturned, and errno isset to
ERANGE; an application should check for thiserror, and allocate a larger buffer if necessary.
Asan extension to the POSIX.1 standard, getcwd() allocatesthe buffer dynamically using malloc() if buf isNULL on call. In
thiscase, the allocated buffer hasthe length si ze unlesssi ze islessthan 0, when buf isallocated aslarge asnecessary. It is
possible (and, indeed, advisable) to free the buffersif they have been obtained thisway.
get_current_dir_name, which isonly prototyped if __USE_GNU isdefined, will malloc(3) an array big enough to hold the
current directory name. If the environment variable PWD isset, and itsvalue iscorrect, that value will be returned.
getwd, which isonly prototyped if __USE_BSD isdefined, will not malloc(3) any memory. The buf argument should be a
pointer to an array at least PATH_MAX byteslong. getwd returnsonly the first PATH_MAX bytesof the actual pathname.
RETURN VALUE
NULL on failure (for example, if the current directory isnot readable), with errno set accordingly, and buf on success.
CONFORMS TO
POSIX.1
SEE ALSO
chdir(2), free(3), malloc(3).
GNU, 21 July1993
getdirentries
getdirentriesGetsdirectory entriesin a filesystem-independent format
SYNOPSIS
#define __USE_BSD or #define __USE_MISC
#include <dirent.h>
ssize_t getdirentries(int f d, char *buf , size_t nbyt es ,offt *basep);
getdirentries
Part III: Library Functions
932
DESCRIPTION
Thisfunction readsdirectory entriesfrom the directory specified by f d into buf . At most, nbyt es are read. Reading startsat
offset *basep, and *basep isupdated with the new position after reading.
RETURN VALUE
getdirentries returnsthe number of bytesread, or 0 when at the end of the directory. If an error occurs, 1 isreturned, and
errno isset appropriately.
ERRORS
See the Linux library source code for details.
SEE ALSO
open(2), lseek(2)
BSD/MISC, 22 July1993
getenv
getenvGetsan environment variable
SYNOPSIS
#include <stdlib.h>
char *getenv(const char *name);
DESCRIPTION
The getenv() function searchesthe environment list for a string that matchesthe string pointed to by name. The stringsare of
the form name=val ue.
RETURN VALUE
The getenv() function returnsa pointer to the value in the environment, or NULL if there isno match.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
putenv(3), setenv(3), unsetenv(3)
GNU, 3 April 1993
getgrent, setgrent, endgrent
getgrent, setgrent, endgrentGet group file entry
SYNOPSIS
#include <grp.h>
#include <sys/types.h>
struct group *getgrent(void);
void setgrent(void);
void endgrent(void);
933
DESCRIPTION
The getgrent() function returnsa pointer to a structure containing the group information from /etc/group. The first time it
iscalled it returnsthe first entry; thereafter, it returnssuccessive entries.
The setgrent() function rewindsthe file pointer to the beginning of the /etc/group file.
The endgrent() function closesthe /etc/group file.
The group structure isdefined in <grp.h> asfollows:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
};
RETURN VALUE
The getgrent()function returnsthe group information structure, or NULL if there are no more entriesor an error occurs.
ERRORS
ENOMEM Insufficient memory to allocate group information structure.
FILES
/etc/group group database file
CONFORMS TO
SVID 3, BSD 4.3
SEE ALSO
fgetgrent(3), getgrnam(3), getgrgid(3)
GNU, 4 April 1993
getgrnam, getgrgid
getgrnam, getgrgidGet group file entry
SYNOPSIS
#include <grp.h>
#include <sys/types.h>
struct group *getgrnam(const char *name);
struct group *getgrgid(gid_t gi d);
DESCRIPTION
The getgrnam() function returnsa pointer to a structure containing the group information from /etc/group for the entry that
matchesthe group name name.
The getgrgid() function returnsa pointer to a structure containing the group information from /etc/group for the entry that
matchesthe group id gi d.
The group structure isdefined in <grp.h> asfollows:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
getgrnam, getgrgid
Part III: Library Functions
934
gid_t gr_gid; /* group id */
char **gr_mem; /* group members */
};
RETURN VALUE
The getgrnam()and getgrgid() functionsreturn the group information structure, or NULL if the matching entry isnot found
or an error occurs.
ERRORS
ENOMEM Insufficient memory to allocate group information structure.
FILES
/etc/group group database file
CONFORMS TO
SVID 3, POSIX, BSD 4.3
SEE ALSO
fgetgrent(3), getgrent(3), setgrent(3), endgrent(3)
GNU, 4 April 1993
getlogin, cuserid
getlogin, cuseridGet username
SYNOPSIS
#include <unistd.h>
char * getlogin ( void );
#include <stdio.h>
char * cuserid ( char *st r i ng );
DESCRIPTION
getlogin returnsa pointer to a string containing the name of the user logged in on the controlling terminal of the process, or
a null pointer if thisinformation cannot be determined. The string isstatically allocated and might be overwritten on
subsequent callsto thisfunction or to cuserid.
cuserid returnsa pointer to a string containing a username associated with the effective user ID of the process. If st r i ng is
not a null pointer, it should be an array that can hold at least L_cuserid characters; the string isreturned in thisarray.
Otherwise, a pointer to a string in a static area isreturned. Thisstring isstatically allocated and might be overwritten on
subsequent callsto thisfunction or to getlogin.
The macro L_cuserid isan integer constant that indicateshow long an array you might need to store a username. L_cuserid is
declared in stdio.h.
These functionslet your program positively identify the user who isrunning (cuserid) or the user who logged in thissession
(getlogin). (These can differ when setuid programsare involved.) The user cannot do anything to fool these functions.
For most purposes, it ismore useful to use the environment variable LOGNAME to find out who the user is. Thisismore flexible
precisely because the user can set LOGNAME arbitrarily.
ERRORS
ENOMEM Insufficient memory to allocate passwd structure.
935
FILES
The /etc/passwd password database file /etc/utmp (or /var/adm/utmp, or wherever your utmp file livesthese daysthe proper
location dependson your libc version)
CONFORMS TO
POSIX.1. System V hasa cuserid function that usesthe real user ID rather than the effective user ID. The cuserid function
wasincluded in the 1988 version of POSIX, but wasremoved from the 1990 version.
BUGS
Unfortunately, it isoften rather easy to fool getlogin(). Sometimesit doesnot work at all, because some program messed up
the utmp file. Often, it givesonly the first eight charactersof the login name. The user currently logged in on the controlling
tty of your program need not be the user who started it.
Nobody knowsprecisely what cuserid() does; so
I Avoid it in portable programs
I Avoid it altogether
I Use getpwuid (geteuid()) instead, if that iswhat you meant.
Simply, do not usecuserid().
SEE ALSO
geteuid(2), getuid(2)
Linux 1.2.13, 3 September 1995
getmntent, setmntent, addmntent, endmntent, hasmntopt
getmntent, setmntent, addmntent, endmntent, hasmntoptGet filesystem descriptor file entry
SYNOPSIS
#include <stdio.h>
#include <mntent.h>
FILE *setmntent(const char *f i l ep, const char *t ype);
struct mntent *getmntent(FILE *f i l ep);
int addmntent(FILE *f i l ep, const struct mntent *mnt );
int endmntent(FILE *f i l ep);
char *hasmntopt(const struct mntent *mnt , const char *opt );
DESCRIPTION
These routinesare used to accessthe filesystem description file /etc/fstab and the mounted filesystem description file /etc/
mstab.
The setmntent() function opensthe filesystem description file f i l ep and returnsa file pointer that can be used by
getmntent(). The argument t ype isthe type of accessrequired and can take the same valuesasthe mode argument of fopen(3).
The getmntent() function readsthe next line from the filesystem description file f i l ep and returnsa pointer to a structure
containing the broken-out fieldsfrom a line in the file. The pointer pointsto a static area of memory that isoverwritten by
subsequent callsto getmntent().
The addmntent() function addsthe mntent structure mnt to the end of the open file filep.
The endmntent() function closesthe filesystem description file f i l ep.
The hasmntopt() function scansthe mnt _opt s field of the mntent structure mnt for a substring that matchesopt . (See
<mntent.h> for valid mount options.)
getmntent, setmntent, addmntent, endmntent, hasmntopt
Part III: Library Functions
936
The mntent structure isdefined in <mntent.h> asfollows:
struct mntent {
char *mnt_fsname; /* name of mounted filesystem */
char *mnt_dir; /* filesystem path prefix */
char *mnt_type; /* mount type (see mntent.h) */
char *mnt_opts; /* mount options (see mntent.h) */
int mnt_freq; /* dump frequency in days */
int mnt_passno; /* pass number on parallel fsck */
};
RETURN VALUE
The getmntent() function returnsa pointer to the mntent structure or NULL on failure.
The addmntent() function returns0 on successand 1 on failure.
The endmntent() functionsalwaysreturns1.
The hasmntopt() function returnsthe addressof the substring if a match isfound, and NULL otherwise.
FILES
/etc/fstab filesystem description file
/etc/mtab mounted filesystem description file
CONFORMS TO
BSD 4.3
SEE ALSO
fopen(3), fstab(5)
27 June1993
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetentGet network entry
SYNTAX
#include <netdb.h>
struct netent *getnetent()
struct netent *getnetbyname(name)
char *name;
struct netent *getnetbyaddr(net , t ype)
long net ; int t ype;
void setnetent(st ayopen)
int st ayopen;
void endnetent()
DESCRIPTION
The getnetent, getnetbyname, and getnetbyaddr subroutineseach return a pointer to an object with the following structure,
containing the broken-out fieldsof a line in the network database, /etc/networks:
struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net number type */
long n_net; /* net number */
};
937
The membersof thisstructure are
n_name The official name of the network.
n_aliases A zero-terminated list of alternate namesfor the network.
n_addrtype The type of the network number returned: AF_INET.
n_net The network number. Network numbersare returned in machine byte order.
If the st ayopen flag on a setnetent subroutine isNULL, the network database isopened. Otherwise the setnetent hasthe effect
of rewinding the network database. The endnetent may be called to close the network database when processing iscomplete.
The getnetent subroutine simply readsthe next line whereasgetnetbyname and getnetbyaddr search until a matching name or
net number isfound (or until EOF isencountered). The t ype must be AF_INET. The getnetent subroutine keepsa pointer in
the database, allowing successive callsto be used to search the entire file.
A call to setnetent must be made before a while loop using getnetent to perform initialization, and an endnetent must be
used after the loop. Both getnetbyname and getnetbyaddr make callsto setnetent and endnetent.
FILES
/etc/networks
DIAGNOSTICS
Null pointer (0) returned on EOF or error.
SEE ALSO
networks(5), RFC 1101
HISTORY
The getnetent(), getnetbyaddr(), getnetbyname(), setnetent(), and endnetent() functionsappeared in 4.2BSD.
BUGS
The data space used by these functionsisstatic; if future use requiresthe data, it should be copied before any subsequent calls
to these functionsoverwrite it. Only Internet network numbersare currently understood. Expecting network numbersto fit
in no more than 32 bitsisprobably naive.
getopt
getoptParsescommand-line options
SYNOPSIS
#include <unistd.h>
int getopt(int ar gc , char * const ar gv[ ] ,
const char *opt st r i ng);
extern char *opt ar g;
extern int opt i nd, opt er r , opt opt ;
#include <getopt.h>
int getopt_long(int ar gc, char * const ar gv[ ] ,
const char *opt st r i ng,
const struct option *l ongopt s , int *l ongi ndex);
int getopt_long_only(int ar gc, char * const ar gv[ ] ,
const char *opt st r i ng,
const struct option *l ongopt s , int *l ongi ndex);
getopt
Part III: Library Functions
938
DESCRIPTION
The getopt() function parsesthe command-line arguments. Itsargumentsargc and argv are the argument count and array as
passed to the main() function on program invocation. An element of argv that startswith - (and isnot exactly - or -) isan
option element. The charactersof thiselement (aside from the initial -) are option characters. If getopt() iscalled repeatedly,
it returnssuccessively each of the option charactersfrom each of the option elements.
If getopt() findsanother option character, it returnsthat character, updating the external variable opti nd and a static variable
next char so that the next call to getopt() can resume the scan with the following option character or ar gv element.
If there are no more option characters, getopt() returnsEOF. Then optind isthe index in ar gv of the first ar gv element that is
not an option.
opt st r i ng isa string containing the legitimate option characters. If such a character isfollowed by a colon, the option
requiresan argument, so getopt placesa pointer to the following text in the same ar gv element, or the text of the following
ar gv element, in opt ar g. Two colonsmean an option takesan optional arg; if there istext in the current ar gv element, it is
returned in opt ar g; otherwise, opt ar g isset to 0.
By default, getargs() permutesthe contentsof ar gv asit scans, so that eventually all the non-optionsare at the end. Two
other modesare also implemented. If the first character of optstring is+ or the environment variable POSIXLY_CORRECT isset,
option processing stopsassoon asa non-option argument isencountered. If the first character of optstring is-, each non-
option ar gv element ishandled asif it were the argument of an option with character code 1. (Thisisused by programsthat
were written to expect optionsand other ar gv elementsin any order and that care about the ordering of the two.) The special
argument forcesan end of option-scanning regardlessof the scanning mode.
If getopt() doesnot recognize an option character, it printsan error message to stderr, storesthe character in optopt, and
returns?. The calling program may prevent the error message by setting opterr to 0.
The getopt_long()function workslike getopt(), except that it also acceptslong options, started out by two dashes. Long
option namesmay be abbreviated if the abbreviation isunique or isan exact match for some defined option. A long option
may take a parameter, of the form -arg=param or -arg param.
l ongopt s isa pointer to the first element of an array of struct option declared in <getopt.h>:
as struct option {
const char *name;
int has_ar g;
int *f l ag;
int val ;
};
The meaningsof the different fieldsare
name The name of the long option.
has_ar g no_argument (or 0) if the option doesnot take an argument, required_argument (or 1) if the
option requiresan argument, or optional_argument (or 2) if the option takesan optional
argument.
f l ag Specifieshow resultsare returned for a long option. If f l ag isNULL, getopt_long() returnsval .
(For example, the calling program might set val to the equivalent short option character.)
Otherwise, getopt_long() returns0, and f l ag pointsto a variable that isset to val if the option
isfound, but left unchanged if the option isnot found.
val The value to return or to load into the variable pointed to by f l ag.
The last element of the array hasto be filled with zeroes.
If l ongi ndex isnot NULL, it pointsto a variable that isset to the index of the long option relative to l ongopt s.
getopt_long_only() islike getopt_long(), but - aswell as- can indicate a long option. If an option that startswith - (not -)
doesnt match a long option but doesmatch a short option, it isparsed asa short option instead.
939
RETURN VALUE
The getopt()function returnsthe option character if the option wasfound successfully, : if there wasa missing parameter for
one of the options, ? for an unknown option character, or EOF for the end of the option list.
getopt_long() and getopt_long_only() also return the option character when a short option isrecognized. For a long option,
they return val if f l ag isNULL, and 0 otherwise. Error and EOF returnsare the same asfor getopt(), plus? for an ambiguous
match or an extraneousparameter.
ENVIRONMENT VARIABLES
POSIXLY_CORRECT If thisisset, option processing stopsassoon asa non-option argument isencountered.
EXAMPLE
The following example program, from the source code, illustratesthe use of getopt_long() with most of itsfeatures:
#include <stdio.h>
int
main (ar gc, ar gv)
int ar gc ;
char **ar gv;
{
int c ;
int di gi t _opt i nd = 0;
while (1)
{
int t hi s_opt i on_opt i nd = opt i nd ? opt i nd : 1;
int opt i on_i ndex = 0;
static struct option l ong_opt i ons[ ] =
{
{add, 1, 0, 0},
{append, 0, 0, 0},
{delete, 1, 0, 0},
{verbose, 0, 0, 0},
{create, 1, 0, c},
{file, 1, 0, 0g, f0, 0, 0, 0}
};
c = getopt_long (ar gc, ar gv, abc:d:012,
l ong_opt i ons, &opt i on_i ndex);
if (c == -1)
break;
switch(c)
{
case 0:
printf (option %s, l ong_opt i ons[ opt i on_i ndex ] . name);
if (opt ar g)
printf ( with arg %s, opt ar g);
printf (\n);
break;
case 0:
case 1:
case 2:
if (di gi t _opt i nd != 0 && di gi t _opt i nd != t hi s_opt i on_opt i nd)
printf (digits occur in two different argv-elements.\n);
di gi t _opt i nd = t hi s_opt i on_opt i nd;
printf (option %c\n, c);
break;
case a:
printf (option a\n);
break;
case b:
getopt
Part III: Library Functions
940
printf (option b\n);
break;
case c:
printf (option c with value %s\n, opt ar g);
break;
case d:
printf (option d with value %s \n, opt ar g);
break;
case ?:
break;
default:
printf (?? getopt returned character code 0%o ??\n, c);
}
}
if (opt i nd < ar gc )
{
printf (non-option ARGV-elements: );
while (opt i nd < ar gc)
printf (%s , ar gv[ opt i nd++] );
printf (\n);
}
exit (0);
}
BUGS
Thisman page isconfusing.
CONFORMS TO
getopt(): POSIX.1, provided the environment variable POSIXLY_CORRECT isset. Otherwise, the elementsof ar gv arent
really const, because they get permuted. Theyre set const in the prototype to be compatible with other
systems.
GNU, 30 August 1995
getpass
getpassGetsa password
SYNOPSIS
#include <pwd.h>
#include <unistd.h>
char *getpass( const char * prompt );
DESCRIPTION
The getpass function displaysa prompt to, and readsin, a password from, /dev/tty. If thisfile isnot accessible, getpass
displaysthe prompt on the standard error output and readsfrom the standard input.
The password may be up to _PASSWORD_LEN (currently 128) charactersin length. Any additional charactersand the terminat-
ing newline character are discarded. (Thismight be different in Linux.)
getpass turnsoff character echoing while reading the password.
RETURN VALUES
getpass returnsa pointer to the null-terminated password.
941
FILES
/dev/tty
SEE ALSO
crypt(3)
HISTORY
A getpass function appeared in Version 7 AT&T UNIX.
BUGS
The getpass function leavesitsresult in an internal static object and returnsa pointer to that object. Subsequent callsto
getpass will modify the same object.
The calling processshould zero the password assoon aspossible to avoid leaving the cleartext password visible in the
processsaddressspace.
BSD Man Page29 November 1993
getprotoent, getprotobyname, getprotobynumber, setprotoent,
endprotoent
getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoentGet protocol entry
SYNOPSIS
#include <netdb.h>
struct protoent *getprotoent(void);
struct protoent *getprotobyname(const char *name);
struct protoent *getprotobynumber(int pr ot o);
void setprotoent(int st ayopen);
void endprotoent(void);
DESCRIPTION
The getprotoent() function readsthe next line from the file /etc/protocols and returnsa structure pr ot oent containing the
broken-out fieldsfrom the line. The /etc/protocols file isopened if necessary.
The getprotobyname() function returnsa pr ot oent structure for the line from /etc/protocols that matchesthe protocol name
name.
The getprotobynumber() function returnsa pr ot oent structure for the line that matchesthe protocol number number .
The setprotoent() function opensand rewindsthe /etc/protocols file. If st ayopen istrue (1), the file will not be closed
between callsto getprotobyname() or getprotobynumber().
The endprotoent() function closes/etc/protocols.
The protoent structure isdefined in <netdb.h> asfollows:
struct protoent {
char *p_name; /* official protocol name */
char **p_aliases; /* alias list */
int p_proto; /* protocol number */
}
getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoent
Part III: Library Functions
942
The membersof the protoent structure are
p_name The official name of the protocol.
p_aliases A zero-terminated list of alternative namesfor the protocol.
p_proto The protocol number.
RETURN VALUE
The getprotoent(), getprotobyname(), and getprotobynumber() functionsreturn the pr ot oent structure, or a NULL pointer if an
error occursor the end of the file isreached.
FILES
/etc/protocols protocol database file
CONFORMS TO
BSD 4.3
SEE ALSO
getservent(3), getnetent(3), protocols(5)
BSD, 24 April 1993
getpw
getpwReconstructspassword line entry
SYNOPSIS
#include <pwd.h>
#include <sys/types.h>
int getpw(uid_t ui d, char *buf );
DESCRIPTION
The getpw() function reconstructsthe password line entry for the given user UID ui d in the buffer buf . The returned buffer
containsa line of format
name:passwd:uid:gid:gecos:dir:shell
The passwd structure isdefined in <pwd.h> asfollows:
struct passwd {
char *pw_name; /*username*/
char *pw_passwd; /* user password */
uid_t pw_uid; /* user id */
gid_t pw_gid; /* group id */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
RETURN VALUE
The getpw()function returns0 on success, or 1 if an error occurs.
ERRORS
ENOMEM Insufficient memory to allocate passwd structure.
943
FILES
/etc/passwd Password database file
SEE ALSO
fgetpwent(3), getpwent(3), setpwent(3), endpwent(3), getpwnam(3), getpwuid(3), putpwent(3), passwd(5)
GNU, 27 May1996
getpwent, setpwent, endpwent
getpwent, setpwent, endpwentget password file entry
SYNOPSIS
#include <pwd.h>
#include <sys/types.h>
struct passwd *getpwent(void);
void setpwent(void);
void endpwent(void);
DESCRIPTION
The getpwent() function returnsa pointer to a structure containing the broken-out fieldsof a line from /etc/passwd. The
first time it iscalled it returnsthe first entry; thereafter, it returnssuccessive entries.
The setpwent() function rewindsthe file pointer to the beginning of the /etc/passwd file.
The endpwent() function closesthe /etc/passwd file.
The passwd structure isdefined in <pwd.h> asfollows:
struct passwd {
char *pw_name; /*username*/
char *pw_passwd; /* user password */
uid_t pw_uid; /* user id */
gid_t pw_gid; /* group id */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
RETURN VALUE
The getpwent()function returnsthe passwd structure, or NULL if there are no more entriesor an error occurs.
ERRORS
ENOMEM Insufficient memory to allocate passwd structure.
FILES
/etc/passwd Password database file
CONFORMS TO
SVID 3, BSD 4.3
SEE ALSO
fgetpwent(3), getpwnam(3), getpwuid(3), getpw(3), putpwent(3), passwd(5).
GNU, 27 May1996
getpwent, setpwent, endpwent
Part III: Library Functions
944
getpwnam, getpwuid
getpwnam, getpwuidGet password file entry
SYNOPSIS
#include <pwd.h>
#include <sys/types.h>
struct passwd *getpwnam(const char * name);
struct passwd *getpwuid(uid_t ui d);
DESCRIPTION
The getpwnam() function returnsa pointer to a structure containing the broken out fieldsof a line from /etc/passwd for the
entry that matchesthe username name.
The getpwuid() function returnsa pointer to a structure containing the broken-out fieldsof a line from /etc/passwd for the
entry that matchesthe user UID ui d.
The passwd structure isdefined in <pwd.h> asfollows:
struct passwd {
char *pw_name; /*username*/
char *pw_passwd; /* user password */
uid_t pw_uid; /* user id */
gid_t pw_gid; /* group id */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
RETURN VALUE
The getpwnam()and getpwuid() functionsreturn the passwd structure, or NULL if the matching entry isnot found or an error
occurs.
ERRORS
ENOMEM Insufficient memory to allocate passwd structure.
FILES
/etc/passwd Password database file
CONFORMS TO
SVID 3, POSIX, BSD 4.3
SEE ALSO
fgetpwent(3), getpwent(3), setpwent(3), endpwent(3), getpw(3), putpwent(3), passwd(5)
GNU, 27 May1996
fgetc, fgets, getc, getchar, gets, ungetc
fgetc, fgets, getc, getchar, gets, ungetcInput of charactersand strings
SYNOPSIS
#include <stdio.h>
int fgetc(FILE *st r eam);
char *fgets(char *s,int si ze, FILE *st r eam);
945
int getc(FILE *st r eam);
int getchar(void);
char *gets(char *s);
int ungetc(int c, FILE *st r eam);
DESCRIPTION
fgetc() readsthe next character from st r eam and returnsit asan unsigned char cast to an int, or EOF on end of file or error.
getc() isequivalent to fgetc() except that it can be implemented asa macro that evaluatesst r eam more than once.
getchar() isequivalent to getc(st di n).
gets()readsa line from stdin into the buffer pointed to by s until either a terminating newline or EOF, which it replaces
with \0. No check for buffer overrun isperformed (see the following Bus section).
fgets() readsin at most one lessthan n charactersfrom st r eam and storesthem into the buffer pointed to by s. Reading stops
after an EOF or a newline. If a newline isread, it isstored into the buffer. \0 isstored after the last character in the buffer.
ungetc() pushesc back to st r eam, cast to unsigned char, where it isavailable for subsequent read operations. Pushed-back
characterswill be returned in reverse order; only one pushback isguaranteed.
Callsto the functionsdescribed here can be mixed with each other and with callsto other input functionsfrom the stdio
library for the same input stream.
RETURN VALUES
fgetc(), getc(), and getchar() return the character read asan unsigned char cast to an int, or EOF on end of file or error.
gets() and fgets() return s on success, and NULL on error or when end of file occurswhile no charactershave been read.
ungetc() returnsc on success, or EOF on error.
CONFORMS TO
ANSIC, POSIX.1
BUGS
Because it isimpossible to tell without knowing the data in advance how many charactersgets() will read, and because
gets() will continue to store characterspast the end of the buffer, it isextremely dangerousto use. It hasbeen used to break
computer security. Use fgets() instead.
It isnot advisable to mix callsto input functionsfrom the stdio library with low-level callsto read() for the file descriptor
associated with the input stream; the resultswill be undefined and very probably not what you want.
SEE ALSO
read(2), write(2), fopen(3), fread(3), scanf(3), puts(3), fseek(3), ferror(3)
GNU, 4 April 1993
getservent, getservbyname, getservbyport, setservent,
endservent
getservent, getservbyname, getservbyport, setservent, endserventGet service entry
SYNOPSIS
#include <netdb.h>
struct servent *getservent(void);
struct servent *getservbyname(const char *name, const char *proto);
struct servent *getservbyport(int por t , const char *pr ot o);
getservent, getservbyname, getservbyport, setservent, endservent
Part III: Library Functions
946
void setservent(int st ayopen);
void endservent(void);
DESCRIPTION
The getservent()function readsthe next line from the file /etc/services and returnsa structure, ser vent , containing the
broken out fieldsfrom the line. The /etc/services file isopened if necessary.
The getservbyname()function returnsa ser vent structure for the line from /etc/services that matchesthe service name using
protocol pr ot o.
The getservbyport()function returnsa ser vent structure for the line that matchesthe port por t given in network byte order
using protocol pr ot o.
The setservent()function opensand rewindsthe /etc/services file. If stayopen istrue (1), the file will not be closed between
callsto getservbyname() and getservbyport().
The endservent() function closes/etc/services.
The ser vent structure isdefined in <netdb.h> asfollows:
struct servent {
char *s_name; /* official service name */
char **s_al i ases; /* alias list */
int s_por t ; /* port number */
char *s_pr ot o; /* protocol to use */
}
The membersof the ser vent structure are:
s_name The official name of the service.
s_al i ases A zero-terminated list of alternative namesfor the service.
s_por t The port number for the service, given in network byte order.
s_pr ot o The name of the protocol to use with thisservice.
RETURN VALUE
The getservent(), getservbyname(), and getservbyport() functionsreturn the ser vent structure, or a NULL pointer if an error
occursor the end of the file isreached.
FILES
/etc/services Servicesdatabase file
CONFORMS TO
BSD 4.3
SEE ALSO
getprotoent(3), getnetent(3), services(5)
BSD, 22 April 1996
getusershell, setusershell, endusershell
getusershell, setusershell, endusershellGet legal user shells
SYNOPSIS
#include <unistd.h>
char *getusershell(void);
947
void setusershell(void);
void endusershell(void);
DESCRIPTION
The getusershell() function returnsthe next line from the file /etc/shells, opening the file if necessary. The line should
contain the pathname of a valid user shell. If /etc/shells doesnot exist or isunreadable, getusershell() behavesasif /bin/sh
and /bin/csh were listed in the file.
The setusershell() function rewinds/etc/shells.
The endusershell() function closes/etc/shells.
RETURN VALUE
The getusershell() function returnsa NULL pointer on end of file.
FILES
/etc/shells
CONFORMS TO
BSD 4.3
SEE ALSO
shells(5)
BSD, 4 July1993
getutent, getutid, getutline, pututline, setutent, endutent,
utmpname
getutent, getutid, getutline, pututline, setutent, endutent, utmpnameAccessutmp file entries
SYNOPSIS
#include <utmp.h>
struct utmp *getutent(void);
struct utmp *getutid(struct utmp *ut );
struct utmp *getutline(struct utmp *ut );
void pututline(struct utmp *ut );
void setutent(void);
void endutent(void);
void utmpname(const char *f i l e);
DESCRIPTION
utmpname() setsthe name of the utmp-format file for the other utmp functionsto access. If utmpname() isnot used to set the
filename before the other functionsare used, they assume PATH_UTMP, asdefined in <paths.h>.
setutent() rewindsthe file pointer to the beginning of the utmp file. It isgenerally a good idea to call it before any of the
other functions.
endutent()closesthe utmp file. It should be called when the user code isdone accessing the file with the other functions.
getutent() readsa line from the current file position in the utmp file. It returnsa pointer to a structure containing the fields
of the line.
getutid()searchesforward from the current file position in the utmp file based on ut . If ut ->ut_type isRUN_LVL, BOOT_TIME,
NEW_TIME, or OLD_TIME, getutid() will find the first entry whose ut_type field matchesut ->ut_type. If ut ->ut_type is
getutent, getutid, getutline, pututline, setutent, endutent, utmpname
Part III: Library Functions
948
INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS, getutid() will find the first entry whose ut_id field matches
ut ->ut_id.
getutline() searchesforward from the current file position in the utmp file. It scansentrieswhose ut type isUSER_PROCESS or
LOGIN_PROCESS and returnsthe first one whose ut_line field matchesut ->ut_line.
pututline()writesthe utmp structure ut into the utmp file. It usesgetutid() to search for the proper place in the file to insert
the new entry. If it cannot find an appropriate slot for ut , pututline() will append the new entry to the end of the file.
RETURN VALUE
getutent(), getutid(), and getutline() return a pointer to a struct utmp, which isdefined in <utmp.h>.
FILES
/var/run/utmpDatabase of currently logged-in users
/var/log/wtmpDatabase of past user logins
CONFORMS TO
XPG 2, SVID 2, Linux FSSTND 1.2
SEE ALSO
utmp(5)
Linux libc 5.0.0, 22 March 1995
getw, putw
getw, putwInput and output of words(ints)
SYNOPSIS
#include <stdio.h>
int getw(FILE *st r eam);
int putw(int w,FILE*st r eam);
DESCRIPTION
getw readsa word (that is, an int) from st r eam. Itsprovided for compatibility with SVID. I recommend you use fread(3)
instead. putw writesthe word w (that is, an int) to st r eam. It isprovided for compatibility with SVID, but I recommend you
use fwrite(3) instead.
RETURN VALUES
Normally, getw returnsthe word read, and putw returnsthe word written. On error, they return EOF.
BUGS
The value returned on error isalso a legitimate data value. ferror(3) can be used to distinguish between the two cases.
CONFORMS TO
SVID
SEE ALSO
fread(3), fwrite(3), ferror(3), getc(3), putc(3)
GNU, 16 September 1995
949
glob, globfree
glob, globfreeFind pathnamesmatching a pattern; free memory from glob()
SYNOPSIS
#include <glob.h>
int glob(const char *pat t er n, int f l ags,
int er r f unc (const char * epat h, int eer r no),
glob_t *pgl ob);
void globfree(glob_t *pgl ob);
DESCRIPTION
The glob() function searchesfor all the pathnamesmatching pat t er n according to the rulesused by the shell (see glob(7)).
No tilde expansion or parameter substitution isdone.
The globfree() function freesthe dynamically allocated storage from an earlier call to glob().
The resultsof a glob() call are stored in the structure pointed to by pglob, which isa glob_t that isdeclared in <glob.h> as
typedef struct
{
int gl_pathc; /* Count of paths matched so far */
char **gl_pathv; /* List of matched pathnames. */
int gl_offs; /* Slots to reserve in gl pathv. */
int gl_flags; /* Flags for globbing */
} glob_t;
Resultsare stored in dynamically allocated storage.
The parameter f l ags ismade up of bitwise OR of zero or more the following symbolic constants, which modify the of
behavior of glob():
GLOB_ERR Return on read error (because a directory doesnot have read permission, for example).
GLOB_MARK Append a slash to each path which correspondsto a directory.
GLOB_NOSORT Dont sort the returned pathnames(they are by default).
GLOB_DOOFS pgl ob->gl _of f s slotswill be reserved at the beginning of the list of stringsin pgl ob->pat hv.
GLOB_NOCHECK If no pattern matches, return the original pattern.
GLOB_APPEND Append to the resultsof a previouscall. Do not set thisflag on the first invocation of glob().
GLOB_NOESCAPE Meta characterscannot be quoted by backslashes.
GLOB_PERIOD A leading period can be matched by meta characters.
If errfunc isnot NULL, it will be called in case of an error with the argumentsepath, a pointer to the path that failed, and
eerrno, the value of errno asreturned from one of the callsto opendir(), readdir(), or stat(). If errfunc returnsnonzero, or
if GLOB_ERR isset, glob() will terminate after the call to errfunc.
Upon successful return, pgl ob->gl _pat hc containsthe number of matched pathnamesand pgl ob->gl _pat hv a pointer to the
list of matched pathnames. The first pointer after the last pathname isNULL.
It ispossible to call glob() several times. In that case, the GLOB_APPEND flag hasto be set in f l ags on the second and later
invocations.
RETURN VALUES
On successful completion, glob() returns0. Other possible returnsare
GLOB_NOSPACE For running out of memory,
GLOB_ABEND For a read error, and
GLOB_NOMATCH For no found matches.
glob, globfree
Part III: Library Functions
950
EXAMPLES
One example of use isthe following code, which simulatestyping in the shell:
ls -l *.c ../*.c
glob_t globbuf;
globbuf.gl_offs = 2;
glob(*.c, GLOB_DOOFS, NULL, &globbuf);
glob(../*.c, GLOB_DOOFS | GLOB_APPEND, NULL, &globbuf);
globbuf.gl_pathv[0] = ls;
globbuf.gl_pathv[1] = -l;
execvp(ls, &globbuf.gl_pathv[0]);
CONFORMS TO
Proposed POSIX.2
BUGS
The glob()function may fail due to failure of underlying function calls, such asmalloc() or opendir(). These will store their
error code in errno.
POSIX.2 isnot yet an approved standard; the information in thisman page issubject to change.
SEE ALSO
ls(1), sh(1), exec(2), stat(2), malloc(3), opendir(3), readdir(3), wordexp(3), glob(7)
GNU, 13 May1996
hosts_access, hosts_ctl
hosts_access, hosts_ctlAccess-control library functions
SYNOPSIS
#include log_tcp.h
extern int al l ow_sever i t y;
extern int deny_sever i t y;
int hosts_access(daemon, cl i ent )
char *daemon;
struct client_info *client;
int hosts_ctl(daemon, cl i ent _name, cl i ent _addr , cl i ent _user )
char *daemon;
char *cl i ent _name;
char *cl i ent _addr ;
char *cl i ent _user ;
DESCRIPTION
The routinesdescribed in thisdocument are part of the libwrap.a library. They implement a pattern-based access-control
language with optional shell commandsthat are executed when a pattern fires.
In all cases, the daemon argument should specify a daemon processname (ar gv[ 0] value). The client host addressshould be a
valid address, or FROM_UNKNOWN if the addresslookup failed. The client hostname and username should be empty stringsif no
information isavailable, FROM_UNKNOWN if the lookup failed, or an actual hostname or username.
hosts_access() consultsthe access-control tablesdescribed in the hosts_access(5) manual page. hosts_access() returns0 if
accessshould be denied.
hosts_ctl() isa wrapper around the hosts_access() routine with a perhapsmore convenient interface (although it doesnot
passon enough information to support automated remote username lookups). hosts_ctl() returns0 if accessshould be
denied.
951
The al l ow_sever i t y and deny_sever i t y variablesdetermine how accepted and rejected requestscan be logged. They must be
provided by the caller and can be modified by rulesin the access-control tables.
DIAGNOSTICS
Problemsare reported via the syslog daemon.
SEE ALSO
hosts_access(5) (format of the accesscontrol tables), hosts_options(5), optional extensionsto the base language
FILES
/etc/hosts.access, /etc/hosts.deny access-control tables
BUGS
The functionsdescribed here do not make copiesof their string-valued arguments. Beware of data from functionsthat
overwrite their resultson each call.
hosts_access() usesthe strtok() library function. Thismay interfere with other code that relieson strtok().
AUTHOR
Wietse Venema (wietse@wzv.win.tue.nl)
Department of Mathematicsand Computing Science
Eindhoven University of Technology
Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
hcreate, hdestroy, hsearch
hcreate, hdestroy, hsearchHash table management
SYNOPSIS
#include <search.h>
ENTRY *hsearch(ENTRY i t em, ACTION act i on);
int hcreate(unsigned nel );
void hdestroy(voi d);
DESCRIPTION
These three functionsallow the user to create a hash table that associatesa key with any data.
First, the table must be created with the function hcreate(). nel isan estimate of the number of entriesin the table.
hcreate() may adjust thisvalue upward to improve the performance of the resulting hash table. The GNU implementation
of hsearch() will also enlarge the table if it getsnearly full. malloc(3) isused to allocate space for the table.
The corresponding function hdestroy() freesthe memory occupied by the hash table so that a new table can be constructed.
i t em isof type ENTRY, which isa typedef defined in <search.h> and includesthese elements:
typedef struct entry
{
char *key ;
char *dat a;
} ENTRY;
key pointsto the zero-terminated ASCII string that isthe search key. dat a pointsto the data associated with that key. (A
pointer to a type other than character should be cast to pointer-to-character.) hsearch()searchesthe hash table for an item
with the same key asi t em, and if successful returnsa pointer to it. act i on determineswhat hsearch() doesafter an unsuccess-
ful search. A value of ENTER instructsit to insert the new item, whereasa value of FIND meansto return NULL.
hcreate, hdestroy, hsearch
Part III: Library Functions
952
RETURN VALUE
hcreate() returnsNULL if the hash table cannot be successfully installed.
hsearch()returnsNULL if act i on isENTER and there isinsufficient memory to expand the hash table, or if act i on isFIND and
i t em cannot be found in the hash table.
CONFORMS TO
SVID, except that in SysV, the hash table cannot grow.
BUGS
The implementation can manage only one hash table at a time. Individual hash table entriescan be added, but not deleted.
EXAMPLE
The following program inserts24 itemsinto a hash table and then printssome of them:
#include <stdio.h>
#include <search.h>
char *dat a[ ] ={ alpha, bravo, charley, delta,
echo, foxtrot, golf, hotel, india, juliette,
kilo, lima, mike, november, oscar, papa,
quebec, romeo, sierra, tango, uniform,
victor, whiskey, x-ray, yankee, zulu
};
int main()
{
ENTRY e, * ep;
int i ;
/* start with small table, and let it grow */
hcreate(3);
for (i = 0; i < 24; i ++)
{
e. key = dat a[ i ] ;
/* data is just an integer, instead of a pointer
to something */
e. dat a = (char *)i ;
ep = hsearch(e, ENTER);
/* there should be no failures */
if(ep == NULL) {fprintf(stderr, entry failed\n); exit(1);}
}
for (i = 22; i < 26; i ++)
/* print two entries from the table, and show that
two are not in the table */
{
e. key = dat a[ i ] ;
ep = hsearch(e, FIND);
printf(%9.9s -> %9.9s:%d\n, e. key , ep?ep->key :NULL,
ep?(int)(ep->dat a):0);
}
return 0;
}
SEE ALSO
bsearch(3), lsearch(3), tsearch(3), malloc(3)
GNU, 30 September 1995
953
hypot
hypotEuclidean distance function
SYNOPSIS
#include <math.h>
double hypot(double x, double y);
DESCRIPTION
The hypot() function returnsthe sqrt(x*x+y*y). Thisisthe length of the hypotenuse of a right-angle triangle with sidesof
length x and y, or the distance of the point (x, y) from the origin.
CONFORMS TO
SVID 3, BSD 4.3
SEE ALSO
sqrt(3)
25 June1993
index, rindex
index, rindexLocate character in string
SYNOPSIS
#include <string.h>
char *index(const char *s,int c);
char *rindex(const char *s,int c);
DESCRIPTION
The index() function returnsa pointer to the first occurrence of the character c in the string s.
The rindex() function returnsa pointer to the last occurrence of the character c in the string s.
The terminating NULL character isconsidered to be a part of the strings.
RETURN VALUE
The index() and rindex() functionsreturn a pointer to the matched character, or NULL if the character isnot found.
CONFORMS TO
BSD 4.3
SEE ALSO
memchr(3), strchr(3), strpbrk(3), strrchr(3), strsep(3), strspn(3), strstr(3), strtok(3)
GNU, 12 April 1993
inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr,
inet_lnaof, inet_netof
inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netofInternet addressmanipulation
routines
inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof
Part III: Library Functions
954
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int inet_aton(const char *cp, struct in_addr *i np);
unsigned long int inet_addr(const char *cp);
unsigned long int inet_network(const char *cp);
char *inet_ntoa(struct in_addr i n);
struct in_addr inet_makeaddr(int net , int host );
unsigned long int inet_lnaof(struct in_addr i n);
unsigned long int inet_netof(struct in_addr i n);
DESCRIPTION
inet_aton() convertsthe Internet host addresscp from the standard numbers-and-dotsnotation into binary data and storesit
in the structure that inp pointsto. inet_aton returnsnonzero if the addressisvalid, and 0 if it isnot.
The inet_addr()function convertsthe Internet host addresscp from numbers-and-dotsnotation into binary data in network
byte order. If the input isinvalid, 1 isreturned. Thisisan obsolete interface to inet_aton; it isobsolete because -1 isa valid
address(255.255.255.255), and inet_aton providesa cleaner way to indicate error return.
The inet_network() function extractsthe network number in network byte order from the addresscp in numbers-and-dots
notation. If the input isinvalid, 1 isreturned.
The inet_ntoa() function convertsthe Internet host addressgiven in network byte order to a string in standard numbers-
and-dotsnotation. The string isreturned in a statically allocated buffer, which subsequent callswill overwrite.
The inet_makeaddr() function makesan Internet host addressin network byte order by combining the network number net
with the local addresshost in network net , both in local host byte order.
The inet_lnaof() function returnsthe local host addresspart of the Internet addressi n. The local host addressisreturned in
local host byte order.
The inet_netof()function returnsthe network number part of the Internet addressi n. The network number isreturned in
local host byte order.
The structure in_addr asused in inet_ntoa(), inet_makeaddr(), inet_lnoaf(), and inet_netof() isdefined in netinet/in.h as
struct in_addr {
unsigned long int s_addr;
}
Note that on the i80x86 the host byte order isLeast Significant Byte first, whereasthe network byte order, asused on the
Internet, isMost Significant Byte first.
CONFORMS TO
BSD 4.3
SEE ALSO
gethostbyname(3), getnetent(3), hosts(5), networks(5)
BSD, 3 September 1995
infnan
infnanDealswith infinite or not-a-number (NaN) result
SYNOPSIS
#include <math.h>
double infnan(int er r or );
955
DESCRIPTION
The infnan() function returnsa suitable value for infinity and not-a-number (NaN) results. The value of er r or can be ERANGE
to represent infinity, or anything else to represent NaN. errno isalso set.
RETURN VALUE
If er r or isERANGE (Infinity), HUGE_VAL isreturned.
If er r or is-ERANGE (-Infinity), -HUGE_VAL isreturned.
If er r or isanything else, NaN isreturned.
ERRORS
ERANGE The value of er r or ispositive or negative infinity.
EDOM The value of er r or isnot-a-number (NaN).
CONFORMS TO
BSD 4.3
GNU, 2 June1993
initgroups
initgroupsInitializesthe supplementary group accesslist
SYNOPSIS
#include <grp.h>
#include <sys/types.h>
int initgroups(const char *user , gid_t gr oup);
DESCRIPTION
The initgroups() function initializesthe group accesslist by reading the group database /etc/group and using all groupsof
which user isa member. The additional group gr oup isalso added to the list.
RETURN VALUE
The initgroups() function returns0 on success, or 1 if an error occurs.
ERRORS
EPERM The calling processdoesnot have sufficient privileges.
ENOMEM Insufficient memory to allocate group information structure.
FILES
/etc/group group database file
CONFORMS TO
SVID 3, BSD 4.3
SEE ALSO
getgroups(2), setgroups(2)
GNU, 5 April 1993
initgroups
Part III: Library Functions
956
inndcomm
inndcommINND communication part of InterNetNewslibrary
SYNOPSIS
#include inndcomm.h
int ICCopen()
int ICCclose()
void ICCsettimeout(i)
int i ;
int ICCcommand(cmd, ar gv, r epl yp)
char cmd;
char *ar gv[ ] ;
char **r epl yp;
int ICCcancel(mesgi d)
char *mesgi d;
int ICCreserve(why)
char *why;
int ICCpause(why)
char *why ;
int ICCgo(why)
char *why ;
extern char *I CCf ai l ur e;
DESCRIPTION
The routinesdescribed in thismanual page are part of the InterNetNewslibrary, libinn(3). They are used to send com-
mandsto a running innd(8) daemon on the local host. The lettersICC stand for Innd Control Command.
ICCopen createsa UNIX-domain datagram socket and bindsit to the serverscontrol socket. It returns1 on failure or 0 on
success. Thisroutine must be called before any other routine.
ICCclose closesany descriptorsthat have been created by ICCopen. It returns1 on failure or 0 on success.
ICCsettimeout can be called before any of the following routinesto determine how long the library should wait before giving
up on getting the serversreply. Thisisdone by setting and catching a SIGALRM signal(2). If the timeout islessthan 0, no
reply will be waited for. The SC_SHUTDOWN, SC_XABORT, and SC_XEXEC commandsdo not get a reply either. The default, which
can be obtained by setting the timeout to 0, isto wait until the server replies.
ICCcommand sendsthe command cmd with parametersar gv to the server. It returns1 on error. If the server replies, and r epl yp
isnot NULL, it will be filled in with an allocated buffer that containsthe full text of the serversreply. Thisbuffer isa string in
the form <di gi t s><space><t ext > where di gi t s isthe text value of the recommended exit code; 0 indicatessuccess. Replies
longer than 4,000 byteswill be truncated. The possible valuesof cmd are defined in the inndcomm.h header file. The param-
etersfor each command are described in ctlinnd(8). Thisroutine returns1 on communication failure; on successit returns
the exit statussent by the server, which will never be negative.
ICCcancel sendsa cancel message to the server. mesgi d isthe message ID of the article that should be canceled. The return
value isthe same asfor ICCcommand.
ICCpause, ICCreserve, and ICCgo send a pause, reserve, or go command to the server, respectively. If ICCreserve isused, the
why value used in the ICCpause invocation must match; the value used in the ICCgo invocation must alwaysmatch the one
used in the ICCpause invocation. The return value for all three routinesisthe same asfor ICCcommand.
If any of these routinesfail, the ICCfailure variable will identify the system call that failed.
HISTORY
Written by Rich $alz (rsalz@uunet.uu.net) for InterNetNews.
SEE ALSO
ctlinnd(8), innd(8), libinn(3).
957
insque, remque
insque, remqueInsert/Remove an item from a queue
SYNOPSIS
#include <stdlib.h>
void insque(struct qelem * el em, struct qelem * pr ev);
void remque(struct qel em*el em);
DESCRIPTION
insque() and remque() are functionsfor manipulating queuesmade from doubly linked lists. Each element in thislist isof
type struct qelem.
The qelem structure isdefined as
struct qelem {
struct qelem *q_forw;
struct qelem *q_back;
char q_data[1];
};
insque() insertsthe element pointed to by el em immediately after the element pointed to by pr ev, which must not be NULL.
remque() removesthe element pointed to by el em from the doubly linked list.
CONFORMS TO
SVR4
BUGS
The q_data field issometimesdefined to be of type char *, and under Solaris2.x, it doesnt appear to exist at all.
The location of the prototypesfor these functionsdiffersamong several versionsof UNIX. Some systemsplace them in
<search.h>, othersin <string.h>. Linux placesthem in <stdlib.h> because that seemsto make the most sense.
Some versionsof UNIX (such asHP-UX 10.x) do not define a struct qelem but rather have the argumentsto insque() and
remque() be of type void *.
GNU, 30 October 1996
isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph,
islower, isprint, ispunct, isspace, isupper, isxdigit
isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit
Character classification routines
SYNOPSIS
#include <ctype.h>
int isalnum (int c);
int isalpha (int c);
int isascii (int c);
int isblank (int c);
int iscntrl (int c);
int isdigit (int c);
int isgraph (int c);
int islower (int c);
int isprint (int c);
int ispunct (int c);
isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit
Part III: Library Functions
958
int isspace (int c);
int isupper (int c);
int isxdigit (int c);
DESCRIPTION
These functionscheck whether c, which must have the value of an unsigned char or EOF, fallsinto a certain character class
according to the current locale:
isalnum() Checksfor an alphanumeric character; it isequivalent to (isalpha(c) || isdigit(c)).
isalpha() Checksfor an alphabetic character; in the standard C locale, it isequivalent to (isupper(c) ||
islower(c)). In some locales, there may be additional charactersfor which isalpha() istrue
lettersthat are neither uppercase nor lowercase.
isascii() Checkswhether c isa 7-bit unsigned char value that fitsinto the ASCII character set. This
function isa BSD extension and isalso an SVID extension.
isblank() Checksfor a blank character; that is, a space or a tab. Thisfunction isa GNU extension.
iscntrl() Checksfor a control character.
isdigit() Checksfor a digit (0 through 9).
isgraph() Checksfor any printable character except space.
islower() Checksfor a lowercase character.
isprint() Checksfor any printable character, including space.
ispunct() Checksfor any printable character that isnot a space or an alphanumeric character.
isspace() Checksfor whitespace characters. They are space, form-feed (\f), newline (\n), carriage
return (\r), horizontal tab (\t), and vertical tab (\v).
isupper() Checksfor an uppercase letter.
isxdigit() Checksfor a hexadecimal digit (that is, one of 0 1 2 3 4 5 6 7 8 9 0 a b c d e f A B C D E F).
RETURN VALUE
The valuesreturned are nonzero if the character c fallsinto the tested class, and 0 if it doesnot.
CONFORMS TO
ANSI C, BSD 4.3. isascii() isa BSD extension and isalso an SVID extension. isblank() isa GNU extension.
BUGS
The detailsof what charactersbelong in which classdepend on the current locale. For example, isupper() will not recognize
an A with an umlaut () asan uppercase letter in the default C locale.
SEE ALSO
tolower(3), toupper(3), setlocale(3), ascii(7), locale(7)
GNU, 2 September 1995
isatty
isattyTestswhether thisdescriptor refersto a terminal
SYNOPSIS
#include <unistd.h>
int isatty (int desc );
DESCRIPTION
isatty returns1 if desc isan open descriptor connected to a terminal, and 0 otherwise.
959
CONFORMS TO
SVID, AT&T, X/OPEN, BSD 4.3
SEE ALSO
fstat(2), ttyname(3)
Linux, 20 April 1995
isinf, isnan, finite
isinf, isnan, finiteTest for infinity or not-a-number (NaN)
SYNOPSIS
#include <math.h>
int isinf(double val ue);
int isnan(double val ue);
int finite(double val ue);
DESCRIPTION
The isinf() function returns1 if value representsnegative infinity, 1 if value representspositive infinity, and 0 otherwise.
The isnan() function returnsa nonzero value if val ue isnot-a-number (NaN), and 0 otherwise.
The finite() function returnsa nonzero value if val ue isfinite or isnot a not-a-number (NaN) value, and 0 otherwise.
CONFORMS TO
BSD 4.3
GNU, 2 June1993
j0, j1, jn, y0, y1, yn
j0, j1, jn, y0, y1, ynBessel functions
SYNOPSIS
#include <math.h>
double j0(double x);
double j1(double x);
double jn(int n, double x);
double y0(double x);
double y1(double x);
double yn(int n, double x);
DESCRIPTION
The j0() and j1() functionsreturn Bessel functionsof x of the first kind of orders0 and 1, respectively. The jn()function
returnsthe Bessel function of x of the first kind of order n.
The y0() and y1() functionsreturn Bessel functionsof x of the second kind, orders0 and 1, respectively. The yn()function
returnsthe Bessel function of x of the second kind, order n.
For the functionsy0(), y1() and yn(),the value of x must be positive. For negative valuesof x, these functionsreturn
HUGE_VAL.
CONFORMS TO
SVID 3, BSD 4.3
j0, j1, jn, y0, y1, yn
Part III: Library Functions
960
BUGS
There are errorsof up to 2e16 in the valuesreturned by j0(), j1(), and jn() for valuesof x between 8 and 8.
26 June1993
killpg
killpgSendsa signal to all membersof a processgroup
SYNOPSIS
#include <signal.h>
int killpg(pid_t pi dgr p, int si gnal );
DESCRIPTION
The killpg() function causesthe signal si gnal to be sent to all the processesin the processgroup pi dgr p or to the processes
own processgroup if pidgrp isequal to 0.
It isequivalent to kill(-pidgrp,signal);.
RETURN VALUE
The value returned is1 on error, or 0 for success.
ERRORS
Errorsare returned in errno and can be one of the following:
EINVAL Signal isinvalid.
ESRCH Processgroup doesnot exist.
EPERM The user ID of the calling processisnot equal to that of the processthe signal issent to, and the user ID is
not that of the super-user.
SEE ALSO
kill(2), signal(2), signal(7)
GNU, 4 April 1993
labs
labsComputesthe absolute value of a long integer
SYNOPSIS
#include <stdlib.h>
long int labs(long int j );
DESCRIPTION
The labs() function computesthe absolute value of the long integer argument j .
RETURN VALUE
Returnsthe absolute value of the long integer argument.
CONFORMS TO
SVID 3, BSD 4.3, ISO 9899
961
NOTES
Trying to take the absolute value of the most negative integer isnot defined.
SEE ALSO
abs(3), ceil(3), floor(3), fabs(3), rint(3)
GNU, 6 June1993
ldexp
ldexpMultipliesfloating-point number by integral power of 2
SYNOPSIS
#include <math.h>
double ldexp(double x, int exp);
DESCRIPTION
The ldexp() function returnsthe result of multiplying the floating-point number x by 2 raised to the power exp.
CONFORMS TO
SVID 3, POSIX, BSD 4.3, ISO 9899
SEE ALSO
frexp(3), modf(3)
BSD, 6 June1993
ldiv
ldivComputesthe quotient and remainder of long integer division
SYNOPSIS
#include <stdlib.h>
ldiv_t ldiv(long int numer , long int denom);
DESCRIPTION
The ldiv() function computesthe value numer /denom and returnsthe quotient and remainder in a structure named ldiv_t
that containstwo long integer membersnamed quot and rem.
RETURN VALUE
The ldiv_t structure.
CONFORMS TO
SVID 3, BSD 4.3, ISO 9899
SEE ALSO
div(3)
GNU, 29 March 1993
ldiv
Part III: Library Functions
962
lgamma
lgammaLogsgamma function
SYNOPSIS
#include <math.h>
double lgamma(double x);
DESCRIPTION
The lgamma() function returnsthe log of the absolute value of the Gamma function. The sign of the Gamma function is
returned in the external integer si gngam.
For negative integer valuesof x, lgamma() returnsHUGE_VAL, and errno isset to ERANGE.
ERRORS
ERANGE Invalid argumentnegative integer value of x.
CONFORMS TO
SVID 3, BSD 4.3
SEE ALSO
infnan(3)
BSD, 25 June1993
libinn
libinnInterNetNewslibrary routines
SYNOPSIS
#include libinn.h
typedef struct _TIMEINFO {
time_t t i me;
long usec ;
long t zone;
} TIMEINFO;
char *GenerateMessageID()
void HeaderCleanFrom(f r om)
char *f r om;
char *HeaderFind(Ar t i cl e, Header , si ze)
char *Ar t i cl e;
char *Header ;
int si ze;
FILE *CAopen(Fr omSer ver , ToSer ver )
FILE *Fr omSer ver ;
FILE *ToSer ver ;
FILE *CAlistopen(Fr omSer ver , ToSer ver , r equest )
FILE *Fr omSer ver ;
FILE *ToSer ver ;
char *r equest ;
963
void CAclose()
struct _DDHANDLE *DDstart(Fr omSer ver , ToSer ver )
FILE *Fr omSer ver ;
FILE *ToSer ver ;
} DDHANDLE;
void DDcheck(h, gr oup)
DDHANDLE *h;
char *gr oup;
char * DDend(h)
DDHANDLE *h;
void CloseOnExec(f d, f l ag)
int f d;
int f l ag;
int SetNonBlocking(f d, f l ag)
int f d;
int f l ag;
int LockFile(f d, f l ag)
int f d;
int f l ag;
char * GetConfigValue(val ue)
char *val ue;
char * GetFileConfigValue(val ue)
char *val ue;
char * GetFQDN()
char * GetModeratorAddress(gr oup)
char *gr oup;
int GetResourceUsage(user t i me, sys t i me)
double *user t i me;
double *syst i me;
int GetTimeInfo(now)
TIMEINFO *now;
int NNTPlocalopen(Fr omSer ver p, ToSer ver p, er r buf f )
FILE **Fr omSer ver p;
FILE **ToSer ver p;
char *er r buf f ;
int NNTPremoteopen(Fr omSer ver p, ToSer ver p, er r buf f )
FILE **Fr omSer ver p;
FILE **ToSer ver p;
char *er r buf f ;
int NNTPconnect(host , Fr omSer ver p, ToSer v er p, er r buf f )
char *host ;
FILE **Fr omSer ver p;
FILE **ToSer ver p;
char *er r buf f ;
int NNTPcheckarticle(t ext )
libinn
Part III: Library Functions
964
char *t ext ;
int NNTPsendarticle(t ext , ToSer ver , Ter mi nat e)
char *t ext ;
FILE *ToSer ver ;
int Ter mi nat e;
int NNTPsendpassword(ser ver , Fr omSer ver , ToSer v er )
char *ser ver ;
FILE *Fr omSer ver ;
FILE *ToSer ver ;
void Radix32(val ue, p)
unsigned long val ue;
char *p;
char * ReadInFile(name, Sbp)
char *name;
struct stat *Sbp;
char * ReadInDescriptor(f d, Sbp)
int f d;
struct stat *Sbp;
char * INNVersion()
DESCRIPTION
libinn isa library of utility routinesfor manipulating Usenet articlesand related data. It isnot necessary to use the header file
libinn.h; if it isnot available, it isonly necessary to properly declare the TIMEINFO datatype, asshown in the preceding code.
GenerateMessageID usesthe current time, processID, and fully qualified domain name of the local host to create a Message
ID header that ishighly likely to be unique. The returned value pointsto static space that isreused on subsequent calls.
HeaderCleanFrom removesthe extraneousinformation from the value of a From or Reply-To header and leavesjust the official
mailing address. In particular, the following transformationsare made to the f r om parameter:
addr ess > addr ess
addr ess (st uf f ) > addr ess
st uf f <addr ess>> addr ess
The transformationsare simple and are based on RFC 1036, which limitsthe format of the header.
HeaderFind searchesthrough Ar t i cl e looking for the specified Header . si ze should be the length of the header name. It
returnsa pointer to the value of the header, skipping leading whitespace, or NULL if the header cannot be found. Ar t i cl e
should be a standard C string containing the text of the article; the end of a header isindicated by a blank line: two
consecutive \n characters.
CAopen and CAclose provide newsclientswith accessto the active file; the CA standsfor Client Active. CAopen opensthe
active(5) file for reading. It returnsa pointer to an open FILE, or NULL on error. If a local or an NFS-mounted copy exists,
CAopen will use that file. The Fr omSer ver and ToSer ver parametersshould be FILEsconnected to the NNTP server for input
and output, respectively. (See the discussionsof NNTPremoteopen and NNTPlocalopen later in thissection.) If either parameter is
NULL, CAopen will just return NULL if the file isnot locally available. If neither isNULL, CAopen will use them to query the NNTP
server using the list command to make a local temporary copy.
The CAlistopen sendsa list command to the server and returnsa temporary file containing the results. The r equest
parameter, if not NULL, will be sent asan argument to the command. Unlike CAopen, thisroutine will never use a locally
available copy of the active file.
CAclose closesthe active file and removesany temporary file that might have been created by CAopen or CAlistopen.
965
CloseOnExec can make a descriptor close-on-execso that it isnot shared with any child processes. If the flag isnonzero, the file
isso marked; if it is0, the close-on-exec mode iscleared.
DDstart, DDcheck, and DDend are used to set the Distribution header; the DD standsfor Default Distribution. The
distrib.pats(5) file isconsulted to determine the proper value for the Distribution header after all newsgroupshave been
checked. DDstart beginsthe parsing. It returnsa pointer to an opaque handle that should be used on subsequent calls. The
Fr omSer ver and ToSer ver parametersshould be FILEsconnected to the NNTP server for input and output, respectively. If
either parameter isNULL, an empty default will ultimately be returned if the file isnot locally available.
DDcheck should be called with the handle, h, returned by DDstart and a new group, gr oup, to check. It can be called asoften as
necessary.
DDend releasesany state maintained in the handle and returnsan allocated copy of the text that should be used for the
Distribution header.
SetNonBlocking enables (if f l ag isnonzero) or disables(if f l ag is0) non-blocking I/O on the indicated descriptor. It returns
1 on failure and 0 on success.
LockFile triesto lock the file descriptor f d. If f l ag isnonzero it will block until the lock can be made; otherwise it will return
1 if the file cannot be locked. It returns1 on failure and 0 on success.
GetConfigValue returnsthe value of the specified configuration parameter. (See inn.conf(5) for detailson the parametersand
their interpretation.) The returned value pointsto static space that isreused on subsequent calls.
GetFileConfigValue returnsthe specified configuration parameter from the inn.conf file without checking for any defaults.
The returned value pointsto static space that isreused on subsequent calls, or NULL if the value isnot present.
GetFQDN returnsthe fully qualified domain name of the local host. The returned value pointsto static space that isreused on
subsequent calls, or NULL on error.
GetModeratorAddress returnsthe mailing addressof the moderator for the specified gr oup or NULL on error. (See moderators(5)
for detailson how the addressisdetermined.) GetModeratorAddress doesno checking to see if the specified group isactually
moderated. The returned value pointsto static space that isreused on subsequent calls.
GetResourceUsage fillsin the user t i me and syst i me parameterswith the total user and system time used by the current process
and any children it may have spawned. It getsthe valuesby doing a times(2) system call. It returns1 on failure, or 0 on
success.
GetTimeInfo fillsin the now parameter with information about the current time and t zone. The t i me and usec fieldswill be
filled in by a call to gettimeofday(2). The t i me field will be filled in by a call to time(2), and the usec field will be set to 0. The
t zone field will be filled in with the current offset from GMT. Thisisdone by calling localtime(3) and taking the value of
the t m_gmt of f field, negating it, and dividing it by 60. Thisisdone by calling localtime(3) and comparing the value with that
returned by a call to gmtime(3). For efficiency, the t zone field isonly recalculated if more than an hour haspassed since the
last time GetTimeInfo wascalled. Thisroutine returns1 on failure, and 0 on success.
NNTPlocalopen opensa connection to the private port of an InterNetNewsserver running on the local host. It returns1 on
failure, or 0 on success. Fr omSer ver p and ToSer ver p will be filled in with FILEsthat can be used to communicate with the
server. er r buf f can either be NULL or a pointer to a buffer at least 512 byteslong. If it isnot NULL, and the server refusesthe
connection, it will be filled in with the text of the serversreply. Thisroutine isnot for general use; it isa subroutine for
compatibility with systemsthat have UNIX-domain stream sockets. It alwaysreturns1.
NNTPremoteopen doesthe same asNNTPlocalopen, except that it callsGetConfigValue to find the name of the local server and
opensa connection to the standard NNTP port. Any client program can use thisroutine. It returns1 on failure, or 0 on
success.
NNTPconnect isthe same asNNTPremoteopen, except that the desired host isgiven asthe host parameter.
NNTPcheckarticle verifiesthat the text meetsthe NNTP limitationson line length. It returns1 on failure, or 0 if the text is
valid.
libinn
Part III: Library Functions
966
NNTPsendarticle writestext on ToSer ver using NNTP conventionsfor line termination. The text should consist of one or
more linesending with a newline. If Ter mi nat e isnonzero, the routine will also write the NNTP data-termination marker on
the stream. It returns1 on failure, or 0 on success.
NNTPsendpassword sendsauthentication information to an NNTP server by finding the appropriate entry in the
passwd.nntp(5) file. ser ver containsthe name of the host; GetConfigValue will be used if server isNULL. Fr omSer ver and
ToSer ver should be FILEsthat are connected to the server. No action istaken if the specified host isnot listed in the password
file.
Radix32 convertsthe number in val ue into a radix-32 string in the buffer pointed to by p. The number issplit into five-bit
pieces, and each piece isconverted into a character using the alphabet 09av to represent the numbers032. Only the
lowest 32 bitsof val ue are used, so p need only point to a buffer of eight bytes(seven charactersand the trailing \0).
ReadInFile readsthe file named name into allocated memory, appending a terminating \0 byte. It returnsa pointer to the
space, or NULL on error. If Sbp isnot NULL, it istaken asthe addressof a place to store the resultsof a stat(2) call.
ReadInDescriptor performsthe same function asReadInFile, except that fd refersto an already-open file.
INNVersion returnsa pointer to a string identifying the INN version, suitable for printing in logon banners.
EXAMPLES
char *p;
char *Ar t i cl e;
char buf f [ 256] ;
FILE *F;
FILE *ToSer ver ;
FILE *Fr omSer ver ;
if ((p = HeaderFind(Ar t i cl e, From, 4)) == NULL)
Fatal(Cant find From line);
(void)strcpy(buf f , p);
HeaderCleanFrom(buf f );
if ((F = CAopen(Fr omSer ver , ToSer ver )) == NULL)
Fatal(Cant open active file);
/* Dont pass the file on to our children. */
CloseOnExec(fileno(F), 1);
/* Make a local copy. */
p = ReadInDescriptor(fileno(F), (struct stat *)NULL);
/* Close the file. */
CAclose();
if (NNTPremoteopen(&Fr omSer ver , &ToSer ver ) < 0)
Fatal(Cant connect to server);
if ((p = GetModeratorAddress(comp.sources.unix)) == NULL)
Fatal(Cant find moderators address);
HISTORY
Written by Rich $alz (rsalz@uunet.uu.net) for InterNetNews.
SEE ALSO
active(5), dbz(3z), parsedate(3), inn.conf(5), inndcomm(3), moderators(5), passwd.nntp(5)
GNU, 30 October 1996
libpbm
libpbmFunctionsto support portable bitmap programs
967
SYNOPSIS
#include <pbm.h>
cc ... libpbm.a
DESCRIPTIONPACKAGEWIDE ROUTINES
The following sectionsdescribe string and file management routinesavailable in libpbm.
KEYWORD MATCHING
The following doesa case-insensitive match of st r against keywor d:
int pm_keymatch( char* st r , char* keywor d, int mi nchar s )
st r can be a leading substring of keywor d, but at least mi nchar s must be present.
LOG BASE TWO
Thisconvertsbetween a maxval and the minimum number of bitsrequired to hold it:
int pm_maxvaltobits(int maxval )
int pm_bitstomaxval(int bi t s)
MESSAGES AND ERRORS
Thisisa printf()-style routine to write an informational message:
void pm_message(char* f mt , ... )
Thisisa printf() style routine to write an error message and abort:
void pm_error(char* f mt , ... )
The following writesa usage message; the string should indicate what argumentsare to be provided to the program:
void pm_usage(char* usage)
GENERIC FILE MANAGEMENT
The following opensthe given file for reading, with appropriate error checking:
FILE* pm_openr(char* name)
A filename of - istaken asequivalent to stdin.
The following opensthe given file for writing, with appropriate error checking:
FILE* pm_openw(char* name)
The following closesthe file descriptor, with appropriate error checking:
void pm_close(FILE* f p)
ENDIAN I/O
The following are routinesto read and write short and long intsin either big- or little-endian byte order:
int pm_readbigshort(FILE* i n, short* sP)
int pm_writebigshort(FILE* out , short s)
int pm_readbiglong(FILE* i n, long* l P)
int pm_writebiglong(FILE* out , long l )
int pm_readlittleshort(FILE* i n, short* sP)
int pm_writelittleshort(FILE* out , short s )
int pm_readlittlelong(FILE* i n, long* l P)
int pm_writelittlelong(FILE* out , long l )
DESCRIPTIONPBM-SPECIFIC ROUTINES
The following sectionsdescribe file management routinesavailable in libpbm.
libpbm
Part III: Library Functions
968
TYPES AND CONSTANTS
Each bit should contain only the valuesof PBM_WHITE or PBM_BLACK:
typedef ... bi t ;
#define PBM_WHITE ...
#define PBM_BLACK ...
These are routinesfor distinguishing different file formatsand types:
#define PBM_FORMAT ...
#define RPBM_FORMAT ...
#define PBM_TYPE PBM_FORMAT
#define PBM_FORMAT TYPE(f ) ...
INITIALIZATION
All PBM programsmust call thisroutine:
void pbm_init(int* ar gcP, char* ar gv[ ] )
MEMORY MANAGEMENT
Thisallocatesan array of bits:
bit** pbm_allocarray(int col s, int r ows)
Thisallocatesa row of the given number of bits:
bit* pbm_allocrow(int col s)
Thisfreesthe array allocated with pbm_allocarray() containing the given number of rows:
void pbm_freearray(bit** bi t s, int r ows)
Thisfreesa row of bits:
void pbm_freerow(bit* bi t r ow)
READING FILES
Thisreadsthe header from a PBM file, filling in the r ows , col s, and f or mat variables:
void pbm_readpbminit(FILE* f p, int* col sP, int* r owsP, int* f or mat P)
Thisreadsa row of bitsinto the bi t r ow array (f or mat and col s are filled in by pbm_readpbminit()):
void pbm_readpbmrow(FILE* f p, bit* bi t r ow, int col s, int f or mat )
Thisfunction combinespbm_readpbminit(), pbm_allocarray(), and pbm_readpbmrow():
bit** pbm_readpbm(FILE* f p, int* col sP, int* r owsP)
It readsan entire bitmap file into memory, returning the allocated array and filling in the r ows and col s variables.
Thisreadsan entire file or input stream of unknown size to a buffer and allocatesmore memory asneeded:
char* pm_read unknown size(FILE* f p, long* nr ead)
The calling routine hasto free the allocated buffer with free(). pm_read_unknown_size() returnsa pointer to the allocated
buffer; the nr ead argument returnsthe number of bytesread.
WRITING FILES
Thiswritesthe header for a portable bitmap file:
void pbm_writepbminit(FILE* f p, int col s, int r ows, int f or cepl ai n)
The f or cepl ai n flag forcesa plain-format file to be written, asopposed to a raw-format one.
Thiswritesa row from a portable bitmap:
void pbm_writepbmrow(FILE* f p, bit* bi t r ow, int col s, int f or cepl ai n)
969
Thiswritesthe header and all data for a portable bitmap:
void pbm_writepbm(FILE* f p, bit** bi t s, int col s, int r ows , int f or cepl ai n)
Thisfunction combinespbm_writepbminit() and pbm_writepbmrow().
SEE ALSO
libpgm(3), libppm(3), libpnm(3)
AUTHOR
Copyright