­
 

 

Quick Tip: Automatically Close Terminal After A Certain Time Of Inactivity

Append TMOUT=120 to the /etc/bash.bashrc file and export the variable. (replace 120 with any number of seconds ; we need root privileges in order to save changes in configuration files). Source the newly updated file, in order to load the changes:

$ sudo sh -c 'echo "export TMOUT=120" >> /etc/profile'
$ sudo source $HOME/.profile

This setting applies to all the users in the system, since it was written in the /etc/profile file. To set it only for your user, do:

$ echo "export TMOUT=120" >> $HOME/.profile
$ source /etc/profile

The ultimate geekery: Set the terminal to auto close after 120 seconds of idleness, only the if the user logged in is root:

$ sudo sh -c 'echo "[ $USER = root ] && export TMOUT=120" >> /etc/profile'
$ sudo source /etc/profile