Skip to content

xterm - X Window System Terminal Emulator

xterm is the standard terminal emulator for the X Window System, serving as the foundation for many modern terminal applications. Originally developed in 1984, xterm remains one of the most widely used and feature-rich terminal emulators in Unix-like systems. It provides extensive customization options, Unicode support, and serves as the reference implementation for terminal emulation standards.

Installation

Linux (Debian/Ubuntu)

bash
sudo apt update
sudo apt install xterm

Linux (Red Hat/CentOS/Fedora)

bash
sudo dnf install xterm
# or on older systems:
sudo yum install xterm

Linux (Arch)

bash
sudo pacman -S xterm

macOS (with X11)

bash
# Install XQuartz first, then:
brew install xterm

FreeBSD

bash
pkg install xterm

Basic Usage

Starting xterm

bash
# Basic xterm window
xterm

# Start with specific title
xterm -title "My Terminal"

# Start with specific geometry
xterm -geometry 80x24+100+100

# Start with specific font
xterm -fn "fixed"

# Start in fullscreen
xterm -fullscreen

Command Line Options

bash
# Display options
xterm -display :0.0
xterm -geometry 132x43
xterm -iconic
xterm -maximized

# Font options
xterm -fn "9x15"
xterm -fa "Monospace:size=12"
xterm -fs 14

# Color options
xterm -fg white -bg black
xterm -rv  # Reverse video
xterm -cm  # Color mode

# Scrolling options
xterm -sb  # Enable scrollbar
xterm -sl 1000  # Set scrollback lines
xterm -si  # Scroll on input
xterm -sk  # Scroll on key press

# Logging options
xterm -l  # Enable logging
xterm -lf logfile.txt  # Log to specific file

Keyboard Shortcuts

Text Selection and Clipboard

bash
# Text selection
Left Click + Drag          # Select text
Double Click               # Select word
Triple Click               # Select line
Shift + Left Click         # Extend selection

# Clipboard operations
Ctrl + Shift + C           # Copy (modern xterm)
Ctrl + Shift + V           # Paste (modern xterm)
Middle Click               # Paste selection (traditional)
Shift + Insert             # Paste clipboard

# Traditional X11 clipboard
Select text                # Automatically copies to primary selection
Middle Click               # Paste primary selection

Window and Font Control

bash
# Font size control
Ctrl + Right Click         # Font menu
Ctrl + Plus                # Increase font size
Ctrl + Minus               # Decrease font size
Ctrl + 0                   # Reset font size

# Window operations
Alt + F4                   # Close window
Alt + F10                  # Maximize window
Alt + F9                   # Minimize window
Alt + F5                   # Restore window

Scrolling

bash
# Scrollback navigation
Shift + Page Up            # Scroll up one page
Shift + Page Down          # Scroll down one page
Shift + Home               # Scroll to top
Shift + End                # Scroll to bottom
Shift + Up Arrow           # Scroll up one line
Shift + Down Arrow         # Scroll down one line

Terminal Control

bash
# Terminal reset and clear
Ctrl + L                   # Clear screen
reset                      # Reset terminal state
clear                      # Clear screen content

# Process control
Ctrl + C                   # Interrupt (SIGINT)
Ctrl + Z                   # Suspend (SIGTSTP)
Ctrl + D                   # EOF/Exit
Ctrl + \                   # Quit (SIGQUIT)

Mouse Operations

Context Menus

bash
# Main menu (Ctrl + Left Click)
- New Window
- Print Window
- Redraw Window
- Send Signal
- Quit

# VT Options menu (Ctrl + Middle Click)
- Enable/Disable Scrollbar
- Enable/Disable Jump Scroll
- Enable/Disable Reverse Video
- Enable/Disable Auto Wraparound
- Enable/Disable Reverse Wraparound
- Enable/Disable Auto Linefeed
- Enable/Disable Application Cursor Keys
- Enable/Disable Application Keypad
- Scroll to Bottom on Output
- Scroll to Bottom on Key
- Allow 80/132 Column Switching
- Keep Selection
- Select to Clipboard

# VT Fonts menu (Ctrl + Right Click)
- Default Font
- Tiny Font
- Small Font
- Medium Font
- Large Font
- Huge Font
- Escape Sequence Font
- Selection Font

Selection Modes

bash
# Selection types
Single Click               # Position cursor
Double Click               # Select word
Triple Click               # Select line
Quadruple Click            # Select all

# Extended selection
Shift + Click              # Extend selection
Ctrl + Click               # Rectangular selection
Alt + Click                # Line selection mode

Configuration

Command Line Configuration

bash
# Resource file options
xterm -xrm "XTerm*background: black"
xterm -xrm "XTerm*foreground: white"
xterm -xrm "XTerm*font: 9x15"
xterm -xrm "XTerm*scrollBar: true"

# Multiple resources
xterm -xrm "XTerm*background: black" \
      -xrm "XTerm*foreground: green" \
      -xrm "XTerm*font: fixed"

X Resources Configuration (~/.Xresources)

bash
! Basic appearance
XTerm*background: black
XTerm*foreground: white
XTerm*cursorColor: yellow
XTerm*pointerColor: red
XTerm*borderColor: blue

! Font configuration
XTerm*font: -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1
XTerm*boldFont: -misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
XTerm*faceName: Liberation Mono:size=12:antialias=false
XTerm*faceSize: 12

! Scrolling
XTerm*scrollBar: true
XTerm*scrollbar.width: 8
XTerm*rightScrollBar: true
XTerm*saveLines: 10000
XTerm*scrollTtyOutput: false
XTerm*scrollKey: true

! Bell configuration
XTerm*visualBell: true
XTerm*bellIsUrgent: true

! Selection and clipboard
XTerm*highlightSelection: true
XTerm*trimSelection: true
XTerm*cutNewline: false
XTerm*cutToBeginningOfLine: false
XTerm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48

! Terminal behavior
XTerm*loginShell: true
XTerm*jumpScroll: true
XTerm*multiScroll: true
XTerm*toolBar: false
XTerm*titeInhibit: false

! Color scheme (Solarized Dark example)
XTerm*color0: #073642
XTerm*color1: #dc322f
XTerm*color2: #859900
XTerm*color3: #b58900
XTerm*color4: #268bd2
XTerm*color5: #d33682
XTerm*color6: #2aa198
XTerm*color7: #eee8d5
XTerm*color8: #002b36
XTerm*color9: #cb4b16
XTerm*color10: #586e75
XTerm*color11: #657b83
XTerm*color12: #839496
XTerm*color13: #6c71c4
XTerm*color14: #93a1a1
XTerm*color15: #fdf6e3

Apply X Resources

bash
# Load resources
xrdb -merge ~/.Xresources

# Load and replace all resources
xrdb -load ~/.Xresources

# View current resources
xrdb -query

# Remove all resources
xrdb -remove

Advanced Features

Unicode and Internationalization

bash
# UTF-8 support
xterm -u8

# Locale-specific startup
LC_ALL=en_US.UTF-8 xterm

# Font configuration for Unicode
XTerm*utf8: 1
XTerm*locale: true
XTerm*utf8Title: true
XTerm*fontMenu*fontdefault*Label: Default
XTerm*faceName: DejaVu Sans Mono:size=11
XTerm*faceNameDoublesize: WenQuanYi Zen Hei Mono:size=11

Terminal Emulation Modes

bash
# VT100 mode
xterm -tn vt100

# VT220 mode  
xterm -tn vt220

# Linux console mode
xterm -tn linux

# Set terminal type
export TERM=xterm-256color

Logging and Session Recording

bash
# Enable logging
xterm -l -lf ~/xterm.log

# Logging with timestamp
xterm -l -lf ~/xterm-$(date +%Y%m%d-%H%M%S).log

# Session recording with script
script -f ~/session.log
# Then start xterm within the script session

Security Features

bash
# Disable dangerous features
XTerm*allowSendEvents: false
XTerm*allowWindowOps: false
XTerm*allowTitleOps: false
XTerm*allowFontOps: false

# Secure keyboard input
XTerm*secureKeyboard: true

# Disable menu access
XTerm*omitTranslation: popup-menu

Customization Examples

Color Schemes

bash
# Solarized Light
XTerm*background: #fdf6e3
XTerm*foreground: #657b83
XTerm*fadeColor: #fdf6e3
XTerm*cursorColor: #586e75
XTerm*pointerColorBackground: #93a1a1
XTerm*pointerColorForeground: #586e75

# Monokai
XTerm*background: #272822
XTerm*foreground: #f8f8f2
XTerm*cursorColor: #f8f8f0
XTerm*color0: #272822
XTerm*color1: #f92672
XTerm*color2: #a6e22e
XTerm*color3: #f4bf75
XTerm*color4: #66d9ef
XTerm*color5: #ae81ff
XTerm*color6: #a1efe4
XTerm*color7: #f8f8f2

# Gruvbox Dark
XTerm*background: #282828
XTerm*foreground: #ebdbb2
XTerm*color0: #282828
XTerm*color1: #cc241d
XTerm*color2: #98971a
XTerm*color3: #d79921
XTerm*color4: #458588
XTerm*color5: #b16286
XTerm*color6: #689d6a
XTerm*color7: #a89984

Font Configurations

bash
# Bitmap fonts
XTerm*font: -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
XTerm*boldFont: -misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1

# TrueType fonts
XTerm*faceName: Inconsolata:size=12
XTerm*faceSize: 12
XTerm*renderFont: true

# Multiple font sizes
XTerm*faceSize1: 8
XTerm*faceSize2: 10
XTerm*faceSize3: 12
XTerm*faceSize4: 14
XTerm*faceSize5: 16
XTerm*faceSize6: 18

Window Manager Integration

bash
# Window class and name
XTerm*iconName: Terminal
XTerm*title: xterm
XTerm*geometry: 80x24+0+0

# Window manager hints
XTerm*allowWindowOps: true
XTerm*disallowedWindowOps: 1,2,3,4,5,6,7,8,9,11,13,18,19

# Session management
XTerm*sessionMgt: true

Troubleshooting

Common Issues

bash
# Font problems
xlsfonts | grep fixed          # List available fonts
xterm -fn fixed                # Use basic fixed font
fc-list : family | grep Mono   # List monospace fonts

# Color issues
echo $TERM                     # Check terminal type
tput colors                    # Check color support
xterm -tn xterm-256color       # Force 256 color mode

# Clipboard problems
xclip -version                 # Check if xclip is installed
xsel --version                 # Check if xsel is installed
echo $DISPLAY                  # Verify X11 display

# Locale issues
locale                         # Check current locale
xterm -u8                      # Enable UTF-8 mode
export LANG=en_US.UTF-8        # Set UTF-8 locale

Performance Optimization

bash
# Disable unnecessary features
XTerm*jumpScroll: true
XTerm*multiScroll: true
XTerm*fastScroll: true

# Reduce resource usage
XTerm*saveLines: 1000          # Limit scrollback
XTerm*visualBell: false        # Disable visual bell
XTerm*toolBar: false           # Disable toolbar

# Font rendering optimization
XTerm*renderFont: true
XTerm*antialias: true
XTerm*faceSize: 11

Debugging

bash
# Debug mode
xterm -debug 1

# Verbose output
xterm -verbose

# Check resources
xrdb -query | grep -i xterm

# Test configuration
xterm -xrm "XTerm*background: red" -geometry 40x10

Integration with Other Tools

Terminal Multiplexers

bash
# With tmux
xterm -e tmux

# With screen
xterm -e screen

# With specific session
xterm -e "tmux attach-session -t main"

Shell Integration

bash
# Specific shell
xterm -e bash
xterm -e zsh
xterm -e fish

# Login shell
xterm -ls

# Execute command and exit
xterm -e "ls -la; read"

Window Manager Scripts

bash
#!/bin/bash
# Launch multiple xterm windows
xterm -geometry 80x24+0+0 -title "Main" &
xterm -geometry 80x24+400+0 -title "Logs" -e "tail -f /var/log/syslog" &
xterm -geometry 80x24+0+300 -title "Monitor" -e "htop" &

Best Practices

Configuration Management

bash
# Use version control for configs
cd ~
git init
git add .Xresources
git commit -m "Initial xterm configuration"

# Backup configurations
cp ~/.Xresources ~/.Xresources.backup

Security Considerations

bash
# Disable dangerous operations
XTerm*allowSendEvents: false
XTerm*allowWindowOps: false
XTerm*allowTitleOps: false

# Use secure keyboard mode
XTerm*secureKeyboard: true

# Limit font operations
XTerm*allowFontOps: false

Performance Tips

bash
# Optimize for speed
XTerm*jumpScroll: true
XTerm*multiScroll: true
XTerm*fastScroll: true

# Limit resource usage
XTerm*saveLines: 2000
XTerm*buffered: true

xterm remains the gold standard for terminal emulation in Unix-like systems, offering unparalleled customization and compatibility. Its extensive feature set and configuration options make it suitable for everything from basic command-line work to complex development environments. Understanding xterm's capabilities and configuration options is essential for any serious Unix/Linux user.