An exploration of the /proc directory

snewmark(53)
Published in
#linux
Words
190
Reading
1 min
Listen
Play
9y

The /proc directory is a way to view information on the running processes and the kernel within the file system.

/proc/[pid]/

For each process on the computer, there is a directory containing files with information on it.

/proc/[pid]/cmdline

This is a file that contains the command that started this process.
For example, run ps and get the process id of the shell. Next, run cat /proc/[pid]/cmdline (pid being the shell's process id.) And you would see the command that started the shell (probably bash.)

/proc/[pid]/cwd

This is a symlink to the current working directory of the process
Now, run readlink -f /proc/[pid]/cwd with pid still being the process id for the shell, and you will see the directory you are currently in.

/proc/[pid]/exe

This is a symlink to the original executable
And now, run readlink -f /proc/[pid]/exe and you will get the location of bash (or what ever shell you were using).

/proc/version

This contains information on the current version of Linux and its compiling.

/proc/uptime

This contains how long the kernel has been running for in seconds.

This is just a bit of the information you could get from the /proc directory.

An exploration of the /proc directory | Ecency