10

I know I've tracked this down before but can't find the answer.

When I start a bash shell on CentOS 7 (from X Windows GNOME or KDE), the variable TMOUT is set which causes the shell to timeout after the specified period of inactivity.

The variable is readonly so I can't unset it or change it!

unset TMOUT
# prints bash: unset: TMOUT: cannot unset: readonly variable
export TMOUT=99999
# prints bash: TMOUT: readonly variable

Normally /etc/bashrc sets these kinds of things. I've tried to find where it is set using:

grep TMOUT $HOME/.??* /etc/* 2> /dev/null
# not found

So I don't think the TMOUT is actually being set in /etc/bashrc or if it is not being set in the way I was looking for it.

Other questions have been asked but they are not the same or not helpful.

Sdgh17
  • 109
  • 3
PatS
  • 552
  • 2
  • 5
  • 17

1 Answers1

7

To disable the time out I changed the file /etc/profile.d/local.sh. I commented out lines that were setting the timeout variable and making it readonly.

vi /etc/profile.d/local.sh
#export TMOUT=43200
#readonly TMOUT

An alternative would be to set TMOUT=0 which means to disable the timeout. Man page for bash TMOUT is http://man7.org/linux/man-pages/man1/bash.1.html.

The most important change is to comment out the line that made the variable "readonly". If the variable could be changed, then I could have modified it in my own login settings (e.g., $HOME/.bashrc, or .bash_profile).

PatS
  • 552
  • 2
  • 5
  • 17
  • 2
    Typically, for compliance reasons, the config should remain set. That said, Is there a way to effectively override this config value which makes the environment variable read only, temporarily? The idea here being that at the discretion of a systems administrator, the value could be unset for a particular session, but still enabled by default for all others. – Chris Jan 24 '19 at 17:02
  • 1
    @ChrisSmith, From my experimentation, once the variable is set to readonly, it can not be changed. What could be done is to have something that uses ```whoami``` or ```id -u``` to get a users name or UID and have the script skip the setting for a specific user. – PatS Jan 25 '19 at 01:43