How to setup auto logout time in a CLI

We can set up automatic logout for root session so that session gets logged off, if it is idle for a while. It is important to know this as any sneaker can misuse the situation, when a root user leaves the session idle. The method is very simple and as follows:

01. Locate the system file
#nano .bashrc

02. Go to under the “#user specific aliases and functions” line and then type

03. Save this file
Ctrl + O

04. Exit the file
Ctrl + X

Here TMOUT is an environment variable which instructs the bash shell to exit if the session is idle. Here timeout is set as 300 seconds (5 minutes).