LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   proc filesystem (https://www.linuxquestions.org/questions/linux-general-1/proc-filesystem-759797/)

Aquarius_Girl 10-05-2009 07:34 AM

proc filesystem
 
can any one tell me : how can a programmer use the proc filesystem's information ? kindly give me some examples !!

pixellany 10-05-2009 07:39 AM

What do you want to do?

/proc contains "virtual files" which are simply ways of viewing the various kernel data structures. The generic answer to your question is "read the file of interest and extract the desired data.".

Aquarius_Girl 10-05-2009 07:45 AM

thanks a lot for your valuable answer !

Aquarius_Girl 10-05-2009 10:55 PM

Have any one of you tried anything with the proc file system ? If so, kindly share your experiences !

thanks !

chrism01 10-06-2009 12:35 AM

Here's a classic example


echo 1 > /proc/sys/net/ipv4/ip_forward

http://www.togaware.com/linux/surviv...orwarding.html

pixellany 10-06-2009 06:12 AM

Quote:

Originally Posted by anishakaul (Post 3709056)
Have any one of you tried anything with the proc file system ? If so, kindly share your experiences !

thanks !

It would help if you would tell us what you want to accomplish. e.g. Are you looking for ways to get information out of /proc or for clever ways to control you system by writing TO it.

Aquarius_Girl 10-06-2009 06:36 AM

Actually, I am trying to find out what can be done to os using the valuable information contained in the proc file system !! Currently I am finding ways to play with the linux operating system ! Thats why i asked if you have done something w.r.t proc file system !

thanks !

lutusp 10-06-2009 12:55 PM

Quote:

Originally Posted by anishakaul (Post 3709420)
Actually, I am trying to find out what can be done to os using the valuable information contained in the proc file system !! Currently I am finding ways to play with the linux operating system ! Thats why i asked if you have done something w.r.t proc file system !

thanks !

We can't answer unasked questions, and we can't get you to ask a specific question, so:

Google: /proc filesystem

pixellany 10-06-2009 02:29 PM

Quote:

Originally Posted by anishakaul (Post 3709420)
Actually, I am trying to find out what can be done to os using the valuable information contained in the proc file system !! Currently I am finding ways to play with the linux operating system ! Thats why i asked if you have done something w.r.t proc file system !

thanks !

got it!!!

Here you go.....

Q: What can I do with the /proc filesystem?

A-1: By reading from the various data structures in /proc you can directly access just about everything the kernel is doing.

A-2: By writing to these same structures, you can change what the kernel is doing without "going through channels". In some cases, this will enable clever tricks and in other cases, it may total destroy your system.

Aquarius_Girl 10-06-2009 11:03 PM

@pixellany,

thanks for your reply, i did understand what u said, but can u give me at least 2 specific examples in which one achieves something my modifying/reading proc file systems !

thanks!

sundialsvcs 10-06-2009 11:14 PM

"/proc" is one of the cleverest inventions I have seen in a very long time.

Historically, it has always been a huge problem to either "peek behind the curtains of the operating-system" or (heaven forbid!) to (legitimately...) "change something."

"/proc" is a brilliantly elegant solution.

The operating-system gives you the perfect illusion that "all sorts of system data" is available as a collection of read/write files. (You may or may not have permission to read and/or to write them, of course...)

Any ol' "perfectly ordinary, nothin' special, non-privileged" program can easily work with that.

None of these files "actually exist, anywhere." The entire directory and all of its contents are purely a figment of the operating system's imagination.

lutusp 10-07-2009 02:03 AM

Quote:

Originally Posted by anishakaul (Post 3710502)
@pixellany,

thanks for your reply, i did understand what u said, but can u give me at least 2 specific examples in which one achieves something my modifying/reading proc file systems !

thanks!

Sure. Here's one:

Code:

$ find /proc | while read path
do
    echo "reading $path ..."
done

For the other, you need to read:

Google: /proc filesystem

Just like a mortal human being intent on learning things the usual way.


All times are GMT -5. The time now is 03:21 PM.