Enabling automatic logoff

Enable automatic logoff to prevent an intruder from compromising the security of the system.

Another valid security concern results from users leaving their accounts unattended for a lengthy period of time. This situation allows an intruder to take control of the user's terminal, potentially compromising the security of the system.

To prevent this type of potential security hazard, you can enable automatic logoff on the system. To do this, set the TMOUT and TIMEOUT environment variables to the number of seconds of inactivity. After the inactive time is elapsed, you are logged off automatically, as in the following example:
TMOUT=600; TIMEOUT=600; export TMOUT TIMEOUT
In the above example, the number 600 is in seconds, which is equal to 10 minutes. This method works solely from the shell application. The variables can be protected from accidental overwriting by making them read only, as follows:
readonly TMOUT TIMEOUT
The TMOUT and TIMEOUT environment variables are set in the .profile files of users or in the /etc/security/.profile file. This allows the file to be added in the .profile file of a user when the user is created.