On Unix-like operating systems, the xterm command is a terminal emulator for the X Window System.

Description

xterm is the standard terminal emulator of the X Window System, providing a command-line interface within a window. Several instances of xterm can run at the same time within the same display, each one providing input and output for a shell or another process.

  • Description
  • Syntax
  • Examples
  • Related commands
  • Linux commands help

Originally written in 1984 for the DEC VAXStation as a stand-alone program, xterm was quickly integrated into X, and today most X terminal emulators are variations of the original xterm code.

Syntax

xterm [-toolkitoption …] [-option …] [shell]

Options

If an option begins with a “+” instead of a “-”, the option is restored to its default value. The -version and -help options are interpreted even if xterm cannot open a display, and along with the -class option, are checked before all other options.

When xterm runs, it normally checks the SHELL environment variable for which shell to run. This shell can be changed, however, by providing a parameter to xterm, after all other options, which specifies the pathname of a shell to run. This pathname can be an absolute path or a relative path, and xterm will search the user’s PATH environment variable for the specified shell if it cannot find it. If no shell is specified, and the SHELL environment variable is undefined, xterm uses the Bourne Shell, /bin/sh.

General Options

Appearance And Behavior Options

The following command line arguments are provided for compatibility with older versions:

XtermLog.XXXXXX

Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX

xterm -e /bin/bash -l -c “my command here”

-S/dev/pts/123/45-S123/45-Sab34

The following standard X Toolkit command line arguments are commonly used with xterm:

Resources

The program understands all of the core X Toolkit resource names and classes. Application specific resources (e.g., “XTerm.NAME”) are as follows:

VT100 Widget Resources

The following resources are specified as part of the vt100 widget (class VT100). They are specified by patterns such as “XTerm.vt100.NAME”.

If your xterm is configured to support the “toolbar”, then those patterns need an extra level for the form-widget which holds the toolbar and vt100 widget. A wildcard between the top-level “XTerm” and the “vt100” widget makes the resource settings work for either, e.g., “XTerm*vt100.NAME”.

Tek4014 Widget Resources

The following resources are specified as part of the tek4014 widget (class Tek4014). These are specified by patterns such as “XTerm.tek4014.NAME”:

FontPath “/usr/lib/X11/fonts/misc/”

FontPath “/usr/lib/X11/fonts/misc/:unscaled”

#!/bin/shFONT=xfontsel -printtest -n “$FONT” && xfd -fn “$FONT”

fc-list :scalable=true:spacing=mono: family

*font: fixed

xterm.vt100.font

xterm.vt100.utf8Fonts.font

*localeFilter: xterm-filter -p

The resources that may be specified for the various menus are described in the documentation for the Athena SimpleMenu widget. The name and classes of the entries in each of the menus are listed below. Resources named “lineN” where N is a number are separators with class SmeLine.

The mainMenu has the following entries:

The vtMenu has the following entries:

The fontMenu has the following entries:

The tekMenu has the following entries:

Scrollbar Resources

The following resources are useful when specified for the Athena Scrollbar widget:

Pointer Usage

Once the VT102 window is created, xterm allows you to select text and copy it within the same or other windows.

Selection

The selection functions are invoked when the pointer buttons are used with no modifiers, and when they are used with the “shift” key. The assignment of the functions described below to keys and buttons may be changed through the resource database; see Actions, below.

Pointer button one (usually left) is used to save text into the cut buffer. Move the cursor to 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 is saved in the global cut buffer and made the PRIMARY selection when the button is released. Normally (but see the discussion of on2Clicks, etc):

  • Double-clicking selects by words.
  • Triple-clicking selects by lines.
  • Quadruple-clicking goes back to characters, etc.

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. Logical words and lines selected by double- or triple-clicking may wrap across more than one screen line if lines were wrapped by xterm itself rather than by the application running in the window. If the key/button bindings specify that an X selection is to be made, xterm will leave the selected text highlighted for as long as it is the selection owner.

Pointer button two (usually middle) “types” (pastes) the text from the PRIMARY selection, if any, otherwise from the cut buffer, inserting it as keyboard input.

Pointer button three (usually right) extends the current selection. Without loss of generality, you can swap “right” and “left” everywhere in the rest of this paragraph. If pressed while closer to the right edge of the selection than the left, it extends/contracts the right edge of the selection. If you contract the selection past the left edge of the selection, xterm assumes you really meant the left edge, restores the original selection, then extends/contracts the left edge of the selection. Extension starts in the selection unit mode that the last selection or extension was performed in; you can multiple-click to cycle through them.

By cutting and pasting pieces of text without trailing new lines, you can take text from several places in 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 cut buffers are globally shared among different applications, you may regard each as a “file” whose contents you know. The terminal emulator and other text programs should be treating it as if it were a text file, i.e., the text is delimited by new lines.

Scrolling

The scroll region displays the position and amount of text currently showing in the window (highlighted) relative to the amount of text actually saved. As more text is saved (up to the maximum), the size of the highlighted area decreases.

Clicking button one with the pointer in the scroll region moves the adjacent line to the top of the display window.

Clicking button three moves the top line of the display window down to the pointer position.

Clicking button two moves the display to a position in the saved text that corresponds to the pointer’s position in the scrollbar.

Tektronix Pointer

Unlike the VT102 window, the Tektronix window does not allow the copying of text. It does allow Tektronix GIN mode, and in this mode the cursor will change from an arrow to a cross. Pressing any key will send that key and the current coordinate of the cross cursor. Pressing button one, two, or three will return the letters “l”, “m”, and “r”, respectively. If the Shift key is pressed when a pointer button is pressed, the corresponding upper case letter is sent. To distinguish a pointer button from a key, the high bit of the character is set (but this is bit is normally stripped unless the terminal mode is RAW).

Select/Paste

X clients provide select and paste support by responding to requests conveyed by the server, as detailed in the following sections:

Primary Selection

When configured to use the primary selection, (the default) xterm can provide the selection data in ways which help to retain character encoding information as it is pasted.

A user “selects” text on xterm, which highlights the selected text. A subsequent “paste” to another client forwards a request to the client owning the selection. If xterm owns the primary selection, it makes the data available in the form of one or more “selection targets”. If it does not own the primary selection, e.g., if it has released it or another client has asserted ownership, it relies on cut-buffers to pass the data. But cut-buffers handle only ISO-8859-1 data (officially, some clients ignore the rules).

Clipboard

When configured to use the clipboard (see resource selectToClipboard), the problem with persistence of ownership is bypassed. Otherwise, there is no difference regarding the data which can be passed via selection.

Selection Targets

The different types of data that are passed depend on what the request from the receiving client. These are termed selection targets.

When asking for the selection data, xterm tries the following types in this order:

The middle two (TEXT and COMPOUND_TEXT) are added if xterm is configured with the i18nSelections resource set to “true”.

UTF8_STRING is preferred (therefore first in the list) since xterm stores text as Unicode data when running in wide-character mode, and no translation is needed. On the other hand, TEXT and COMPOUND_TEXT may require translation. If the translation is incomplete, they will insert X’s “defaultString” whose value cannot be set, and may be empty. xterm’s defaultString resource specifies the string to use for incomplete translations of the UTF8_STRING.

You can alter the types which xterm tries using the eightBitSelectTypes or utf8SelectTypes resources. For instance, you might have some specific locale setting which does not use UTF-8 encoding. The resource value is a comma-separated list of the selection targets, which consist of the names shown. You can use the special name I18N to denote the optional inclusion of TEXT and COMPOUND_TEXT. The names are matched ignoring case, and can be abbreviated. The default list can be expressed in several ways, for example:

UTF8_STRING,I18N,STRING utf8,i18n,string u,i,s

xterm has four menus, named mainMenu, vtMenu, fontMenu, and tekMenu. Each menu pops up under the correct combinations of key and button presses. Each menu is divided into sections, separated by a horizontal line. Some menu entries correspond to modes that can be altered. A check mark appears next to a mode that is currently active. Selecting one of these modes toggles its state. Other menu entries are commands; selecting one of these performs the indicated function.

All of the menu entries correspond to X actions. In the list below, the menu label is shown followed by the action’s name:

Main Options

The xterm mainMenu pops up when the “control” key and pointer button one are pressed in a window. This menu contains items that apply to both the VT102 and Tektronix windows. There are several sections:

Commands for managing X events:

Commands for capturing output:

Modes for setting keyboard style:

Commands for process signalling:

VT Options

The vtMenu sets various modes in the VT102 emulation, and is popped up when the CONTROL key and pointer button two are pressed in the VT102 window.

VT102/VT220 Modes:

VT102/VT220 Commands:

Commands for setting the current screen:

VT Fonts

The fontMenu pops up when the CONTROL key and pointer button three are pressed in a window. It sets the font used in the VT102 window, or modifies the way the font is specified or displayed. There are several sections.

The first section allows you to select the font from a set of alternatives:

The second section allows you to modify the way it is displayed:

The third section allows you to modify the way it is specified:

The fourth section allows you to enable or disable special operations which can be controlled by writing escape sequences to the terminal. These are disabled if the SendEvents feature is enabled:

uxterm -class XTerm

Security

X environments differ 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 is only using a host-based mechanism to control access to the server, then if you enable access for a host and other users are also permitted to run clients on that same host, it is possible that someone can run an application which uses the basic services of the X protocol to snoop on your activities, potentially capturing a transcript of everything you type at the keyboard.

Any process which has access to your X display can manipulate it in ways that you might not anticipate, even redirecting your keyboard to itself and sending events to your application’s windows. This is true even with the “magic cookie” authorization scheme. While the allowSendEvents provides some protection against rogue applications tampering with your programs, guarding against a snooper is harder.

The X input extension for instance allows an application to bypass all of the other (limited) authorization and security features, including the GrabKeyboard protocol.

The possibility of an application spying on your keystrokes is of particular concern when you want to type in a password or other sensitive data. The best solution to this problem is to use a better authorization mechanism than is provided by X.

Subject to all of these caveats, a simple mechanism exists for protecting keyboard input in xterm.

The xterm menu (see Menus above) contains a Secure Keyboard entry which, when enabled, attempts to ensure that all keyboard input is directed only to xterm (using the GrabKeyboard protocol request). When an application prompts you 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.

This ensures that you know which window is accepting your keystrokes.

It cannot ensure that there are no processes which have access to your X display that might be observing the keystrokes as well.

Only one X client at a time can grab the keyboard, so when you attempt to enable Secure Keyboard it may fail. In this case, the bell will sound. If the Secure Keyboard succeeds, the foreground and background colors will be exchanged (as if you selected the Reverse Video entry in the Modes menu); they will be exchanged again when you exit secure mode. If the colors do not switch, then you should be very suspicious that you are being spoofed. If the application you are running displays a prompt before asking for the password, it is safest to enter secure mode before the prompt gets displayed, and to make sure that the prompt gets displayed 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 appears next to the entry.

Secure Keyboard mode will be disabled automatically if your xterm window becomes iconified (or otherwise unmapped), or if you start up a reparenting window manager (that places a title bar or other decoration around the window) while in Secure Keyboard mode. This is a feature of the X protocol not easily overcome. When this happens, the foreground and background colors will be switched back and the bell will sound in warning.

Character Classes

Clicking the left pointer button twice in rapid succession (double-clicking) causes all characters of the same class (e.g., letters, white space, punctuation) to be selected as a “word”. Since different people have different preferences for what should be selected (for example, should file names be selected as a whole or only the separate subnames), the default mapping can be overridden through the use of the charClass (class CharClass) resource.

This resource is a series of comma-separated of range:value pairs. The range is either a single number or low-high in the range of 0 to 65535, corresponding to the code for the character or characters to be set. The value is arbitrary, although the default table uses the character number of the first character occurring in the set. When not in UTF-8 mode, only the first 256 bytes of this table will be used.

The default table starts as follows:

static int charClass[256] = { /* 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 / 48, 48, 48, 48, 48, 48, 48, 48, / 8 9 : ; < = > ? / 48, 48, 58, 59, 60, 61, 62, 63, / @ A B C 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 Q R S T U V W / 48, 48, 48, 48, 48, 48, 48, 48, / X Y Z [ \ ] ^ _ / 48, 48, 48, 91, 92, 93, 94, 48, / a b c d e f g */ 96, 48, 48, 48, 48, 48, 48, 48, /* h i j k l m n o */ 48, 48, 48, 48, 48, 48, 48, 48, /* p q r s t u v w */ 48, 48, 48, 48, 48, 48, 48, 48, /* x y z { | } ~ DEL */ 48, 48, 48, 123, 124, 125, 126, 1, /* x80 x81 x82 x83 IND NEL SSA ESA */ 1, 1, 1, 1, 1, 1, 1, 1, /* HTS HTJ VTS PLD PLU RI SS2 SS3 */ 1, 1, 1, 1, 1, 1, 1, 1, /* DCS PU1 PU2 STS CCH MW SPA EPA */ 1, 1, 1, 1, 1, 1, 1, 1, /* x98 x99 x9A CSI ST OSC PM APC */ 1, 1, 1, 1, 1, 1, 1, 1, /* - i c/ L ox Y- | So */ 160, 161, 162, 163, 164, 165, 166, 167, /* .. c0 ip << _ R0 - */ 168, 169, 170, 171, 172, 173, 174, 175, /* o +- 2 3 ' u q| . */ 176, 177, 178, 179, 180, 181, 182, 183, /* , 1 2 >> 1/4 1/2 3/4 ? */ 184, 185, 186, 187, 188, 189, 190, 191, /* A A’ A^ A~ A: Ao AE C, / 48, 48, 48, 48, 48, 48, 48, 48, / E E' E^ E: I I’ I^ I: / 48, 48, 48, 48, 48, 48, 48, 48, / D- N~ O O' O^ O~ O: X */ 48, 48, 48, 48, 48, 48, 48, 215, /* O/ U U’ U^ U: Y’ P B / 48, 48, 48, 48, 48, 48, 48, 48, / a a' a^ a~ a: ao ae c, */ 48, 48, 48, 48, 48, 48, 48, 48, /* e e’ e^ e: i i' i^ i: */ 48, 48, 48, 48, 48, 48, 48, 48, /* d n~ o o’ o^ o~ o: -: / 48, 48, 48, 48, 48, 48, 48, 247, / o/ u` u’ u^ u: y’ P y: */ 48, 48, 48, 48, 48, 48, 48, 48};

For example, the string “33:48,37:48,45-47:48,38:48” indicates that the exclamation mark, percent sign, dash, period, slash, and ampersand characters should be treated the same way as characters and numbers. This is useful for cutting and pasting electronic mailing addresses and file names.

Actions

It is possible to rebind keys (or sequences of keys) to arbitrary strings for input, by changing the translations resources for the vt100 or tek4014 widgets. Changing the translations resource for events other than key and button events is not expected, and will cause unpredictable behavior. The following actions are provided for use within the vt100 or tek4014 translations resources:

The Tektronix window also has the following action:

VT100translations: #override \n\ Meta /:dabbrev-expand()

^X Esc G <line+" “> <col+” “>

Esc ^P

Esc ^N

The default bindings in the VT102 window use the SELECT token, which is set by the selectToClipboard resource:

     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(SELECT, CUT_BUFFER0) \n\
    Shift <KeyPress> Insert:insert-selection(SELECT, CUT_BUFFER0) \n\
            Alt <Key>Return:fullscreen() \n\
   <KeyRelease> Scroll_Lock:scroll-lock() \n\

Shift~Ctrl KP_Add:larger-vt-font() \n
Shift Ctrl KP_Add:smaller-vt-font() \n
Shift KP_Subtract:smaller-vt-font() \n
~Meta :insert-seven-bit() \n
Meta :insert-eight-bit() \n
!Ctrl :popup-menu(mainMenu) \n
!Lock Ctrl :popup-menu(mainMenu) \n
!Lock Ctrl @Num_Lock :popup-menu(mainMenu) \n
! @Num_Lock Ctrl :popup-menu(mainMenu) \n
~Meta :select-start() \n
~Meta :select-extend() \n
!Ctrl :popup-menu(vtMenu) \n
!Lock Ctrl :popup-menu(vtMenu) \n
!Lock Ctrl @Num_Lock :popup-menu(vtMenu) \n
! @Num_Lock Ctrl :popup-menu(vtMenu) \n
~Ctrl ~Meta :ignore() \n
Meta :clear-saved-lines() \n
~Ctrl ~Meta :insert-selection(SELECT, CUT_BUFFER0) \n
!Ctrl :popup-menu(fontMenu) \n
!Lock Ctrl :popup-menu(fontMenu) \n
!Lock Ctrl @Num_Lock :popup-menu(fontMenu) \n
! @Num_Lock Ctrl :popup-menu(fontMenu) \n
~Ctrl ~Meta :start-extend() \n
~Meta :select-extend() \n
Ctrl :scroll-back(1,halfpage,m) \n
Lock Ctrl :scroll-back(1,halfpage,m) \n
Lock @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n
@Num_Lock Ctrl :scroll-back(1,halfpage,m) \n
:scroll-back(5,line,m) \n
Ctrl :scroll-forw(1,halfpage,m) \n
Lock Ctrl :scroll-forw(1,halfpage,m) \n
Lock @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n
@Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n
:scroll-forw(5,line,m) \n
:select-end(SELECT, CUT_BUFFER0) \n
:ignore()

The default bindings for the scrollbar widget are separate from the VT100 widget:

                 <Btn5Down>: StartScroll(Forward) \n\
                 <Btn1Down>: StartScroll(Forward) \n\
                 <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
                 <Btn3Down>: StartScroll(Backward) \n\
                 <Btn4Down>: StartScroll(Backward) \n\
               <Btn2Motion>: MoveThumb() NotifyThumb() \n\
                    <BtnUp>:    NotifyScroll(Proportional) EndScroll()

The default bindings in 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\

!Lock Ctrl @Num_Lock : popup-menu(mainMenu) \n
!Ctrl @Num_Lock : popup-menu(mainMenu) \n
!Ctrl : popup-menu(tekMenu) \n
!Lock Ctrl : popup-menu(tekMenu) \n
!Lock Ctrl @Num_Lock : popup-menu(tekMenu) \n
!Ctrl @Num_Lock : popup-menu(tekMenu) \n
Shift ~Meta: gin-press(L) \n
~Meta: gin-press(l) \n
Shift ~Meta: gin-press(M) \n
~Meta: gin-press(m) \n
Shift ~Meta: gin-press(R) \n
~Meta: gin-press(r)

Here is an example which uses shifted select/paste to copy to the clipboard, and unshifted select/paste for the primary selection. In each case, a (different) cut buffer is also a target or source of the select/paste operation. It is important to remember however, that cut buffers store data in ISO-8859-1 encoding, while selections can store data in a variety of formats and encodings. While xterm owns the selection, it highlights it. When it loses the selection, it removes the corresponding highlight. But you can still paste from the corresponding cut buffer.

        *VT100*translations:    #override \n\
        ~Shift~Ctrl<Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0) \n\
           Shift~Ctrl<Btn2Up>:  insert-selection(CLIPBOARD, CUT_BUFFER1) \n\
           ~Shift<BtnUp>:       select-end(PRIMARY, CUT_BUFFER0) \n\
           Shift<BtnUp>:        select-end(CLIPBOARD, CUT_BUFFER1)

Below is a sample of how the keymap() action is used to add special keys for 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)

Some people prefer using the left pointer button for dragging the scrollbar thumb. That can be setup by altering the translations resource, e.g.,

       *VT100.scrollbar.translations:#override \n\
            <Btn5Down>:StartScroll(Forward) \n\
            <Btn1Down>:StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
            <Btn4Down>:StartScroll(Backward) \n\
            <Btn1Motion>:MoveThumb() NotifyThumb() \n\
            <BtnUp>:  NotifyScroll(Proportional) EndScroll()

Control Sequences And Keyboard

The xterm Control Sequences document lists the control sequences which an application can send xterm to make it perform various operations. Most of these operations are standardized, from either the DEC or Tektronix terminals, or from more widely used standards such as ISO-6429.

Environment

xterm sets several environment variables:

Depending on your system configuration, xterm may also set the following:

Files

The actual pathnames given may differ on your system:

Error Messages

Most of the fatal error messages from xterm use the following format:

*customization: -color

xterm: Error XXX, errno YYY: ZZZ

The XXX codes (which are used by xterm as its exit-code) are listed below, with a brief explanation.

Examples

xterm

Launches xterm in a new window running the default terminal shell as set in the SHELL environment variable, or else /bin/sh (the Bourne Shell).

xterm csh

Launches xterm in a new window running the C Shell, csh.

xterm -e top

Launches xterm in a new window running the program top. When top is exited, the xterm window will also close.

X — Executable of the X Window System.