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.

  • 1
    Look at in /etc/profile or /etc/profile.d/. Commented Oct 27, 2017 at 17:11
  • @lpor Sicer, Thanks. It was in /etc/profile.d/local.sh. I would mark this comment as the answer if I could!
    – PatS
    Commented Oct 27, 2017 at 19:49
  • In my case, it was /etc/environment. Commented Mar 2, 2023 at 10:40
  • @MateenUlhaq, what Unix distribution & version set TMOUT in /etc/environment?
    – PatS
    Commented Mar 3, 2023 at 14:44

1 Answer 1


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).

  • 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
    Commented Jan 24, 2019 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
    Commented Jan 25, 2019 at 1:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .