Linux bash shell allows you to define the TMOUT environment variable. Set TMOUT to log users out after a period of inactivity automatically. The value is defined in seconds. For example,
export TMOUT=SECONDS export TMOUT=120
# set a 5 min timeout policy for bash shell TMOUT=300 readonly TMOUT export TMOUT
Save and close the file. The readonly command is used to make variables and functions readonly. In other words, your user cannot change the value of the variable called TMOUT. Consider this as a security feature.
How Do I Disable TMOUT?
To disable auto-logout, just set the TMOUT to zero or unset it as follows:
$ export TMOUT=0
$ unset TMOUT
Please note that readonly variable can only be disabled by root user in /etc/profile or ~/.bash_profile.
A Note About TCSH SHELL and OpenSSH Server/Client
SSH allows administrators to set an idle timeout interval in /etc/ssh/sshd_config file. TCSH user should use autologout variable. Please see our previous FAQ “Linux / UNIX Automatically Log BASH / TCSH / SSH Users Out After a Period of Inactivity” for more information.
TMOUT is a bash variable to auto-logout Linux users when there isn’t any activity. When we set TMOUT value greater than zero, TMOUT is treated as the default timeout for the read command. The select command terminates if the input does not arrive after TMOUT seconds when information is coming from a terminal. In an interactive shell, the value is interpreted as the number of seconds to wait for a line of input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if a complete line of information does not arrive. Read bash man page for more information by typing the following man command:
$ man bash
🐧 7 comments so far... add one ↓
|Category||List of Unix and Linux commands|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|