- [Instructor] Welcome to the next video
of the last section.
Using /proc for Gathering Information.
In the previous video, we've seen how to gather
system information.
In this video, we'll see how to use /proc
for gathering information.
/proc is an in-memory pseudo filesystem
available with the GNU/Linux operating system.
It was actually introduced to provide an interface
to read several system parameters from the user space.
It is very interesting, and we can gather
lots of information from it.
Let's see how to do it.
If you look at /proc,
you'll see several files and directories.
Some of which I already explained in this section.
You can simply cat files in /proc
in their subdirectories to get information.
All of them are well-formatted text.
There will be a directory in /proc
for every process that is running on the system,
named after the PID of that process.
Suppose Bash is running with a PID of 4295.
pgrep Bash/proc/4395 will exist.
Each of the directories corresponding to the process
will contain their lot of information
regarding that process.
A few of the important files in /proc/PID are as follows.
environ.
This contains environment variables
associated with the process.
Cat/proc/4295/environ
will display all the environment variables
passed to that process.
cwd.
This is a symlink to a working directory of the process.
exe, this is a symlink to the running executable
for the current process.
fd, this is the directory consisting of entries
on file descriptors used by the process.
Awesome, we've successfully learned how to use
/proc for gathering information.
In the next video, we'll learn about scheduling with cron.