STTY(1P)
β¨ STTY(1P) β¨ β coming at you straight from the POSIX Programmer's Manual, and yes bestie we are doing the WHOLE thing, no skimming, no skipping, every single flag gets its moment. π
π«Ά PROLOG π«Ά
okay so housekeeping first, it's giving legal-but-make-it-cute: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so like, go consult the corresponding Linux manual page for the tea on Linux behavior β or honestly the interface may not be implemented on Linux at all. π
π NAME π
stty β set the options for a terminal. that's the whole name section. short, sweet, iconic.
β¨ SYNOPSIS β¨
stty [-a|-g]
stty operand...
πΈ DESCRIPTION πΈ
So what does stty actually do? It sets or reports on terminal I/O characteristics for the device that is its standard input. that's the vibe. π
If you give it no options and no operands at all? It reports the settings of certain characteristics β usually the ones that differ from implementation-defined defaults. Otherwise, it modifies the terminal state according to whatever operands you handed it. π
Detailed info about the modes in the first five groups below lives in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface. The operands in the Combination Modes group (peep Combination Modes) are implemented using the operands from the previous groups, no cap. And heads up: some combinations of operands are mutually-exclusive on some terminal types, and the results of using such combos are unspecified. so like, don't be messy. π
Typical implementations of this utility require a communications line configured to use the termios interface defined in the System Interfaces volume of POSIX.1-2017. On systems where none of these lines are available, and on lines not currently configured to support the termios interface, some of the operands need not affect terminal characteristics. lowkey important, highkey boring, moving on. π
π OPTIONS π
The stty utility shall conform to the Base Definitions volume of POSIX.1-2017, Section 12.2, Utility Syntax Guidelines. (Yes, that's a real thing. Yes, it's just as glamorous as it sounds.)
The following options shall be supported:
-aβ write to standard output all the current settings for the terminal. everything. the whole closet. π-gβ write to standard output all the current settings in an unspecified form that can be used as arguments to another invocation of thesttyutility on the same system. and the form used shall not contain any characters that would require quoting to avoid word expansion by the shell β see Section 2.6, Word Expansions. so it's the "save your settings and replay them later" girlie. π¦
π§ OPERANDS π§
The following operands shall be supported to set the terminal characteristics. buckle up bestie, there are a LOT of them, and we're doing every single one.
π Control Modes π
parenb (-parenb)β enable (disable) parity generation and detection. this sets (or doesn't set, if you used the-form)PARENBin thetermiosc_cflagfield, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.parodd (-parodd)β pick odd (even) parity. that'sPARODDin thetermiosc_cflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.cs5cs6cs7cs8β select the character size, if possible. these setCS5,CS6,CS7, andCS8respectively in thetermiosc_cflagfield, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface. pick your fighter. βnumberβ set the terminal baud rate to the number given, if possible. and if the baud rate is set to zero, the modem control lines shall no longer be asserted. this sets the input and outputtermiosbaud rate values, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.ispeed numberβ set the terminal input baud rate to the number given, if possible. if the input baud rate is set to zero, the input baud rate shall be specified by the value of the output baud rate. this sets the inputtermiosbaud rate values, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.ospeed numberβ set the terminal output baud rate to the number given, if possible. if the output baud rate is set to zero, the modem control lines shall no longer be asserted. this sets the outputtermiosbaud rate values, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.hupcl (-hupcl)β stop asserting modem control lines (or don't stop asserting them) on last close.HUPCLin thetermiosc_cflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.hup (-hup)β equivalent tohupcl(-hupcl). the little shortcut. π«Άcstopb (-cstopb)β use two (one) stop bits per character.CSTOPBin thetermiosc_cflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.cread (-cread)β enable (disable) the receiver.CREADin thetermiosc_cflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.clocal (-clocal)β assume a line without (with) modem control.CLOCALin thetermiosc_cflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.
It is unspecified whether stty shall report an error if an attempt to set a Control Mode fails. so likeβ¦ maybe it yells, maybe it doesn't. we don't know. π
π Input Modes π
ignbrk (-ignbrk)β ignore (do not ignore) break on input. this sets (not sets)IGNBRKin thetermiosc_iflagfield, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.brkint (-brkint)β signal (do not signal)INTRon break. that'sBRKINTin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.ignpar (-ignpar)β ignore (do not ignore) bytes with parity errors.IGNPARin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.parmrk (-parmrk)β mark (do not mark) parity errors.PARMRKin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.inpck (-inpck)β enable (disable) input parity checking.INPCKin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.istrip (-istrip)β strip (do not strip) input characters down to seven bits.ISTRIPin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.inlcr (-inlcr)β map (do not map)NLtoCRon input.INLCRin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.igncr (-igncr)β ignore (do not ignore)CRon input.IGNCRin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.icrnl (-icrnl)β map (do not map)CRtoNLon input.ICRNLin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.ixon (-ixon)β enable (disable)START/STOPoutput control. output from the system is stopped when the system receivesSTOP, and started when the system receivesSTART.IXONin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.ixany (-ixany)β allow any character to restart output.IXANYin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.ixoff (-ixoff)β request that the system send (not send)STOPcharacters when the input queue is nearly full, plusSTARTcharacters to resume data transmission.IXOFFin thetermiosc_iflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.
π¦ Output Modes π¦
opost (-opost)β post-process output (do not post-process output; ignore all other output modes).OPOSTin thetermiosc_oflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.onlcr (-onlcr)β map (do not map)NLtoCR-NLon output.ONLCRin thetermiosc_oflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.ocrnl (-ocrnl)β map (do not map)CRtoNLon output.OCRNLin thetermiosc_oflagfield, set or not set, as defined in the Base Definitions volume of POSIX.1-2017, Chapter 11, General Terminal Interface.onocr,-onocrβ don't (do) drop a CR at column zero. Lowkey this flips ONOCR in the termiosc_oflagfield, exactly like the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface says. πonlret,-onlretβ the terminal's newline key does (doesn't) do the CR thing. Sets (or unsets) ONLRET in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. β¨ofill,-ofillβ use fill characters (or use timing) for delays. That's OFILL in termiosc_oflag, set (not set), per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πofdel,-ofdelβ fill characters are DELs (NULs). Sets (not sets) OFDEL in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πΈcr0cr1cr2cr3β pick the delay style for CRs. This sets CRDLY to CR0, CR1, CR2, or CR3 respectively, in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. π¦nl0nl1β pick the delay style for NL. Sets NLDLY to NL0 or NL1 respectively, in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. βtab0tab1tab2tab3β pick the delay style for horizontal tabs. Sets TABDLY to TAB0, TAB1, TAB2, or TAB3 respectively, in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. Heads up bestie: TAB3 has the effect of expanding<tab>characters to<space>characters. πtabs,-tabsβ just a synonym fortab0(tab3). πbs0bs1β pick the delay style for<backspace>characters. Sets BSDLY to BS0 or BS1 respectively, in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πff0ff1β pick the delay style for<form-feed>characters. Sets FFDLY to FF0 or FF1 respectively, in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πvt0vt1β pick the delay style for<vertical-tab>characters. Sets VTDLY to VT0 or VT1 respectively, in termiosc_oflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. β¨
π Local Modes π
isig,-isigβ turn on (off) checking characters against the special control characters INTR, QUIT, and SUSP. Sets (not sets) ISIG in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. π«Άicanon,-icanonβ turn on (off) canonical input, aka ERASE and KILL processing. Sets (not sets) ICANON in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πiexten,-iextenβ turn on (off) any implementation-defined special control characters that aren't currently controlled byicanon,isig,ixon, orixoff. Sets (not sets) IEXTEN in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. π¦echo,-echoβ echo back (don't echo back) every single character typed. Sets (not sets) ECHO in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πechoe,-echoeβ the ERASE character visually erases (doesn't erase) the last character in the current line from the display, if possible. Sets (not sets) ECHOE in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πΈechok,-echokβ echo (don't echo) NL after the KILL character. Sets (not sets) ECHOK in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. πechonl,-echonlβ echo (don't echo) NL even when echo is disabled. Sets (not sets) ECHONL in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. βnoflsh,-noflshβ disable (enable) flush after INTR, QUIT, SUSP. Sets (not sets) NOFLSH in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. π₯tostop,-tostopβ send SIGTTOU for background output. Sets (not sets) TOSTOP in termiosc_lflag, per the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface. π
π Special Control Character Assignments π
<control>βcharacter string
Set <control>βcharacter to string. If <control>βcharacter is one of the character sequences in the first column of the table below, then the matching Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface control character from the second column gets recognized. This has the effect of setting the corresponding element of the termios c_cc array (peep the Base Definitions volume of POSIX.1β2017, Chapter 13, Headers, <termios.h>). β¨
Table: Control Character Names in stty
eofβ c_cc Subscript:VEOFβ EOF charactereolβ c_cc Subscript:VEOLβ EOL charactereraseβ c_cc Subscript:VERASEβ ERASE characterintrβ c_cc Subscript:VINTRβ INTR characterkillβ c_cc Subscript:VKILLβ KILL characterquitβ c_cc Subscript:VQUITβ QUIT charactersuspβ c_cc Subscript:VSUSPβ SUSP characterstartβ c_cc Subscript:VSTARTβ START characterstopβ c_cc Subscript:VSTOPβ STOP character
If string is a single character, the control character shall be set to that character. If string is the two-character sequence "^-" or the string undef, the control character shall be set to _POSIX_VDISABLE, if it's in effect for the device; but if _POSIX_VDISABLE is not in effect for the device, it shall be treated as an error. π¨
In the POSIX locale, if string is a two-character sequence beginning with <circumflex> ('^'), and the second character is one of those listed in the "^c" column of the table below, the control character shall be set to the corresponding character value in the Value column. π
Table: Circumflex Control Characters in stty
a, Aβ<SOH>b, Bβ<STX>c, Cβ<ETX>d, Dβ<EOT>e, Eβ<ENQ>f, Fβ<ACK>g, Gβ<BEL>h, Hβ<BS>i, Iβ<HT>j, Jβ<LF>k, Kβ<VT>l, Lβ<FF>m, Mβ<CR>n, Nβ<SO>o, Oβ<SI>p, Pβ<DLE>q, Qβ<DC1>r, Rβ<DC2>s, Sβ<DC3>t, Tβ<DC4>u, Uβ<NAK>v, Vβ<SYN>w, Wβ<ETB>x, Xβ<CAN>y, Yβ<EM>z, Zβ<SUB>[β<ESC>\β<FS>]β<GS>^β<RS>_β<US>?β<DEL>
min number
Set the value of MIN to number. MIN is used in non-canonical mode input processing (icanon). πΈ
time number
Set the value of TIME to number. TIME is used in non-canonical mode input processing (icanon). β
π¦ Combination Modes π¦
saved settings
Set the current terminal characteristics to the saved settings produced by the -g option. π
evenporparityβ flip onparenbandcs7, flip offparodd. β¨oddpβ flip onparenb,cs7, andparodd. bestie it's the odd one out π-parity,-evenp, or-oddpβ flip offparenband setcs8. bye parity πraw(-raworcooked) β turn raw input and output on (or off, respectively). Raw mode is equivalent to setting exactly this:
stty cs8 erase ^- kill ^- intr ^- \
quit ^- eof ^- eol ^- -post -inpck
nl(-nl) β disable (enable)icrnl. and like, as a lil bonus,-nlalso unsetsinlcrandigncrπekβ reset the ERASE and KILL characters back to the system defaults. fresh start fr π¦saneβ reset all modes to some reasonable, unspecified, values. the ultimate glow-up β¨π§
π STDIN π
okay so even though nothing actually gets read from standard input, standard input is still the thing that's used to grab the current terminal I/O characteristics and to set the new terminal I/O characteristics. it's giving behind-the-scenes main character energy. π
π INPUT FILES π
None. literally none. empty. nada. the void. π
π ENVIRONMENT VARIABLES π
these variables affect how stty runs, bestie:
LANGβ provides a default value for the internationalization variables that are unset or null. (see the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) π«ΆLC_ALLβ if it's set to a non-empty string value, it overrides the values of all the other internationalization variables. it said "i'm the captain now" πLC_CTYPEβ this one determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments) and which characters are in the classprint.LC_MESSAGESβ determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHβ determines the location of message catalogs for the processing ofLC_MESSAGES. β¨
πΈ ASYNCHRONOUS EVENTS πΈ
Default. that's it, that's the section. π
β STDOUT β
if operands are specified, no output shall be produced. silence. iconic. π€«
if the -g option is specified, stty shall write to standard output the current settings in a form that can be used as arguments to another instance of stty on the same system. copy-paste-able slay. πΎ
if the -a option is specified, all of the information as described in the OPERANDS section shall be written to standard output. Unless otherwise specified, this information shall be written as <space>-separated tokens in an unspecified format, on one or more lines, with an unspecified number of tokens per line. Additional information may be written. no cap, it's vague on purpose. π
if no options or operands are specified, an unspecified subset of the information written for the -a option shall be written.
if speed information is written as part of the default output, or if the -a option is specified and if the terminal input speed and output speed are the same, the speed information shall be written as follows:
"speed %d baud;", <speed>
otherwise, speeds shall be written as:
"ispeed %d baud; ospeed %d baud;", <ispeed>, <ospeed>
in locales other than the POSIX locale, the word baud may be changed to something more appropriate in those locales. β¨ localization ate. π
if control characters are written as part of the default output, or if the -a option is specified, control characters shall be written as:
"%s = %s;", <control-character name>, <value>
where <value> is either the character, or some visual representation of the character if it is non-printable, or the string undef if the character is disabled. π
π STDERR π
the standard error shall be used only for diagnostic messages. that's its whole job bestie. π’
π OUTPUT FILES π
None. again. the emptiness is the vibe. π³οΈ
π§ EXTENDED DESCRIPTION π§
None.
π₯ EXIT STATUS π₯
the following exit values shall be returned:
0β the terminal options were read or set successfully. we love a win π>0β an error occurred. π
π CONSEQUENCES OF ERRORS π
Default.
heads up bestie: the following sections are informative. (not normative, just so you know the vibe.) π
π APPLICATION USAGE π
the -g flag is designed to facilitate the saving and restoring of terminal state from the shell level. for example, a program may:
saveterm="$(stty -g)" # save terminal state
stty (new settings) # set new state
... # ...
stty $saveterm # restore terminal state
since the format is unspecified, the saved value is not portable across systems. π don't be out here copying it between machines, fr.
since the -a format is so loosely specified, scripts that save and restore terminal settings should use the -g option. periodt. π
π¦ EXAMPLES π¦
None. π
π RATIONALE π
the original stty description was taken directly from System V and reflected the System V terminal driver termio. It has been modified to correspond to the terminal driver termios. glow-up complete. β¨
output modes are specified only for XSI-conformant systems. All implementations are expected to provide stty operands corresponding to all of the output modes they support.
the stty utility is primarily used to tailor the user interface of the terminal, such as selecting the preferred ERASE and KILL characters. As an application programming utility, stty can be used within shell scripts to alter the terminal settings for the duration of the script.
the termios section states that individual disabling of control characters is possible through the option _POSIX_VDISABLE. If enabled, two conventions currently exist for specifying this: System V uses "^-", and BSD uses undef. Both are accepted by stty in this volume of POSIX.1β2017. The other BSD convention of using the letter 'u' was rejected because it conflicts with the actual letter 'u', which is an acceptable value for a control character. bestie the letter u said "not today" π
ββοΈ
early proposals did not specify the mapping of "^c" to control characters because the control characters were not specified in the POSIX locale character set description file requirements. The control character set is now specified in the Base Definitions volume of POSIX.1β2017, Chapter 3, Definitions, so the historical mapping is specified. Note that although the mapping corresponds to control-character key assignments on many terminals that use the ISO/IEC 646:1991 standard (or ASCII) character encodings, the mapping specified here is to the control characters, not their keyboard encodings. iykyk β¨οΈ
since termios supports separate speeds for input and output, two new options were added to specify each distinctly. β¨
some historical implementations use standard input to get and set terminal characteristics; others use standard output. Since input from a login TTY is usually restricted to the owner while output to a TTY is frequently open to anyone, using standard input provides fewer chances of accidentally (or maliciously) altering the terminal settings of other users. Using standard input also allows stty -a and stty -g output to be redirected for later use. Therefore, usage of standard input is required by this volume of POSIX.1β2017. safety first bestie, no cap. π
π FUTURE DIRECTIONS π
None.
π«Ά SEE ALSO π«Ά
- Chapter 2, Shell Command Language
- The Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Chapter 11, General Terminal Interface, Section 12.2, Utility Syntax Guidelines,
<termios.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! π source/version is IEEE/The Open Group and the date is 2017, for STTY(1P) β thanks for reading the whole thing, you ate that. mwah. π β¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms