Spread the love

While administrating a box, you may wanted to find out what a processes is doing and find out how many file descriptors (fd) are being used. You will surprised to find out that process does open all sort of files:

=> Actual log file
=> /dev files
=> UNIX Sockets
=> Network sockets
=> Library files /lib /lib64
=> Executables and other programs etc
In this quick post, I will explain how to to count how many file descriptors are currently in use on your Linux server system.

Step # 1 Find Out PID
To find out PID for mysqld process, enter:

# ps aux | grep mysqld


# pidof mysqld

Step # 2 List File Opened By a PID # 28290
Use the lsof command or /proc/$PID/ file system to display open fds (file descriptors), run:

# lsof -p 28290

# lsof -a -p 28290


# cd /proc/28290/fd

# ls -l | less

You can count open file, enter:

# ls -l | wc -l
Tip: Count All Open File Handles
To count the number of open file handles of any sort, type the following command:

# lsof | wc -l

Sample outputs:
List File Descriptors in Kernel Memory
Type the following command:

# sysctl fs.file-nr

Sample outputs:
fs.file-nr = 1020 0 70000

1020 The number of allocated file handles.
0 The number of unused-but-allocated file handles.
70000 The system-wide maximum number of file handles.

You can use the following to find out or set the system-wide maximum number of file handles:

# sysctl fs.file-max

Sample outputs:
fs.file-max = 70000

Related Posts


Apache Kafka Commands Cheat sheet

Spread the loveKafka Topics List existing topics bin/kafka-topics.sh –zookeeper localhost:2181 –list Purge a topic bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –config retention.ms=1000 … wait a minute … bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –delete-config retention.ms
Read more…


What is Apache Maven | Apache Maven complete tutorial from scratch pdf

Spread the love In this post you will learn the complete tutorial of Apache Maven build tool What is Maven ? Apache Maven is a software project management and comprehension tool. Based on the concept
Read more…


Practical Guide for Web Development in 2018

Spread the loveWelcome to my practical guide  for web development in 2018 in terms of  technology and career. Before we start I just want to  mention a few things, you don’t need to learn  everything that
Read more…