Linux:How To Configure User logged Out Automatically

For a new linux admin,if you can set an automatic logout after a certain idle-time is a good way for system security to prevent  unauthorized access. this post will guide you how to configure logged out automatically for inactive user.

This can be done by modifying  “TMOUT” variable in the bash start-up scrpt. and you can edit one of the below two configuration files to accomplish automatically logout for inactive user.

  • /etc/profile
  • ~/.bashrc 

If you append the “TMOUT” variable into /etc/profile file , then User logged  out will affect all users on the system, As the /etc/profile contains global variables for all users.

Edit  /etc/profile file via vi command:

#vi /etc/profile

Set TMOUT value to 100s, then adding the following lines to it:

export TMOUT=100

If you just want to set logged out automatically for a specific user , then you can edit individual user’s bashrc file and adding following  “TMOUT”  line into it.

export TMOUT=100

Last,   if you want the above change to take effect  immediately, you should re-login the bash or run the following command:

source /etc/profile

or

source ~/.bashrc

done..

You might also like:

Sidebar



back to top