About Linux FAQ

Browse More FAQs:

Linux logged out a user automatically

Posted by Vivek Gite [Last updated: November 6, 2007]

Q. We have a few users who frequently forget to log out and I'd like to force them or automatically log out a user in case of inactivity detected. How do I force user to be logged out automatically?

A. BASH provides TMOUT variable. It is necessary for security reasons to have an inactive user logged out after a period of inactivity from Linux / UNIX ssh / telnet session. This can be accomplished by setting an environment variable TMOUT.

Automatically log out a user

Add the TMOUT variable to your /etc/bashrc file:
# vi /etc/bashrc
Set TMOUT to 300 seconds (5 minuets):
TMOUT=300
Save an close the file. Above config would automatically logout users after 300 seconds of inactivity. Please note that this hack only works with run level 2, 3 i.e. it will not work with GUI sessions.

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Other Helpful FAQs:

Discussion on This FAQ

  1. Anil Says:

    Hi

    Do i need to add this to every bashrc in user’s home dir to work ???

    Thanks
    Anil

  2. HarryWWC Says:

    Hullo Anil,
    if you read carefully, you are editting the “/etc/bashrc” - this is the *system* (global) BASH Resource Configuration file. Hence, editting this file will make it affect *all* (subsequent) logons.
    You could (in theory) in your own .bashrc modify the value to something else (e.g. to 600seconds = 10mins) if you wished.
    hth,
    .h

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.