Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set Bash’s TMOUT variable to a positive number of seconds to make an interactive Bash shell exit when no complete line is entered after its primary prompt. For example, TMOUT=900 sets a 15-minute prompt timeout. This applies to the Bash shell, not automatically to every Linux shell, running command, SSH connection, or terminal session.

What TMOUT does—and what it does not

In an interactive Bash shell, TMOUT is the number of seconds Bash waits for input after displaying the primary prompt. If the user does not enter a complete line before the interval expires, Bash exits. See the GNU Bash manual’s interactive shell behavior.

This timeout is about an idle prompt: it does not mean Bash will terminate a command that is already running after the same interval. It is also not a universal Linux setting. Other shells may behave differently, and TMOUT alone does not set an SSH transport timeout or guarantee logout from a terminal multiplexer or graphical session.

Set TMOUT for one user’s Bash login shells

For a per-user setting, add an assignment to the login startup file used by that user’s interactive Bash shell. For example, to use 900 seconds:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
TMOUT=900

The value is in seconds, so 900 seconds is 15 minutes. Choose an interval that fits local policy and users’ workflows; there is no universally correct timeout.

For an interactive login shell, Bash reads /etc/profile, then the first readable file it finds from this list: ~/.bash_profile, ~/.bash_login, and ~/.profile. Add the assignment to the applicable file, rather than assuming every distribution or shell invocation reads the same file. The Bash startup files documentation describes this login-shell sequence.

  1. Identify the shell and startup mode. Confirm the user is running Bash and that the shell in question is an interactive login shell.
  2. Edit the applicable profile. Put TMOUT=900 in the first readable user login profile Bash uses, or use another startup mechanism appropriate to the site’s setup.
  3. Start a matching shell or load the setting. The value takes effect in a shell where it has been set; opening a new matching login shell is the straightforward way to apply the profile change.

Account for non-login shells and system-wide policy

Non-login interactive Bash shells can follow a different startup path, so a value placed only in a login profile may not cover every shell a user opens. For a system-wide policy, first determine which shell users run and which startup files the target system actually uses. The Bash manual establishes the login-shell order above; it is not a universal distribution-specific recipe for enforcing a policy across all shells.

Administrators sometimes mark TMOUT readonly to discourage changes in a shell. That measure should not be treated as a complete security boundary: this setting alone does not guarantee coverage of other shells or all session types. Verify the startup configuration and test the intended behavior on the systems where the policy will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the effects on read and select

A positive TMOUT also has effects beyond waiting at the prompt. Bash uses it as the default timeout for the read builtin, and select ends if terminal input does not arrive within that interval. Broadly applying a short value can therefore affect scripts, menus, or other interactive workflows. The Bash variables documentation covers these uses.

If you manage SSH inactivity separately, configure and assess the appropriate SSH or server-side session policy as well. Those mechanisms are distinct from Bash’s prompt timeout.

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.