How To set Auto Logout for Linux users

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 its 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/ 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/

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.

Show your love by sharing this..!
Share on VKShare on StumbleUponShare on YummlyPrint this pageFlattr the authorShare on TumblrEmail this to someoneBuffer this pageShare on Google+Share on LinkedInShare on FacebookTweet about this on TwitterPin on PinterestShare on RedditDigg this
The following two tabs change content below.
My name is Surendra Kumar Anne. I hail from Vijayawada which is capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. I work with ICE systems, Sydney as Sr. Consultant. You can contact me at surendra (@) linuxnix dot com.
  • Arun

    this set up is for all the users, how to do it for a single user

    • Surendra Anne

      Hi Arun,

      You can keep below lines in your ~/.bashrc file(For every user, they have their own .bashrc files).

      export TMOUT

      Save the file and source it.

      source ~/.bashrc

      Hope this helps and I updated the post to include this as well.


  • Albin

    How to record  in /var/log/message if user session expires due to time out.