May 16, 2010

Auto Logout In Linux

Almost everyone are forgetful and used to leave the Linux/Unix login session open without logging out. So, how to make sure all the Linux systems will automatically logout users after idle for certain minutes?

In fact, the simplest way is to configure the TMOUT shell variable!
i.e
export TMOUT=60

This export command will immediately get the Linux OS to automatically logout a user after his/her login session being idle for 60 seconds or 1 minute! 

Note: The TMOUT environment variable is applied to a command line console login session only. For X-window or GUI log in, we can easily turn on any pretty auto-lock screen-saver, that works very much like those in Windows.

In order the apply TMOUT to all Linux login accounts, put that export command to the login scripts or login profile (.bash_profile or .profile) in respective user home directory. But, the easiest way is to write the export command in the system profile instead of respective user’s profile! That’s to say, we can append the export TMOUT=60 command to /etc/profile (i.e. the system profile)!

To disable the Linux auto-logout user feature, just set the TMOUT to zero,
i.e.
export TMOUT=0

No comments:

Post a Comment