• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL : How to adjust the telnet timeout (and how to disable it)

by admin

The problem

1. How to modify the telnet timeout period?
2. Telnet connection is disconnected after some idle time. How to disable the timeout in telnet?

The Solution

Using the tcp_keepalive_time parameter

To modify the telnet timeout you need to change the value of the parameter tcp_keepalive_time. Below is the details of the parameter from the man page of tcp.

# man tcp
       tcp_keepalive_time (integer; default: 7200; since Linux 2.2)
              The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes.  Keep-alives  are  sent  only  when  the
              SO_KEEPALIVE socket option is enabled.  The default value is 7200 seconds (2 hours).  An idle connection is terminated after approximately an
              additional 11 minutes (9 probes an interval of 75 seconds apart) when keep-alive is enabled.

1. To view the current value of the tcp_keepalive_time parameter, use the below command.

# sysctl -a | grep tcp_keepalive_time
net.ipv4.tcp_keepalive_time = 7200

2. To set a new value of the tcp_keepalive_time parameter, use the below command.

# echo 3600 > /proc/sys/net/ipv4/tcp_keepalive_time

3. To keep the change permanent add a line to /etc/sysctl.conf similar to the following.

# vi /etc/sysctl.conf
net.ipv4.tcp_keepalive_time = 3600

4. Now run the command below for the changes to be effective in the current session as well.

# sysctl -p
net.ipv4.tcp_keepalive_time = 3600

Using the TMOUT environment variable

You can also adjust timeout by using ‘TMOUT=’ environment variable. If you don’t want to use auto logging out, please put the below in ~/.bashrc file of the respective user.

# export TMOUT=0

Filed Under: Linux

Some more articles you might also be interested in …

  1. How To Create Virtual Data Optimizer(VD0) in CentOS/RHEL 7 and 8
  2. How to view past performance with sar in Linux
  3. How to Setup SSH keys for “passwordless” ssh login in Linux
  4. CentOS / RHEL 6 : How to change SNMP log level
  5. CentOS / RHEL 7 : How to recover from deleted root entry in /etc/shadow and/or /etc/passwd files
  6. e2image Command Examples in Linux
  7. How to Compress and Extract Files and Directories in Linux Using gzip and bzip2
  8. flatpak Command Examples in Linux
  9. How to find and delete files older than some particular time period in Linux
  10. How to Check Btrfs FileSystem Usage and Perform Balancing

You May Also Like

Primary Sidebar

Recent Posts

  • dircolors: Output commands to set the LS_COLOR environment variable and style ls, dir, etc
  • dillo: A lightweight web browser intended for slow computers
  • dig: DNS lookup utility
  • diffstat: Create a histogram from the output of the diff command

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright