This is a good case for the pam_env.so PAM module. Virtual console logins use the login program, so you can open /etc/pam.d/login and add a line such as the following:
session required pam_env.so readenv=1 envfile=/etc/vc-environment user_readenv=0 With the accompanying new file, /etc/vc-environment:
TMOUT=600 Two advantages to using PAM for this:
- It applies to any user who logs into the virtual console (although it does not stop them from changing
TMOUTlater). - The timeout can be applied to other specific services as well, such as
sudo.
Read here for details on this module.