STTY(1POSIX)
๐ STTY(1POSIX) ๐ โ set the options for a terminal ๐
๐ธ PROLOG ๐ธ
okay bestie, so this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ โ so pls consult the corresponding Linux manual page for details of Linux behavior โ or the interface may not be implemented on Linux at all. no cap, that's just how it is. ๐
โจ NAME โจ
stty โ set the options for a terminal ๐
๐ฆ SYNOPSIS ๐ฆ
stty [-a|-g]
stty operand...
๐ DESCRIPTION ๐
The stty utility shall set or report on terminal I/O characteristics for the device that is its standard input. periodt.
Without options or operands specified, it shall report the settings of certain characteristics, usually those that differ from implementation-defined defaults. like, it's giving "here's what's weird about your terminal right now" energy.
Otherwise, it shall modify the terminal state according to the specified operands. ๐ฅ
Detailed information about the modes listed in the first five groups below are described in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. iykyk.
Operands in the Combination Modes group (see Combination Modes) are implemented using operands in the previous groups. Some combinations of operands are mutually-exclusive on some terminal types; the results of using such combinations are unspecified. so like, don't do that unless you enjoy chaos. ๐
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, bestie.
๐ OPTIONS ๐
The stty utility shall conform to the Base Definitions volume of POSIX.1โ2017, Section 12.2, Utility Syntax Guidelines. slay.
The following options shall be supported:
-aโ Write to standard output all the current settings for the terminal. the full tea โ-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. 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 copy-paste friendly, no quotes needed ๐
๐ซถ OPERANDS ๐ซถ
The following operands shall be supported to set the terminal characteristics. let's get into it.
๐ Control Modes ๐
All of these Control Mode bits live in thetermiosc_cflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. I'm saying it once here so I don't have to retype the whole citation every single bullet, bestie. It applies to literally all of them. ๐
parenb,-parenbโ Enable (disable) parity generation and detection. This shall have the effect of setting (not setting)PARENBin thetermiosc_cflagfield. parity tea.parodd,-paroddโ Select odd (even) parity. This shall have the effect of setting (not setting)PARODDin thetermiosc_cflagfield. odd one out energy.cs5,cs6,cs7,cs8โ Select character size, if possible. This shall have the effect of settingCS5,CS6,CS7, andCS8, respectively, in thetermiosc_cflagfield. pick your bits, bestie.numberโ Set terminal baud rate to the number given, if possible. If the baud rate is set to zero, the modem control lines shall no longer be asserted. This shall have the effect of setting the input and outputtermiosbaud rate values. zero means no modem lines, periodt.ispeednumber โ Set 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 shall have the effect of setting the inputtermiosbaud rate values. input speed only.ospeednumber โ Set 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 shall have the effect of setting the outputtermiosbaud rate values. output speed only.hupcl,-hupclโ Stop asserting modem control lines (do not stop asserting modem control lines) on last close. This shall have the effect of setting (not setting)HUPCLin thetermiosc_cflagfield. last close drama.hup,-hupโ Equivalent tohupcl(-hupcl). same vibe, shorter name.cstopb,-cstopbโ Use two (one) stop bits per character. This shall have the effect of setting (not setting)CSTOPBin thetermiosc_cflagfield. two bits or one bit, choose.cread,-creadโ Enable (disable) the receiver. This shall have the effect of setting (not setting)CREADin thetermiosc_cflagfield. receiver on/off.clocal,-clocalโ Assume a line without (with) modem control. This shall have the effect of setting (not setting)CLOCALin thetermiosc_cflagfield. modem control? not today.
It is unspecified whether stty shall report an error if an attempt to set a Control Mode fails. so like, it might error, it might not. chaos. ๐
๐ธ Input Modes ๐ธ
All of these Input Mode bits live in thetermiosc_iflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. same citation energy, bestie. ๐
ignbrk,-ignbrkโ Ignore (do not ignore) break on input. This shall have the effect of setting (not setting)IGNBRKin thetermiosc_iflagfield. break? ignored.brkint,-brkintโ Signal (do not signal)INTRon break. This shall have the effect of setting (not setting)BRKINTin thetermiosc_iflagfield. interrupt on break, or not.ignpar,-ignparโ Ignore (do not ignore) bytes with parity errors. This shall have the effect of setting (not setting)IGNPARin thetermiosc_iflagfield. parity errors? bye.parmrk,-parmrkโ Mark (do not mark) parity errors. This shall have the effect of setting (not setting)PARMRKin thetermiosc_iflagfield. mark it.inpck,-inpckโ Enable (disable) input parity checking. This shall have the effect of setting (not setting)INPCKin thetermiosc_iflagfield. check the parity, bestie.istrip,-istripโ Strip (do not strip) input characters to seven bits. This shall have the effect of setting (not setting)ISTRIPin thetermiosc_iflagfield. seven bits only.inlcr,-inlcrโ Map (do not map)NLtoCRon input. This shall have the effect of setting (not setting)INLCRin thetermiosc_iflagfield. newline to carriage return.igncr,-igncrโ Ignore (do not ignore)CRon input. This shall have the effect of setting (not setting)IGNCRin thetermiosc_iflagfield. carriage return? ignored.icrnl,-icrnlโ Map (do not map)CRtoNLon input. This shall have the effect of setting (not setting)ICRNLin thetermiosc_iflagfield. carriage return to newline.ixon,-ixonโ Enable (disable)START/STOPoutput control. Output from the system is stopped when the system receivesSTOPand started when the system receivesSTART. This shall have the effect of setting (not setting)IXONin thetermiosc_iflagfield. flow control vibes.ixany,-ixanyโ Allow any character to restart output. This shall have the effect of setting (not setting)IXANYin thetermiosc_iflagfield. any char can restart.ixoff,-ixoffโ Request that the system send (not send)STOPcharacters when the input queue is nearly full andSTARTcharacters to resume data transmission. This shall have the effect of setting (not setting)IXOFFin thetermiosc_iflagfield. queue full? send STOP.
๐ฆ Output Modes ๐ฆ
All of these Output Mode bits live in thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. same citation, bestie. ๐
opost,-opostโ Post-process output (do not post-process output; ignore all other output modes). This shall have the effect of setting (not setting)OPOSTin thetermiosc_oflagfield. post-processing on/off.onlcr,-onlcrโ Map (do not map)NLtoCR-NLon output. This shall have the effect of setting (not setting)ONLCRin thetermiosc_oflagfield. newline to CR-NL.ocrnl,-ocrnlโ Map (do not map)CRtoNLon output. This shall have the effect of setting (not setting)OCRNLin thetermiosc_oflagfield. CR to NL on output.
okay bestie, we're still deep in the option buffet and it's giving terminal lore โ no cap, every single flag matters, so let's go ๐ โจ
onocr,-onocrโ Do not (do) output CR at column zero. This shall have the effect of setting (not setting)ONOCRin thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐onlret,-onlretโ The terminal newline key performs (does not perform) the CR function. This shall have the effect of setting (not setting)ONLRETin thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ofill,-ofillโ Use fill characters (use timing) for delays. This shall have the effect of setting (not setting)OFILLin thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ธofdel,-ofdelโ Fill characters are DELs (NULs). This shall have the effect of setting (not setting)OFDELin thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ฆcr0,cr1,cr2,cr3โ Select the style of delay for CRs. This shall have the effect of settingCRDLYtoCR0,CR1,CR2, orCR3, respectively, in thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. โจnl0,nl1โ Select the style of delay for NL. This shall have the effect of settingNLDLYtoNL0orNL1, respectively, in thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐tab0,tab1,tab2,tab3โ Select the style of delay for horizontal tabs. This shall have the effect of settingTABDLYtoTAB0,TAB1,TAB2, orTAB3, respectively, in thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. Note thatTAB3has the effect of expanding<tab>characters to<space>characters. ๐ฅtabs,-tabsโ Synonym fortab0(tab3). ๐ซถbs0,bs1โ Select the style of delay for<backspace>characters. This shall have the effect of settingBSDLYtoBS0orBS1, respectively, in thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ff0,ff1โ Select the style of delay for<form-feed>characters. This shall have the effect of settingFFDLYtoFF0orFF1, respectively, in thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐vt0,vt1โ Select the style of delay for<vertical-tab>characters. This shall have the effect of settingVTDLYtoVT0orVT1, respectively, in thetermiosc_oflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. โญ
โจ Local Modes โจ
isig,-isigโ Enable (disable) the checking of characters against the special control charactersINTR,QUIT, andSUSP. This shall have the effect of setting (not setting)ISIGin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ญicanon,-icanonโ Enable (disable) canonical input (ERASEandKILLprocessing). This shall have the effect of setting (not setting)ICANONin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐iexten,-iextenโ Enable (disable) any implementation-defined special control characters not currently controlled byicanon,isig,ixon, orixoff. This shall have the effect of setting (not setting)IEXTENin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐echo,-echoโ Echo back (do not echo back) every character typed. This shall have the effect of setting (not setting)ECHOin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ธechoe,-echoeโ TheERASEcharacter visually erases (does not erase) the last character in the current line from the display, if possible. This shall have the effect of setting (not setting)ECHOEin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ฆechok,-echokโ Echo (do not echo) NL afterKILLcharacter. This shall have the effect of setting (not setting)ECHOKin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. โจechonl,-echonlโ Echo (do not echo) NL, even ifechois disabled. This shall have the effect of setting (not setting)ECHONLin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐noflsh,-noflshโ Disable (enable) flush afterINTR,QUIT,SUSP. This shall have the effect of setting (not setting)NOFLSHin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ฅtostop,-tostopโ SendSIGTTOUfor background output. This shall have the effect of setting (not setting)TOSTOPin thetermiosc_lflagfield, as defined in the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface. ๐ซถ
๐ Special Control Character Assignments ๐
<control>-character stringโ Set<control>-characterto string. If<control>-characteris one of the character sequences in the first column of the following table, the corresponding the Base Definitions volume of POSIX.1โ2017, Chapter 11, General Terminal Interface control character from the second column shall be recognized. This has the effect of setting the corresponding element of thetermiosc_ccarray (see the Base Definitions volume of POSIX.1โ2017, Chapter 13, Headers,<termios.h>). ๐
๐ฆ Control Character Names in stty ๐ฆ
eofโVEOFโ EOF charactereolโVEOLโ EOL charactereraseโVERASEโ ERASE characterintrโVINTRโ INTR characterkillโVKILLโ KILL characterquitโVQUITโ QUIT charactersuspโVSUSPโ SUSP characterstartโVSTARTโ START characterstopโ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 is in effect for the device; 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 following table, the control character shall be set to the corresponding character value in the Value column of the 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>minnumber โ Set the value ofMINto number.MINis used in non-canonical mode input processing (icanon). ๐ธtimenumber โ Set the value ofTIMEto number.TIMEis used in non-canonical mode input processing (icanon). ๐ฆ
๐ Combination Modes ๐
saved settingsโ Set the current terminal characteristics to the saved settings produced by the-goption. โจevenporparityโ turns onparenbandcs7, and turns offparodd. ๐oddpโ turns onparenb,cs7, andparodd. โจ-parity,-evenp, or-oddpโ turns offparenb, and setscs8. ๐raw(also-raworcooked) โ enables (or disables) raw input and output. Raw mode shall be equivalent to setting:
stty cs8 erase ^- kill ^- intr ^- \
quit ^- eof ^- eol ^- -post -inpck
nl(also-nl) โ disables (or enables)icrnl. In addition,-nlunsetsinlcrandigncr. ๐ฆekโ resetsERASEandKILLcharacters back to system defaults. ๐saneโ resets all modes to some reasonable, unspecified, values. ๐
๐ STDIN ๐
Although no input is read from standard input, standard input shall be used to get the current terminal I/O characteristics and to set new terminal I/O characteristics. Like, it's not reading your DMs, it's just peeking at the terminal settings. ๐ญ
๐ธ INPUT FILES ๐ธ
None. Literally nothing here. ๐
๐ฆ ENVIRONMENT VARIABLES ๐ฆ
The following environment variables shall affect the execution of stty:
LANGโ Provide 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 set to a non-empty string value, override the values of all the other internationalization variables.LC_CTYPEโ This variable 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โ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHโ Determine the location of message catalogs for the processing ofLC_MESSAGES.
โจ ASYNCHRONOUS EVENTS โจ
Default. No cap. ๐
๐ STDOUT ๐
If operands are specified, no output shall be produced. Like, silence. ๐คซ
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. It's giving save-state energy. ๐ฎ
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. So like, a vibe, but make it tokens. โจ
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.
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. It's not for your hot takes, only for errors. ๐
๐ OUTPUT FILES ๐
None. Zero. Nada. ๐
๐ EXTENDED DESCRIPTION ๐
None. โจ
๐ฅ EXIT STATUS ๐ฅ
The following exit values shall be returned:
0โ The terminal options were read or set successfully. ๐>0โ An error occurred. ๐ญ
๐ซถ CONSEQUENCES OF ERRORS ๐ซถ
Default.
The following sections are informative. (iykyk, bonus lore only.) ๐
๐ 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. So don't expect it to travel, bestie. ๐ญ
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 fr. โจ
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. It's giving main character energy for your terminal. ๐
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. So 'u' got left on read. ๐
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. So like, it's about the characters, not the keys. ๐ง
Since termios supports separate speeds for input and output, two new options were added to specify each distinctly. Slay for separate speeds. ๐
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. Security vibes, we love to see it. ๐
๐ 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 .
xoxo, IEEE/The Open Group, 2017, STTY(1POSIX) ๐โจ
๐ฆ where this page comes from
- debian bookworm: manpages-posix 2017a-2 ยท Other
- debian trixie: manpages-posix 2017a-2 ยท Other
- ubuntu jammy: manpages-posix 2017a-2 ยท Other
- ubuntu noble: manpages-posix 2017a-2 ยท Other
- ubuntu resolute: manpages-posix 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms