1

Since pty is limited, I want to modify the content of /proc/sys/kernel/pty/max. The original value in max is 4096, and now I want to modify it to 10000.

[root@home pty]# pwd
/proc/sys/kernel/pty
[root@home pty]# ls -lh
total 0
-rw-r--r-- 1 root root 0 Aug 13 11:24 max
-r--r--r-- 1 root root 0 Aug 13 11:24 nr
vim max

I edit the max file directly, using root, but it fails. I use :w! in vim, but then I see the following picture:

then i edit max file directly using root, but failed

so I tried to chmod max first, but that also failed:

[root@home pty]# chmod 666 max 
chmod: changing permissions of `max': Operation not permitted
[root@home pty]# whoami 
root

so, how can I change the content of /proc/sys/kernel/pty/max?

Edit

@jon-lin:

it also failed using the sysctl command:

[root@home kernel]# sysctl -a | less | grep pty
kernel.pty.nr = 2
kernel.pty.max = 4096
[root@home kernel]# sysctl kernel.pty.max=10000
error: "Operation not permitted" setting key "kernel.pty.max"
[root@home kernel]# sysctl -p kernel.pty.max 10000
error: unable to open preload file "kernel.pty.max"
[root@home kernel]# sysctl -p kernel.pty.max = 10000
error: unable to open preload file "kernel.pty.max"

@AlanCurry:

It also failed using echo:

[root@home pty]# cat max
4096
[root@home pty]# echo 10000 > max
bash: echo: write error: Operation not permitted
[root@home pty]# echo 10000 >> max 
bash: echo: write error: Operation not permitted
[root@home pty]# cat max 
4096
quanta
  • 51,413
  • 19
  • 159
  • 217
giantforest
  • 239
  • 1
  • 4
  • 15
  • I think you mean `/proc/sys/kernel/pty/max` (you said `/proc/sys/kernel/pts/max` in title and body, I've fixed) – therefromhere Aug 13 '12 at 03:40
  • This should be migrated to [unix.SE](http://unix.stackexchange.com/). – bitmask Aug 13 '12 at 03:44
  • @therefromhere i am sure it's /proc/sys/kernel/pty/max, and there is no directory named /proc/sys/kernel/pts on my system. By the way, the system i use is CentOS 5.3, what about yours? –  Aug 13 '12 at 03:45
  • 1
    The not-really-files in `/proc` and `/sys` are a bit too fragile for a full-featured editor like vim to handle well. The recommended tools are `echo` and `cat`. However... you could just say `y` when vim asks if you're sure you want to write to it. – Alan Curry Aug 13 '12 at 03:53
  • @AlanCurry failed either using echo. replied above:) –  Aug 13 '12 at 04:04
  • @hugemeow exactly - I fixed your typo of pts :) – therefromhere Aug 13 '12 at 04:32

2 Answers2

4

If you want to change the number of max pseudo terminals you can have, don't edit the proc file. You should make the change to /etc/sysctl.conf and then re-run sysctl -p to change kernel parameters at runtime. Specifically change (or add) the line that has:

kernel.pty.max = <max>

Change <max> to the number you want.

Jon Lin
  • 1,353
  • 9
  • 21
  • also failed, i have replied in the post above :) –  Aug 13 '12 at 03:51
  • @hugemeow No, you edit the file `/etc/sysctl.conf`, and change the line `kernel.pty.max` to have the value that you want (which appears to be 10000), then save the file. Then run `sysctl -p` with no other arguments. If you use `-p`, it tells sysctl to load from a file, and if you give it anything it assumes it's a file. See the [sysctl man page](http://man.flashnux.com/en/centos/5/5.6/man8/sysctl.8.html) – Jon Lin Aug 13 '12 at 03:56
  • 1
    @hugemeow If you don't want to edit the file, then use the `-w` option: `sysctl -w kernel.pty.max=10000` – Jon Lin Aug 13 '12 at 03:58
  • it fails either:( [root@home kernel]# sysctl -w kernel.pty.max=10000 error: "Operation not permitted" setting key "kernel.pty.max" –  Aug 13 '12 at 04:00
  • @hugemeow Not sure what the problem is [because it works just fine for me](http://i.stack.imgur.com/gSkib.png), try editing the conf file and running `sysctl -p` – Jon Lin Aug 13 '12 at 04:07
  • That's strange. All three methods (`sysctl -w`, `echo >`, and saying `y` to vim's question) work for me. Do you have some enhanced security module loaded? – Alan Curry Aug 13 '12 at 04:08
  • @JonLin , AlanCurry: is that because my host is on openvz? –  Aug 13 '12 at 04:15
1

Just experienced the same problem in my environment.

Apparently OpenVZ is controlling these variables on a host level i.e. if you want to change some setting, you'll need to change it on the host machine and as an effect it will be applied to all VMs running on that physical server.

ljubomir
  • 113
  • 5