How to set bash auto logout expiration in ubuntu 20.04 ?
I,m setting the variable TMOUT for root user to 2 hours on my server using following bash-command:
sudo export TMOUT=7200But it does not work at all, are there any other solutions to achieve this, other than putting that variable in my .profile ?
1 Answer
You could set a log out script in /etc/profile.d:
Create the file
/etc/profile.d/autologout.sh:sudo nano /etc/profile.d/autologout.shThe contents of
autologout.sh:#!/bin/sh # Sets auto log out for all users to 2 hours TMOUT=7200 readonly TMOUT export TMOUTSet permissions for the script:
sudo chmod 0755 /etc/profile.d/autologout.shReload the profile or log out and back in.
source /etc/profile.d/autologout.sh