When you are giving interviews where you know you will be asked Linux. You can bet heavily on this question. This is one of the most basic questions that can be asked. In this article, we are going to see what is the answer to this question.
What does /proc Directory contains?
Let’s do a
ls in the directory and see what all content is present in the directory.
As you can see there are a lot of directories with numbers. You must be confused why are there numbers.
These directory actually consists of information of process id with which they are named.
Let’s check a process and verify it in the directory.
If you look at the image. We checked the process ID of the Nginx process. Then we
/proc/1216/cmdline file which contains the command used to start the process and you can see the Nginx startup command. Hence we verified this.
There are other files like
cpuinfo, stat, vmstat, meminfo and many more. These files contain the current running information of your system. You can always see these for system info given you know how to interpret the numbers. All the Linux utils like top free etc parse these files only to get the data. They use system calls which behind the scene parse these files.
Let’s look at the size of these files.
When you look at the size they are all 0. Wow, file of size zero. This is because they are virtual files and are generated on the fly from memory when you try to look into the content.
Now let’s look at what is inside the directory or each process. When we do ls inside any of the process directories it has many files to define its state and usages. A few of the notable ones are
status, stat, cmdline, etc. These files have all the information needed to identify every aspect of a process.
So now you understand what is inside /proc directory and how to answer these questions. If you want to know more you can explore the files and then search on google for their output format.
If you like the article please share and subscribe.
Can you please guide me how to start on Devops and get real time project experience. Please.