What is this auto logout?
Ans : Auto logout is a concept to force user to logout from the remote server. If the open session to remote server is idle for a given time. This is a security measure Linux administrators follow for terminating idel sessions to remote servers.
Why actually we require auto logout?
Ans : As a security measure, This is a good practice to set this, because it’s not a good idea/practice to keep open terminal idle for longer duriations.
How to accomplish this for a system wide setting?
Ans : This can be achieved by two ways.

1. Open /etc/profile and append TMOUT variable. See my below example

Export TMOUT=600 # 10 minutes in seconds
typeset -r TMOUT
This will set time-out to 600 sec(ie 10mins) and I have given typeset -r which read-only and will not allow users to change this. Save the file and exit.


2. By creating /etc/profile.d/sessiontimout.sh file then keeping above mention entries in it.
Export TMOUT=600 # 10 minutes in seconds
typeset -r TMOUT
Now save and exit the file

As this is a script we have to change the permissions too.
#chmod +x /etc/profile.d/sessiontimout.sh

How to accomplish this for individual users?

Ans : We can edit ~/.bashrc file as given below.

Open ~/.bashrc file for a given user and write below two line in to it.


export TMOUT

Save the file and source it as given below.

source ~/.bashrc

This change can be seen only for that user. Please share your thoughts on this, if you know better option to do it.

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.