Auto-logout idle terminal sessions (TMOUT)
Have bash close your shell after a period of inactivity — ideal for shared or lab machines.
01Command
$ echo 'TMOUT=900; readonly TMOUT; export TMOUT' >> ~/.bashrc && source ~/.bashrc02What it does
Bash closes an interactive shell when no input arrives for TMOUT seconds, so an unlocked terminal can't stay open all lunch break. Putting it in ~/.bashrc applies it to your own sessions; setting it readonly plus export stops anyone from casually unsetting it. 900 seconds (15 minutes) is the usual compromise for shared admin boxes.
03Risk
04Undo
$ sed -i '/TMOUT=900/d; /readonly TMOUT/d; /export TMOUT/d' ~/.bashrc05Sources
- bash(1) — manual pageEvidence: In interactive shells, bash exits automatically after TMOUT seconds without input; making it readonly prevents users from unsetting it.
Last verified: 2026-09-18 · Category: Security & Privacy
06Related solutions
Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.
Add a UFW rule to permit inbound traffic on a TCP or UDP port, such as SSH on port 22.