Bash Configure Automatic Logout [ Linux / Unix / Apple OS X ]

How can I configure automatic logout for my bash shell under Unix / Apple OS X / Linux operating systems?\

You can configure any modern shell including bash to auto logout. Please note that autologout will only work for the foreground process. For example, if you left your session idle the automatic shell logout will occur. But, if an interactive process such as top command or a vi text editor session is left idle, then automatic logout would not occur.


Add the following lines to your bash startup file such as $HOME/.bash_profile or create a new bash shell script called in the /etc/profile.d directory:

## append in $HOME/.bash_profile
## 300 seconds == 5 minutes ##
readonly TMOUT
export TMOUT

OR /etc/profile.d/

## 300 seconds == 5 minutes ##
readonly TMOUT
export TMOUT

Save and close the file.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Thangamariappan May 22, 2014 @ 16:09


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum