

To check the hard limit, use the -Hn flag together with the ulimit command. To check the soft limit, use the -Sn flag together with the ulimit command. The hard limit is changeable by privileged users. The soft limit is changeable (can only be lowered) by an unprivileged user but fully changeable by a privileged user. It can either be a soft limit or a hard limit. It is the limit to the number of files a process is allowed to open at any given time. The NAME column points to the file descriptor’s exact file and the TYPE column points to the file type. Then implement the lsof command to determine the per-process file descriptors. For instance, the per-process usage of the cat command’s file descriptors can be determined in the following manner:įirst, run the ps aux command to determine the process id: $ ps aux To check a process’s file descriptor usage, we first need to check the targeted process’s ID and then implement it in a lsof command. We can check the /proc/sys/fs/file-nr file’s first field with the following awk one-liner command: $ awk '' /proc/sys/fs/file-nrġ2832 Check File Descriptors Per-Process Usage of File Descriptors Under Linux file management, it is possible to associate various system agents and their assigned file descriptors (total number of file descriptors) to transparently account for used system resources. The three file descriptors are associated by their own unique notations and are as follows: When a user is done previewing the file, the close() system call is used to finally close the file.Īt any given file operation instance, three file descriptors (all of them being open by default), are linked to a single file process. The cat command then takes advantage of the assigned file descriptor to interact with the file (display its content). The open() system call is used to pass the filename as an argument before a file descriptor is assigned to it. Whenever a new file is open, it is immediately appended as a new entry on the process’s table of open file descriptors.įor instance, consider the basic usage of the Linux cat command to open a simple text file. Open file descriptors are tabulated and linked to the process responsible for their existence. In Linux, once a file is open, it is identified by a non-negative integer called a file descriptor. The entire hierarchy of a Linux operating system is file-attributed (be it the presentation of partitioned disk drives, network sockets, or regular/normal data). This article will investigate the cause and cure of the “ too many open files” error that is prominent in Linux operating system environments. Each system user or process in a Linux environment is assigned an open file limit value which is rather small. This Linux OS error simply implies that too many files (file descriptors) have been opened by a process and therefore no more files can be opened because the maximum open file limit has been met. If your Linux usage experience has led/exposed you to high-load Linux server environments, then there is a high chance you’ve crossed paths with the infamous “ too many open files” error.
