Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
$TERM is an environment variable that identifies the terminal type and capability description associated with the current session. Programs such as clear, tput, text editors, pagers, and curses-based interfaces use it to select a matching terminfo entry.
It is not the name of the Bash shell and does not necessarily identify the terminal emulator product. For example, xterm-256color is a terminal capability profile; it does not prove that the xterm application is running.
What does $TERM mean?
The relationship is:
$TERM value → terminfo entry → terminal capabilities
The terminfo database describes terminal behavior such as cursor movement, screen clearing, colors, highlighting, alternate-screen mode, and control sequences. A terminal-aware program reads TERM, finds the corresponding description, and uses the capabilities recorded there.
Bash normally inherits TERM from the process that starts it. Bash does not usually determine the value itself.
#1 Best Overall
Inspect the current value
printf 'TERM=%sn' "${TERM-<unset>}"
printf '%sn' "$TERM"
printenv TERM
The first command safely distinguishes an unset variable from an ordinary value. Typical values include:
| Value | Typical context | Important qualification |
|---|---|---|
xterm |
X-compatible terminal behavior | Does not necessarily mean the xterm application is running. |
xterm-256color |
Common modern terminal profile | The matching database entry must exist on the host. |
screen |
GNU Screen | Describes the multiplexer layer. |
screen-256color |
Screen with an extended color profile | Availability varies by system. |
tmux-256color |
tmux sessions | Requires a matching local terminfo entry. |
linux |
Linux virtual console | Describes the console terminal. |
vt100 |
Conservative historical profile | Offers a relatively limited capability set. |
dumb |
Minimal or non-interactive terminal | Scripts should avoid advanced visual control. |
Check the terminfo entry
Printing TERM only shows the identifier. It does not prove that the corresponding terminal description is installed.
infocmp "$TERM"
A successful command prints a formatted capability description. If it fails with an error such as unknown terminal type, the value may be misspelled, unsupported by the local database, or associated with a database that cannot be found.
To validate it in a script:
if [[ -n ${TERM-} ]] && infocmp "$TERM" >/dev/null 2>&1; then
printf 'Known terminal type: %sn' "$TERM"
else
printf 'No usable terminfo entry for: %sn' "${TERM-<unset>}" >&2
fi
How tput uses $TERM
tput queries the selected terminal description instead of assuming that every terminal understands the same control sequences. POSIX documents TERM as the variable used to determine terminal type for utilities such as tput.
tput colors
tput cols
tput lines
tput clear
tput colors reports the color capability recorded in the selected terminfo entry. It is not a complete measurement of the physical terminal’s capabilities. The dimension commands report the current terminal size when available, not merely a fixed identity encoded in TERM.
Curses applications use the same mechanism. When a terminal name is not supplied directly, the curses setup functions read TERM to choose the terminal description. See the setupterm and terminal-description documentation.
Using $TERM safely in Bash scripts
A script should account for missing variables, redirected output, and minimal terminals. This is a reasonable pattern for optional color:
Rank #2
if [[ -t 1 && -n ${TERM-} && $TERM != dumb ]] && command -v tput >/dev/null 2>&1; then
if green=$(tput setaf 2 2>/dev/null) && reset=$(tput sgr0 2>/dev/null); then
printf '%sSuccess%sn' "$green" "$reset"
else
printf 'Successn'
fi
else
printf 'Successn'
fi
[[ -t 1 ]] checks whether standard output is connected to a terminal. It does not prove that every capability is available, so it should be combined with checks appropriate to the feature being used. TERM=dumb is a useful conservative signal to avoid colors, cursor movement, and alternate-screen behavior.
For general-purpose scripts, prefer tput for terminal capabilities such as colors, bold text, cursor movement, clearing, reset, and alternate-screen mode. Hard-coded ANSI sequences can be acceptable in a tightly controlled output environment, but they are less portable.
Avoid treating a particular name as a complete feature test:
if [[ $TERM == xterm-256color ]]; then
# This alone does not prove every desired feature is available.
fi
Terminal type names describe a capability profile, not a security guarantee or a perfect inventory of modern features. Truecolor, mouse protocols, and emulator-specific behavior may involve additional conventions. COLORTERM, when present, is supplementary and does not replace TERM.
Recommended Free Tools
Unset, empty, invalid, and non-terminal values
These states are different:
if [[ -z ${TERM+x} ]]; then
echo 'TERM is unset'
elif [[ -z $TERM ]]; then
echo 'TERM is set but empty'
else
printf 'TERM is set to: %sn' "$TERM"
fi
TERM may be absent in cron jobs, CI runners, containers, system services, redirected commands, restricted environments, or SSH commands without a pseudo-terminal. A non-interactive script should normally fall back to plain output rather than inventing a terminal type.
Temporarily changing TERM
For one command only:
TERM=vt100 tput colors
For a child shell:
TERM=xterm-256color bash
For the current shell:
export TERM=xterm-256color
Changing the variable does not change the terminal emulator or add capabilities. It only changes the description applications use. An incompatible value can produce incorrect colors, broken screen formatting, or keyboard problems.
To restore an existing value safely:
old_term=${TERM-}
old_term_was_set=${TERM+x}
export TERM=vt100
# Run the test here.
if [[ -n $old_term_was_set ]]; then
export TERM=$old_term
else
unset TERM
fi
Should you set TERM permanently?
Usually, no. The terminal emulator, login process, SSH session, or multiplexer should provide the appropriate value. An unconditional line such as:
Rank #3
export TERM=xterm-256color
in .bashrc can fix one local session while breaking SSH connections, tmux, recovery shells, virtual consoles, or other environments.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →If a specialized environment genuinely requires an override, make it narrowly scoped and use a value known to match the actual terminal:
if [[ ${TERM-} == xterm ]]; then
export TERM=xterm-256color
fi
Even this should not be used merely to force color or silence an error.
SSH, tmux, and screen
SSH
For an interactive SSH session, the client normally sends a terminal-type request. The remote shell may receive a value such as xterm-256color, but the remote host also needs a matching terminfo entry.
ssh [email protected] 'printf "TERM=%sn" "${TERM-<unset>}"; infocmp "$TERM" >/dev/null && echo terminfo-ok'
If the remote host lacks the entry, use an accurate terminal type already installed there, install the relevant terminal database package, or copy and compile an entry into a user-local database. An advanced example is:
Free tools Windows power users keep installed
One-click scans. No signup required.
infocmp "$TERM" > /tmp/terminal.info
tic -x -o "$HOME/.terminfo" /tmp/terminal.info
The exact tic options and database layout vary between ncurses implementations, so this is not a universal first remedy.
tmux and GNU Screen
A multiplexer creates another terminal layer and may set TERM inside the session to screen, screen-256color, tmux, or tmux-256color. The inner value should describe the capabilities exposed by the multiplexer, not simply copy the outer emulator’s value.
printf '%sn' "$TERM"
tmux show-environment -g TERM 2>/dev/null
infocmp "$TERM"
Compare the value outside and inside the multiplexer, then verify that the inner value has a local database entry before changing configuration.
Understanding terminfo lookup
The terminal identifier and its database are separate:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
TERMnames the terminal type.terminfostores the capabilities associated with that name.TERMINFOandTERMINFO_DIRScan affect where ncurses searches for terminal descriptions.
printf 'TERM=%sn' "${TERM-<unset>}"
printf 'TERMINFO=%sn' "${TERMINFO-<unset>}"
printf 'TERMINFO_DIRS=%sn' "${TERMINFO_DIRS-<unset>}"
Depending on the ncurses build and operating system, terminal data may be stored in a directory tree, a hashed database, a user-local directory, or another configured location. The ncurses documentation describes the search behavior.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common errors and recovery
TERM environment variable not set
Check the environment:
printf 'TERM=%sn' "${TERM-<unset>}"
In a known interactive terminal, a temporary value such as export TERM=xterm may help, but only if that description matches the terminal. In scripts, handle the missing value and produce plain output instead.
unknown terminal type
Inspect the value and entry:
printf '%sn' "${TERM-<unset>}"
infocmp "$TERM"
Common causes include a misspelling, a missing remote or container package, an incomplete TERMINFO path, or a multiplexer value not installed on the host. Use an accurate installed profile, install the required database data, or add the entry to a user-local database.
Broken colors
Check both the selected profile and its database:
printf 'TERM=%sn' "$TERM"
tput colors
infocmp "$TERM" | head
Do not automatically replace the value with xterm-256color. First determine whether the terminal, multiplexer, remote host, and database all support the selected description.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsGarbled screen after an interrupted program
Try:
reset
or:
tput reset
If the terminal remains confused, close and reopen the session. Full-screen programs can leave terminal modes altered when they are interrupted.
Best Value
Is $TERM safe to trust?
Treat it as configuration data, not as proof of terminal identity or capability. A user, wrapper, SSH client, container, or other process can set it to an arbitrary string. Validate it through the terminal capability interface and handle missing entries gracefully. Shell expansions should be quoted:
infocmp "$TERM"
The key distinction is simple: TERM tells programs which description to use; it does not make that description true.
Frequently Asked Questions
Is $TERM a Bash special variable?
No. It is an ordinary exported environment variable that Bash generally inherits from its parent process and passes to child processes.
Why do different terminal applications often use xterm-256color?
The value is a compatibility and capability profile, not necessarily an application name. Different emulators can expose sufficiently similar behavior and use the same profile.
Does changing TERM enable 256 colors or truecolor?
No. It changes the description applications consult. It cannot add capabilities that the terminal, multiplexer, or remote path does not actually provide.
Why does clear fail when TERM is missing?
clear needs a terminal description to select the appropriate control sequence. Without a usable value and matching terminfo data, it may report an error or refuse to operate.
Does TERM contain the terminal window size?
No. Use tput cols and tput lines, or an application mechanism that responds to window-size changes.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

