How to count the number of threads in a process on Linux

Question: I have an application running, which forks a number of threads at run-time. I want to know how many threads are actively running in the program. What is the easiest way to check the thread count of a process on Linux? If you want to see the number of threads per process in Linux […]
Continue reading…

 

How to view threads of a process on Linux

Question: My program creates and executes multiple threads in it. How can I monitor individual threads of the program once they are created? I would like to see the details (e.g., CPU/memory usage) of individual threads with their names. Threads are a popular programming abstraction for parallel execution on modern operating systems. When threads are […]
Continue reading…

 

How to get the process ID (PID) of a shell script

Question: I want to know the process ID (PID) of the subshell under which my shell script is running. How can I find a PID in a bash shell script? When you execute a shell script, it will launch a process known as a subshell. As a child process of the main shell, a subshell […]
Continue reading…

 

How to check memory usage on Linux

Question: I would like to monitor memory usage on my Linux system. What are the available GUI-based or command-line tools for checking current memory usage of Linux? When it comes to optimizing the performance of a Linux system, physical memory is the single most important factor. Naturally, Linux offers a wealth of options to monitor […]
Continue reading…

 

How to install htop on CentOS or RHEL

Question: I heard nice things about htop as an alternative to top command. When I tried to install htop with yum package manager on CentOS, I got “No package htop available” error. How can I install htop on CentOS/RHEL? Htop vs. Top htop is an ncurses-based real-time process viewer for Linux. While its interface is […]
Continue reading…

 

How to check what libraries are used by a program or process on Linux

Question: I would like to know which shared libraries are loaded at run-time when I invoke a particular executable. Is there any way to identify shared library dependencies of a program executable or a running process on Linux? Check shared library dependencies of a program executable To find out what libraries a particular executable depends […]
Continue reading…