Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The number of allocated ptys (/proc/sys/kernel/pty/nr) on my linux server is constantly growing, and exceeds the number of active logins, terminals and screen sessions by orders of magnitude. Only a system restart resets seems to reset it.

How can I find out which process is eating up the pty's?

I tried the suggestion in answer 1, but

# lsof -n | grep pts | wc -l
# cat /proc/sys/kernel/pty/nr 

# uname -a
Linux spitzer 2.6.32-34-server #77-Ubuntu SMP Tue Sep 13 20:54:38 UTC 2011 x86_64 GNU/Linux
share|improve this question
up vote 4 down vote accepted

According to grawity's answer on superuser, what you are seeing is due to a bug in linux. /proc/sys/kernel/pty/nr is not decremented when a pty is no longer used. That is why lsof is showing a lower number. This was noticed in November 2009 but not fixed until August 2011.

share|improve this answer

Ptys are file handles. You can use lsof to find out which process is keeping which files open.

# lsof -n | grep pts
share|improve this answer
Doesn't quite work though (main question edited). – Nikratio Oct 24 '11 at 21:38
Which kernel/distribution are you running? – Kvisle Oct 24 '11 at 21:44
Try lsof -n | grep 136, – David Schwartz Oct 25 '11 at 1:53
@DavidSchwartz That includes process ids and memory segments that would happen to match as well. – Kvisle Oct 25 '11 at 7:27

A pty can have more than one 'file' associated with it. If you take that into account, the number will match the lsof number.

cat /proc/sys/kernel/pty/nr


lsof -n | fgrep pts | wc -l


lsof -n | fgrep pts | sed 's/  */ /g' | cut -f9 -d' ' | sort | uniq | wc -l

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.