hw-1

Set ulimit -n / open files Permanently in ubuntu

Set ulimit -n / open files Permanently in ubuntu

1
2
3
4
5
6
7
8
9
10
11
12
# available limit
user@ubuntu:~$ ulimit -n
1024

# To increase the available limit to say 65535
user@ubuntu:~$ sudo vim /etc/sysctl.conf

# add the following line to it
fs.file-max = 65535

# run this to refresh with new config
user@ubuntu:~$ sudo sysctl -p

if you got error “sysctl: permission denied on key ‘fs.file-max’” or not effect , you can skip that step, then you doing steps as below :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# edit the following file
user@ubuntu:~$ sudo vim /etc/security/limits.conf

# add following lines to it
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
root soft nproc 65535
root hard nproc 65535
root soft nofile 65535
root hard nofile 65535

# edit the following file
user@ubuntu:~$ sudo vim /etc/pam.d/common-session

# add this line to it
session required pam_limits.so

# logout and login and try the following command
user@ubuntu:~$ ulimit -n
65535