Bash / Korn - Change the default session timeout

This short guide will show you how to set the default session timeout. We will set the TMOUT variable, of which is supported by both shells, Bash and Korn.

To check your current timeout setting, enter the following,

[root@localhost ~]# env | grep TMOUT

To change this setting globally edit the /etc/bashrc. To change this setting per user edit ~/.bashrc.
Below are the required settings you will need to add/modify to your bashrc file.

echo "TMOUT=300 >> /etc/bashrc
echo "readonly TMOUT" >> /etc/bashrc
echo "export TMOUT" >> /etc/bashrc

This will set your timeout to 5 minutes and also prevent anyone from modifying these settings.