How to auto logout(timeout) a regular user and root user in Linux?



I want to set shell auto logout for multiple users with multiple timeout in linux

Steps:

# touch /etc/profile.d/log-out.sh

# cd /etc/profile.d

Modify your log-out.sh script as below

#!/bin/bash
# Log out in 2 minutes if the session is idle
if [ `id -nu` == "root" ];then
   export TMOUT=120
   readonly TMOUT
elif [ `id -nu` == "himanshu" ];then
   export TMOUT=60
   readonly TMOUT
fi

Log out and re-login to validate your new changes








If you like please follow and comment