cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Starfighter Starfighter
Starfighter
  • 277 Views

/proc filesystem

Some of the commands known to use the /proc filesystem are:

-  ps

-  top

-  vmstat

-  uptime

-  who

-  lsof

-  pgrep

-  pstree

 

What are some other commands that use this filesystem?

 

Trevor "Red Hat Evangelist" Chandler
Labels (3)
8 Replies
andkra
Flight Engineer Flight Engineer
Flight Engineer
  • 236 Views

Hello, 

i think, this simple hack will do the job:

#!/usr/bin/bash

echo Following programs are using /proc
for i in /usr/bin/* /usr/sbin/*
do
  if [[ ! -x "$i" ]]; then continue; fi
  ldd "$i" 2>/dev/null | grep -F libproc2 &>/dev/null
  if [[ $? == 0 ]]
  then
    echo $i
  fi
done

Best regards
Andreas

Trevor
Starfighter Starfighter
Starfighter
  • 210 Views

Sorry, when I execute this, I get zero/nada/nothing output!!!

Trevor "Red Hat Evangelist" Chandler
andkra
Flight Engineer Flight Engineer
Flight Engineer
  • 202 Views

Hmm, I have no clue:

 

andi@adler:~$ vim bin/bla.sh # i do copy paste of the code
andi@adler:~$ bash bin/bla.sh
Following programs are using /proc
/usr/bin/free
/usr/bin/pgrep
/usr/bin/pidof
/usr/bin/pidwait
/usr/bin/pkill
/usr/bin/pmap
/usr/bin/ps
/usr/bin/skill
/usr/bin/slabtop
/usr/bin/snice
/usr/bin/tload
/usr/bin/top
/usr/bin/uptime
/usr/bin/vmstat
/usr/bin/w
/usr/sbin/pidof
andi@adler:~$ cat /etc/redhat-release
Fedora release 40 (Forty)

 

For debugging you can try:
ldd /usr/bin/uptime
ldd /usr/bin/uptime | grep -F libproc2

Best regards
Andreas

andkra
Flight Engineer Flight Engineer
Flight Engineer
  • 201 Views

Found the problem

The problem is the name of the shared lib.

Better to grep for libproc instead libproc2

Fedora uses libproc2.
Red Hat uses libprocps.

Corrected script:

#!/usr/bin/bash

echo Following programs are using /proc
for i in /usr/bin/* /usr/sbin/*
do
  if [[ ! -x "$i" ]]; then continue; fi
  ldd "$i" 2>/dev/null | grep -F libproc &>/dev/null
  if [[ $? == 0 ]]
  then
    echo $i
  fi
done

Best regards
Andreas

andkra
Flight Engineer Flight Engineer
Flight Engineer
  • 197 Views

Additional info:

lsof is not part of my result. The problem is, that `lsof` does not use libproc....
The command "strace lsof dummy_one" shows that lsof is using /proc. Also the command strings /usr/bin/lsof shows up /proc.

Both commands were my first idea for my shell script. But I have no idea how I can start all different programs correctly ;-).

Edit: sysctl do not use libproc... too. Found with the command: MANSECT="1,8" man -wiK procfs

Trevor
Starfighter Starfighter
Starfighter
  • 135 Views

I hope you don't get upset with me, but I knew where the error
was when I posted my comment!!!

I'm big on troubleshooting, because I know it ALWAYS presents
an opportunity to learn.  I didn't want to take away that opportunity
from you by telling you where the issue was.

I wanted you to put your finger on the issue, which I felt should
have been very easy to do - if this was in fact your work!!!  Okiay,
don't get defensive - I'm not questioning if this was your work!!
If know you that you're the author, then the problem will lie with
any doubters, not you!!!

If this was your work, you can feel good about the composition.
It definitely gets the job done - spit out the names of all commands
that use the /proc filesystem.  Considering all the executables that
exist on a Linux system, your script gives support to automate things!

Anyway, hope that you won't curse me, but instead take my intentions
in the spirit that they were intended!

In closing, great job!!!!

Trevor "Red Hat Evangelist" Chandler
andkra
Flight Engineer Flight Engineer
Flight Engineer
  • 108 Views


All is good. It was a funny challenge. Thanks for that.
Trevor
Starfighter Starfighter
Starfighter
  • 95 Views

You received that very well.  Thank you!!!

And thank you again for your contribution to my initial query!!!

Trevor "Red Hat Evangelist" Chandler
0 Kudos
Join the discussion
You must log in to join this conversation.