Skip to content

Instantly share code, notes, and snippets.

@bfgits
Created April 16, 2020 09:00
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save bfgits/b4f922958716088f4c840365e54c625e to your computer and use it in GitHub Desktop.
Save bfgits/b4f922958716088f4c840365e54c625e to your computer and use it in GitHub Desktop.
Set Permanently ulimit -n / open files in ubuntu
# 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
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
# run this to refresh with new config
user@ubuntu:~$ sudo sysctl -p
# logout and login and try the following command
user@ubuntu:~$ ulimit -n
65535
@capaj
Copy link

capaj commented Apr 7, 2022

doesn't seem to work anymore on ubuntu 21.04

@ngtrieuvi92
Copy link

This doesn't work on ubuntu 20.04 LST too

@AbdullahPF
Copy link

This is not working on Ubuntu 20.04 LTS

@Meikelrizkyhartawan
Copy link

it's working in Ubuntu 22.04 LTS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment