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.

Rick Donato

Want to become a Linux expert?

Here is our hand-picked selection of the best courses you can find online:
Linux Mastery course
Linux Administration Bootcamp
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial