basnotes

 

Linux: Too many files open

tip

I’m a happy Linux desktop user and running Zorin OS 16.2. Every now and then some Gnome extensions stop working without any error message. I found out what happens.

The issue

I had noticed several times that some of my Gnome extensions stopped working. It seemed to happen randomly and I couldn’t find an explanation for the cause.
Until I checked the plugins in the Extension Manager:

error message Bluetooth Quick Connect extension

Apparently, multiple plugins ran into an error: “Too many open files”.

Searching for “gnome extensions too many open files” in Google led me to find an How-To Geek [1] article that handled the exact same issue and clearly explains the cause and remedy.

The cause

In short: Linux has a limit on how many files are allowed to open, by default 1024.
1024 doesn’t directly sound like a small amount if you consider how many files users explicitly open, like for example in a text editor. But when using many webbrowser tabs and one or more IDE’s which index lots of files, this number suddenly feels much smaller.

With tool ulimit, you can check the soft limit:

$ ulimit -n
1024

The solution

The limits can be modified by editing 2 files:

$ sudo nano /etc/systemd/system.conf
$ sudo nano /etc/systemd/user.conf

In both files, modify the line containing:

- #DefaultLimitNOFILE
+ DefaultLimitNOFILE=4096:524288

This modifies the 1024 limit to 4096.

Conclusion

After a reboot, my Gnome extensions were working again. Time will tell if the problem is resolved with this value…

See below link for more detailed information about this issue and the solution to it.

[1] How-To Geek - How to Solve the “Too Many Open Files” Error on Linux

January 19, 2023