1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
|
.\" $OpenBSD: stty.1,v 1.40 2014/05/28 17:34:10 jmc Exp $
.\" $NetBSD: stty.1,v 1.10 1995/09/07 06:57:14 jtc Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)stty.1 8.5 (Berkeley) 6/1/94
.\"
.Dd $Mdocdate: May 28 2014 $
.Dt STTY 1
.Os
.Sh NAME
.Nm stty
.Nd set the options for a terminal device interface
.Sh SYNOPSIS
.Nm stty
.Op Fl a | Fl e | Fl g
.Op Fl f Ar file
.Op Ar operands
.Sh DESCRIPTION
The
.Nm
utility sets or reports on terminal
characteristics for the device that is its standard input.
If no options or operands are specified, it reports the settings of a subset
of characteristics as well as additional ones if they differ from their
default values.
Otherwise it modifies
the terminal state according to the specified arguments.
Some combinations of arguments are mutually
exclusive on some terminal types.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl a
Display all the current settings for the terminal to standard output
as per
.St -p1003.2 .
.It Fl e
Display all the current settings for the terminal to standard output
in the traditional
.Bx
.Dq all
and
.Dq everything
formats.
.It Fl f Ar file
Open and use the terminal named by
.Ar file
rather than using standard input.
The file is opened using the
.Dv O_NONBLOCK
flag of
.Xr open 2 ,
making it possible to
set or display settings on a terminal that might otherwise
block on the open.
.It Fl g
Display all the current settings for the terminal to standard output
in a form that may be used as an argument to a subsequent invocation of
.Nm
to restore the current terminal state as per
.St -p1003.2 .
.El
.Pp
The following arguments are available to set the terminal
characteristics:
.Ss Control modes
Control mode flags affect hardware characteristics associated with the
terminal.
This corresponds to the
.Li c_cflag
in the termios structure.
.Bl -tag -width Fl
.It Cm parenb Pq Fl parenb
Enable (disable) parity generation
and detection.
.It Cm parodd Pq Fl parodd
Select odd (even) parity.
.It Cm cs5 cs6 cs7 cs8
Select character size, if possible.
.It Ar number
Set terminal baud rate to the
number given, if possible.
If the
baud rate is set to zero, modem
control is no longer
asserted.
.It Cm ispeed Ar number
Set terminal input baud rate to the
number given, if possible.
If the
input baud rate is set to zero, the
input baud rate is set to the
value of the output baud
rate.
.It Cm ospeed Ar number
Set terminal output baud rate to
the number given, if possible.
If
the output baud rate is set to
zero, modem control is
no longer asserted.
.It Cm speed Ar number
This sets both
.Cm ispeed
and
.Cm ospeed
to
.Ar number .
.It Cm hupcl Pq Fl hupcl
Stop asserting modem control
(do not stop asserting modem control) on last close.
.It Cm hup Pq Fl hup
Same as
.Cm hupcl
.Pq Fl hupcl .
.It Cm cstopb Pq Fl cstopb
Use two (one) stop bits per character.
.It Cm cread Pq Fl cread
Enable (disable) the receiver.
.It Cm clocal Pq Fl clocal
Assume a line without (with) modem
control.
.It Cm crtscts Pq Fl crtscts
Enable (disable) RTS/CTS flow control.
.El
.Ss Input modes
This corresponds to the
.Li c_iflag
in the termios structure.
.Bl -tag -width Fl
.It Cm ignbrk Pq Fl ignbrk
Ignore (do not ignore) break on
input.
.It Cm brkint Pq Fl brkint
Signal (do not signal)
.Dv INTR
on
break.
.It Cm ignpar Pq Fl ignpar
Ignore (do not ignore) parity
errors.
.It Cm parmrk Pq Fl parmrk
Mark (do not mark) parity errors.
.It Cm inpck Pq Fl inpck
Enable (disable) input parity
checking.
.It Cm istrip Pq Fl istrip
Strip (do not strip) input characters
to seven bits.
.It Cm inlcr Pq Fl inlcr
Map (do not map)
.Dv NL
to
.Dv CR
on input.
.It Cm igncr Pq Fl igncr
Ignore (do not ignore)
.Dv CR
on input.
.It Cm icrnl Pq Fl icrnl
Map (do not map)
.Dv CR
to
.Dv NL
on input.
.It Cm iuclc Pq Fl iuclc
Translate (do not translate) upper case to lower case
on input.
.It Cm ixon Pq Fl ixon
Enable (disable)
.Dv START/STOP
output
control.
Output from the system is
stopped when the system receives
.Dv STOP
and started when the system
receives
.Dv START ,
or if
.Cm ixany
is set, any character restarts output.
.It Cm ixoff Pq Fl ixoff
Request that the system send (not
send)
.Dv START/STOP
characters when
the input queue is nearly
empty/full.
.It Cm ixany Pq Fl ixany
Allow any character (allow only
.Dv START )
to restart output.
.It Cm imaxbel Pq Fl imaxbel
The system imposes a limit of
.Dv MAX_INPUT
(currently 255) characters in the input queue.
If
.Cm imaxbel
is set and the input queue limit has been reached,
subsequent input causes the system to send an ASCII BEL
character to the output queue (the terminal beeps at you).
Otherwise, if
.Cm imaxbel
is unset and the input queue is full, the next input character causes
the entire input and output queues to be discarded.
.El
.Ss Output modes
This corresponds to the
.Li c_oflag
of the termios structure.
.Bl -tag -width Fl
.It Cm opost Pq Fl opost
Post-process output (do not
post-process output; ignore all other
output modes).
.It Cm onlcr Pq Fl onlcr
Map (do not map)
.Dv NL
to
.Dv CR-NL
on output.
.It Cm ocrnl Pq Fl ocrnl
Translate (do not translate) carriage return to newline on output.
.It Cm onocr Pq Fl onocr
Carriage return is not output (is output) at column 0.
.It Cm onlret Pq Fl onlret
Newline performs (does not perform) carriage return on output.
.It Cm olcuc Pq Fl olcuc
Translate (do not translate) lower case to upper case on output.
.It Cm oxtabs Pq Fl oxtabs
Expand (do not expand) tabs to spaces on output.
.It Cm onoeot Pq Fl onoeot
Discard (do not discard) EOFs on output.
.El
.Ss Local modes
Local mode flags (lflags) affect various and sundry characteristics of terminal
processing.
Historically the term "local" pertained to new job control features
implemented by Jim Kulp on a
.Tn Pdp 11/70
at
.Tn IIASA .
Later the driver ran on the first
.Tn VAX
at Evans Hall, UC Berkeley, where the job control details
were greatly modified but the structure definitions and names
remained essentially unchanged.
The second interpretation of the
.Sq l
in lflag is
.Dq line discipline flag
which corresponds to the
.Li c_lflag
of the termios structure.
.Bl -tag -width Fl
.It Cm isig Pq Fl isig
Enable (disable) the checking of
characters against the special control
characters
.Dv INTR , QUIT ,
and
.Dv SUSP .
.It Cm icanon Pq Fl icanon
Enable (disable) canonical input
.Pf ( Dv ERASE
and
.Dv KILL
processing).
.It Cm iexten Pq Fl iexten
Enable (disable) any implementation
defined special control characters
not currently controlled by
.Cm icanon ,
.Cm isig ,
or
.Cm ixon .
.It Cm echo Pq Fl echo
Echo back (do not echo back) every
character typed.
.It Cm echoe Pq Fl echoe
The
.Dv ERASE
character shall (shall
not) visually erase the last character
in the current line from the
display, if possible.
.It Cm echok Pq Fl echok
Echo (do not echo)
.Dv NL
after
.Dv KILL
character.
.It Cm echoke Pq Fl echoke
The
.Dv KILL
character shall (shall
not) visually erase the
current line from the
display, if possible.
.It Cm echonl Pq Fl echonl
Echo (do not echo)
.Dv NL ,
even if echo
is disabled.
.It Cm echoctl Pq Fl echoctl
If
.Cm echoctl
is set, echo control characters as
.Ql ^X .
Otherwise control characters echo as themselves.
.It Cm echoprt Pq Fl echoprt
For printing terminals.
If set, echo erased characters backwards within
.Ql \e
and
.Ql / .
Otherwise, disable this feature.
.It Cm noflsh Pq Fl noflsh
Disable (enable) flush after
.Dv INTR , QUIT , SUSP .
.It Cm tostop Pq Fl tostop
Send (do not send)
.Dv SIGTTOU
for background output.
This causes background jobs to stop if they attempt
terminal output.
.It Cm altwerase Pq Fl altwerase
Use (do not use) an alternate word erase algorithm when processing
.Dv WERASE
characters.
This alternate algorithm considers sequences of
alphanumeric/underscores as words.
It also skips the first preceding character in its classification
(as a convenience since the one preceding character could have been
erased with simply an
.Dv ERASE
character).
.It Cm mdmbuf Pq Fl mdmbuf
If set, flow control output based on condition of Carrier Detect.
Otherwise
writes return an error if Carrier Detect is low (and Carrier is not being
ignored with the
.Dv CLOCAL
flag).
.It Cm flusho Pq Fl flusho
Indicates output is (is not) being discarded.
.It Cm pendin Pq Fl pendin
Indicates input is (is not) pending after a switch from non-canonical
to canonical mode and will be re-input when a read becomes pending
or more input arrives.
.It Cm xcase Pq Fl xcase
Upper and lower case is (is not) handled canonically on input and output
with
.Cm iuclc
and
.Cm olcuc .
.El
.Ss Control characters
.Bl -tag -width Fl
.It Ar control-character Ar string
Set
.Ar control-character
to
.Ar string .
If string is a single character,
the control character is set to
that character.
If string is the
two character sequence
.Ql ^-
or the string
.Dq undef
the control character
is disabled (i.e., set to
.Pf { Dv _POSIX_VDISABLE Ns } ) .
.Pp
Recognized control-characters:
.Bl -column "character" "Subscript" "Description"
.It Sy Control Ta Sy Subscript Ta Sy Description
.It Sy character Ta "" Ta ""
.It eof Ta Dv VEOF Ta "EOF character"
.It eol Ta Dv VEOL Ta "EOL character"
.It eol2 Ta Dv VEOL2 Ta "EOL2 character"
.It erase Ta Dv VERASE Ta "ERASE character"
.It werase Ta Dv VWERASE Ta "WERASE character"
.It intr Ta Dv VINTR Ta "INTR character"
.It kill Ta Dv VKILL Ta "KILL character"
.It quit Ta Dv VQUIT Ta "QUIT character"
.It susp Ta Dv VSUSP Ta "SUSP character"
.It start Ta Dv VSTART Ta "START character"
.It stop Ta Dv VSTOP Ta "STOP character"
.It dsusp Ta Dv VDSUSP Ta "DSUSP character"
.It lnext Ta Dv VLNEXT Ta "LNEXT character"
.It reprint Ta Dv VREPRINT Ta "REPRINT character"
.It status Ta Dv VSTATUS Ta "STATUS character"
.El
.It Cm min Ar number
.It Cm time Ar number
Set the value of min or time to
number.
.Dv MIN
and
.Dv TIME
are used in
non-canonical mode input processing
(-icanon).
.El
.Ss Combination modes
.Bl -tag -width Fl
.It Ar saved settings
Set the current terminal
characteristics to the saved settings
produced by the
.Fl g
option.
.It Cm evenp No or Cm parity
Enable parenb and cs7; disable
parodd.
.It Cm oddp
Enable
.Cm parenb ,
.Cm cs7 ,
and
.Cm parodd .
.It Fl parity , evenp , oddp
Disable
.Cm parenb
and set
.Cm cs8 .
.It Cm \&nl Pq Fl \&nl
Enable (disable)
.Cm icrnl .
In addition,
.Fl \&nl
unsets
.Cm inlcr
and
.Cm igncr .
.It Cm ek
Reset
.Dv ERASE
and
.Dv KILL
characters
back to system defaults.
.It Cm sane
Resets all modes to reasonable values for interactive terminal use.
.It Cm tty
Set the line discipline to the standard terminal line discipline
.Dv TTYDISC .
.It Cm crt Pq Fl crt
Set (disable) all modes suitable for a CRT display device.
.It Cm kerninfo Pq Fl kerninfo
Enable (disable) the system generated status line associated with
processing a
.Dv STATUS
character (usually set to
.Ql ^T ) .
The status line consists of the
system load average, the current command name, its process ID, the
event the process is waiting on (or the status of the process), the user
and system times, percent CPU, and current memory usage.
.It Cm columns Ar number
The terminal size is recorded as having
.Ar number
columns.
.It Cm cols Ar number
This is an alias for
.Cm columns .
.It Cm rows Ar number
The terminal size is recorded as having
.Ar number
rows.
.It Cm dec
Set modes suitable for users of Digital Equipment Corporation systems
.Pf ( Dv ERASE ,
.Dv KILL ,
and
.Dv INTR
characters are set to ^?, ^U, and ^C;
.Dv ixany
is disabled, and
.Dv crt
is enabled).
.It Cm extproc Pq Fl extproc
If set, this flag indicates that some amount of terminal processing is being
performed by either the terminal hardware or by the remote side connected
to a pty.
.It Cm raw Pq Fl raw
If set, change the modes of the terminal so that no input or output processing
is performed.
If unset, change the modes of the terminal to some reasonable
state that performs input and output processing.
Note that since the terminal driver no longer has a single
.Dv RAW
bit, it is not possible to intuit what flags were set prior to setting
.Cm raw .
This means that unsetting
.Cm raw
may not put back all the setting that were previously in effect.
To set the terminal into a raw state and then accurately restore it,
the following shell code is recommended:
.Bd -literal -offset indent
save_state=$(stty -g)
stty raw
\&...
stty "$save_state"
.Ed
.It Cm size
The size of the terminal is printed as two numbers on a single line,
first rows, then columns.
.El
.Ss Compatibility modes
These modes remain for compatibility with the previous version of
the stty command.
.Bl -tag -width Fl
.It Cm all
Reports all the terminal modes as with
.Cm stty Fl a
except that the control characters are printed in a columnar format.
.It Cm everything
Same as
.Cm all .
.It Cm cooked
Same as
.Cm sane .
.It Cm cbreak
If set, enables
.Cm brkint , ixon , imaxbel , opost ,
.Cm isig , iexten ,
and
.Fl icanon .
If unset, same as
.Cm sane .
.It Cm new
Same as
.Cm tty .
.It Cm old
Same as
.Cm tty .
.It Cm newcrt Pq Fl newcrt
Same as
.Cm crt .
.It Cm pass8
The converse of
.Cm parity .
.It Cm tandem Pq Fl tandem
Same as
.Cm ixoff .
.It Cm decctlq Pq Fl decctlq
The converse of
.Cm ixany .
.It Cm crterase Pq Fl crterase
Same as
.Cm echoe .
.It Cm crtbs Pq Fl crtbs
Same as
.Cm echoe .
.It Cm crtkill Pq Fl crtkill
Same as
.Cm echoke .
.It Cm ctlecho Pq Fl ctlecho
Same as
.Cm echoctl .
.It Cm prterase Pq Fl prterase
Same as
.Cm echoprt .
.It Cm lcase Pq Fl lcase
Same as
.Cm iuclc ,
.Cm olcuc
and
.Cm xcase .
.It Cm litout Pq Fl litout
The converse of
.Cm opost .
.It Cm tabs Pq Fl tabs
The converse of
.Cm oxtabs .
.It Cm brk Ar value
Same as the control character
.Cm eol .
.It Cm flush Ar value
Same as the control character
.Cm discard .
.It Cm rprnt Ar value
Same as the control character
.Cm reprint .
.El
.Ss Control operations
These operations are not modes, but rather commands to be performed by
the tty layer.
.Bl -tag -width Fl
.It Cm ostart
Performs a
.Dq start output
operation, as normally done by an
incoming
.Dv START
character when
.Cm ixon
is set.
.It Cm ostop
Performs a
.Dq stop output
operation, as normally done by an incoming
.Dv STOP
character when
.Cm ixon
is set.
.El
.Sh EXIT STATUS
.Ex -std stty
.Sh SEE ALSO
.Xr termios 4 ,
.Xr tty 4
.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -p1003.1-2008
specification.
.Pp
The flags
.Op Fl ef
and the operands
.Cm speed ,
.Cm crtscts ,
.Cm iuclc ,
.Cm imaxlabel ,
.Cm onlcr ,
.Cm olcuc ,
.Cm oxtabs ,
.Cm onoeot ,
.Cm echoke ,
.Cm altwerase ,
.Cm mdmbuf ,
.Cm flusho ,
.Cm pendin ,
.Cm xcase ,
.Cm tty ,
.Cm crt ,
.Cm kerninfo ,
.Cm columns ,
.Cm cols ,
.Cm rows ,
.Cm dec ,
.Cm extproc ,
.Cm raw ,
.Cm size ,
the compatibility modes and the control operations
are extensions to that specification.
.Sh HISTORY
A
.Nm
command appeared in
.At v3 .
|