{"id":460992,"date":"2022-06-10T20:00:43","date_gmt":"2022-06-10T17:00:43","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-solve-the-too-many-open-files-error-on-linux\/"},"modified":"2022-06-10T20:00:43","modified_gmt":"2022-06-10T17:00:43","slug":"how-to-solve-the-too-many-open-files-error-on-linux","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/","title":{"rendered":"#How to Solve the \u201cToo Many Open Files\u201d Error on Linux"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2fc16547629\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2fc16547629\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/#%E2%80%9CHow_to_Solve_the_%E2%80%9CToo_Many_Open_Files%E2%80%9D_Error_on_Linux%E2%80%9D\" >&#8220;How to Solve the \u201cToo Many Open Files\u201d Error on Linux&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/#Shared_System_Resources\" >Shared System Resources<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/#Its_Not_Just_Files_Youve_Opened\" >It\u2019s Not Just Files You\u2019ve Opened<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/#File_Handle_Limits\" >File Handle Limits<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/#Increasing_the_Soft_Limit\" >Increasing the Soft Limit<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/#Making_Permanent_Changes\" >Making Permanent Changes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-solve-the-too-many-open-files-error-on-linux\/#Everything_is_a_File\" >Everything is a File<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CHow_to_Solve_the_%E2%80%9CToo_Many_Open_Files%E2%80%9D_Error_on_Linux%E2%80%9D\"><\/span>&#8220;How to Solve the \u201cToo Many Open Files\u201d Error on Linux&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<figure style=\"width: 1200px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage size-full wp-image-791996\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/03\/shutterstock_321627716.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Linux laptop showing a bash prompt\" width=\"1200\" height=\"675\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\">fatmawati achmad zaenuri\/Shutterstock.com<\/a><\/span><\/figcaption><\/figure>\n<p>On Linux computers, system resources are shared amongst the users. Try to use more than your fair share and you\u2019ll hit an upper limit. You might also bottleneck other users or processes.<\/p>\n<h2 id=\"shared-system-resources\"><span class=\"ez-toc-section\" id=\"Shared_System_Resources\"><\/span>Shared System Resources<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Amongst its other gazillion jobs, the kernel of a Linux computer is always busy watching who\u2019s using how many of the finite system resources, such as RAM and CPU cycles. A multi-user system requires constant attention to make sure people and processes aren\u2019t using more of any given system resource than is <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ropriate.<\/p>\n<p>It\u2019s not fair, for example, for someone to hog so much CPU time that the computer feels slow for everyone else. Even if you\u2019re the only person who uses your Linux computer, there are limits set for the resources your processes can use. After all, you\u2019re still just another user.<\/p>\n<p>Some system resources are well-known and obvious, like RAM, CPU cycles, and hard drive space. But there are many, many more resources that are monitored and for which each user\u2014or each <em>user-owned<\/em> <em>process<\/em>\u2014has a set upper limit. One of these is the number of files a process can have open at once.<\/p>\n<p>If you\u2019ve ever seen the \u201cToo many files open\u201d error message in a terminal window or found it in your system logs, it means that the upper limit has been hit, and the process is not being permitted to open any more files.<\/p>\n<h2 id=\"its-not-just-files-youve-opened\"><span class=\"ez-toc-section\" id=\"Its_Not_Just_Files_Youve_Opened\"><\/span>It\u2019s Not Just Files You\u2019ve Opened<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There\u2019s a system-wide limit to the number of open files that Linux can handle. It\u2019s a very large number, as we\u2019ll see, but there is still a limit. Each user process has an allocation that they can use. They each get a small share of the system total allocated to them.<\/p>\n<p>What actually gets allocated is a number of\u00a0<em>file handles<\/em>. Each file that is opened requires a handle. Even with fairly generous allocations, system-wide, file handles can get used up faster than you might first imagine.<\/p>\n<p>Linux abstracts almost everything so that it appears as though it is a file. Sometimes they\u2019ll be just that, plain old files. But other actions such as opening a directory uses a file handle too.\u00a0Linux uses block special files as a sort of driver for hardware devices. Character special files are very similar, but they are more often used with devices that have a concept of throughput, such as pipes and serial ports.<\/p>\n<p>Block special files handle blocks of data at a time and character special files handle each character separately. Both of these special files can only be accessed by using file handles.\u00a0Libraries used by a program use a file handle, streams use file handles, and network connections use file handles.<\/p>\n<p>Abstracting all of these different requirements so that they appear as files simplifies interfacing with them and allows such things as piping and streams to work.<\/p>\n<p>You can see that behind the scenes Linux is opening files and using file handles just to run itself\u2014never mind your user processes. The count of open files isn\u2019t just the number of files you\u2019ve opened. Almost everything in the operating system is using file handles.<\/p>\n<h2 id=\"file-handle-limits\"><span class=\"ez-toc-section\" id=\"File_Handle_Limits\"><\/span>File Handle Limits<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The system-wide maximum number of file handles can be seen with this command.<\/p>\n<pre>cat \/proc\/sys\/fs\/file-max<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805638\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/1-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Finding the system maximum for open files\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This returns a preposterously large number of 9.2 quintillion. That\u2019s the theoretical system maximum. It\u2019s the largest possible value you can hold in a 64-bit signed integer. Whether your poor computer could actually cope with that many files open at once is another matter altogether.<\/p>\n<p>At the user level, there isn\u2019t an explicit value for the maximum number of open files you can have. But we can roughly work it out. To find out the maximum number of files that one of your processes can open, we can use the <code>ulimit<\/code> command with the <code>-n<\/code> (open files) option.<\/p>\n<pre>ulimit -n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805641\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/2-5.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Finding how many files a process can open\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>And to find the maximum number of processes a user can have we\u2019ll use <code>ulimit<\/code> with the <code>-u<\/code> (user processes) option.<\/p>\n<pre>ulimit -u<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805643\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/3-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Finding the number of processes a user can have\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Multiplying 1024 and 7640 gives us 7,823,360. Of course, many of those processes will be already used by your desktop environment and other background processes. So that\u2019s another theoretical maximum, and one you\u2019ll never realistically achieve.<\/p>\n<p>The important figure is the number of files a process can open. By default, this is 1024. It\u2019s worth noting that opening the same file 1024 times concurrently is the same as opening 1024 different files concurrently. Once you\u2019ve used up all of your file handles, you\u2019re done.<\/p>\n<p>It\u2019s possible to adjust the number of files a process can open. There are actually two values to consider when you\u2019re adjusting this number. One is the value it is currently set to, or that you\u2019re trying to set it to. This is called the <em>soft limit<\/em>. There\u2019s a <em>hard limit<\/em> too, and this is the highest value that you can raise the soft limit to.<\/p>\n<p>The way to think about this is the soft limit really is the \u201ccurrent value\u201d and the upper limit is the highest value the current value can reach. A regular, non-root, user can raise their soft limit to any value up to their hard limit. The root user can increase their hard limit.<\/p>\n<p>To see the current soft and hard limits, use <code>ulimit<\/code> with the <code>-S<\/code> (soft) and <code>-H<\/code> (hard) options, and the <code>-n<\/code> (open files) option.<\/p>\n<pre>ulimit -Sn<\/pre>\n<pre>ulimit -Hn<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805660\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/4-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Finding the soft and hard limit for process file handles\" width=\"644\" height=\"130\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To create a situation where we can see the soft limit being enforced, we created a program that repeatedly opens files until it fails. It then waits for a keystroke before relinquishing all the file handles it used. The program is called <code>open-files<\/code>.<\/p>\n<pre>.\/open-Files<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805661\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/5-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The open-files program hitting the soft limit of 1024\" width=\"644\" height=\"110\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>It opens 1021 files and fails as it tries to open file 1022.<\/p>\n<p>1024 minus 1021 is 3. What happened to the other three file handles? They were used for the <code>STDIN<\/code>, <code>STDOUT<\/code>, and <code>STDERR<\/code> streams. They\u2019re created automatically for each process. These always have file descriptor values of 0, 1, and 2.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>How to Use the Linux lsof Command<\/em><\/strong><\/p>\n<p>We can see these using the <code>lsof<\/code> command with the <code>-p<\/code> (process) option and the process ID of the <code>open-files<\/code>program. Handily, it prints its process ID to the terminal window.<\/p>\n<pre>lsof -p 11038<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805664\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/6-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The stdin, stdout, and stderr streams and file handles in the lsof command output\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Of course, In a real-world situation, you might not know which process has just gobbled up all the file handles. To start your investigation you could use this sequence of piped commands. It\u2019ll tell you the fifteen most prolific users of file handles on your computer.<\/p>\n<pre>lsof | awk '{ print $1 \" \" $2; }' | sort -rn | uniq -c | sort -rn | head -15<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805665\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/9-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Seeing the processes that use the most file handles\" width=\"644\" height=\"359\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see more or fewer entries adjust the <code>-15<\/code> parameter to the <code>head<\/code> command. Once you\u2019ve identified the process, you need to figure out whether it has gone rogue and is opening too many files because it is out of control, or whether it really needs those files. If it does need them, you need to increase its file handle limit.<\/p>\n<h2 id=\"increasing-the-soft-limit\"><span class=\"ez-toc-section\" id=\"Increasing_the_Soft_Limit\"><\/span>Increasing the Soft Limit<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If we increase the soft limit and run our program again, we should see it open more files. We\u2019ll use the <code>ulimit<\/code> command and the <code>-n<\/code> (open files) option with a numeric value of 2048. This will be the new soft limit.<\/p>\n<pre>ulimit -n 2048<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805700\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/7-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Setting a new file handle soft limit for processes\" width=\"644\" height=\"75\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This time we successfully opened 2045 files. As expected, this is three less than 2048, because of the file handles used for <code>STDIN<\/code> , <code>STDOUT<\/code> , and <code>STDERR<\/code>.<\/p>\n<h2 id=\"making-permanent-changes\"><span class=\"ez-toc-section\" id=\"Making_Permanent_Changes\"><\/span>Making Permanent Changes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Increasing the soft limit only affects the current shell. Open a new terminal window and check the soft limit. You\u2019ll see it is the old default value. But there is a way to globally set a new default value for the maximum number of open files a process can have that is persistent and survives reboots.<\/p>\n<p>Out-dated advice often recommends you edit files such as \u201c\/etc\/sysctl.conf\u201d and \u201c\/etc\/security\/limits.conf.\u201d\u00a0However, on systemd-based distributions, these edits don\u2019t work consistently, especially for graphical log-in sessions.<\/p>\n<p>The technique shown here is the way to do this on systemd-based distributions.\u00a0There are two files we need to work with. The first is the \u201c\/etc\/systemd\/system.conf\u201d file. We\u2019ll need to use <code>sudo<\/code> .<\/p>\n<pre>sudo gedit \/etc\/systemd\/system.conf<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805701\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/10-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Editing the system.conf file\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Search for the line that contains the string \u201cDefaultLimitNOFILE.\u201d Remove the hash \u201c#\u201d from the start of the line, and edit the first number to whatever you want your new soft limit for processes to be. We chose 4096. The second number on that line is the hard limit. We didn\u2019t adjust this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805702\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/11-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The DefaultLimitNOFILE value in the system.conf file\" width=\"644\" height=\"180\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Save the file and close the editor.<\/p>\n<p>We need to repeat that operation on the \u201c\/etc\/systemd\/user.conf\u201d file.<\/p>\n<pre>sudo gedit \/etc\/systemd\/user.conf<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805703\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/12-3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Editing the user.conf file\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Make the same adjustments to the line containing the string \u201cDefaultLimitNOFILE.\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805704\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/13-3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The DefaultLimitNOFILE value in the user.conf file\" width=\"644\" height=\"180\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Save the file and close the editor. You must either reboot your computer or use the <code>systemctl<\/code> command with the <code>daemon-reexec<\/code> option so that <code>systemd<\/code> is re-executed and ingests the new settings.<\/p>\n<pre>sudo systemctl daemon-reexec<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805705\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/14-3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Restarting systemd\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Opening a terminal window and checking the new limit should show the new value you set. In our case that was 4096.<\/p>\n<pre>ulimit -n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805706\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/15-3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Checking the new soft limit with ulimit -n\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We can test this is a live, operational value by rerunning our file-greedy program.<\/p>\n<pre>.\/open-Files<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805707\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/16-4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Checking the new soft limit with the open-files program\" width=\"644\" height=\"110\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The program fails to open file number 4094, meaning 4093 were files opened. That\u2019s our expected value, 3 less than 4096.<\/p>\n<h2 id=\"wrap-up\"><span class=\"ez-toc-section\" id=\"Everything_is_a_File\"><\/span>Everything is a File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>That\u2019s why Linux is so dependent on file handles. Now, if you start to run out of them, you know how to increase your quota.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>What Are stdin, stdout, and stderr on Linux?<\/em><\/strong><\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/805629\/too-many-open-files-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How to Solve the \u201cToo Many Open Files\u201d Error on Linux&#8221; fatmawati achmad zaenuri\/Shutterstock.com On Linux computers, system resources are shared amongst the users. Try to use more than your fair share and you\u2019ll hit an upper limit. You might also bottleneck other users or processes. Shared System Resources Amongst its other gazillion jobs, the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":460993,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/03\/shutterstock_321627716.png?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-460992","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/460992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=460992"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/460992\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/460993"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=460992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=460992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=460992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}