LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-05-2009, 07:34 AM   #1
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
proc filesystem


can any one tell me : how can a programmer use the proc filesystem's information ? kindly give me some examples !!
 
Old 10-05-2009, 07:39 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.".
 
Old 10-05-2009, 07:45 AM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
thanks a lot for your valuable answer !
 
Old 10-05-2009, 10:55 PM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

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

thanks !
 
Old 10-06-2009, 12:35 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Here's a classic example


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

http://www.togaware.com/linux/surviv...orwarding.html
 
Old 10-06-2009, 06:12 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by anishakaul View Post
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.
 
Old 10-06-2009, 06:36 AM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
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 !
 
Old 10-06-2009, 12:55 PM   #8
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by anishakaul View Post
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
 
Old 10-06-2009, 02:29 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by anishakaul View Post
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.
 
Old 10-06-2009, 11:03 PM   #10
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
@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!
 
Old 10-06-2009, 11:14 PM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
"/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.
 
Old 10-07-2009, 02:03 AM   #12
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by anishakaul View Post
@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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Notification on `/proc' filesystem. firstfire Programming 6 04-07-2006 01:59 AM
/proc filesystem has too many 2gb files hard disk getting full sadun SUSE / openSUSE 5 09-16-2005 07:40 AM
how to maintain /proc filesystem hardeep_ubhi Linux - Newbie 6 03-22-2005 08:34 AM
/proc filesystem dawsonbdky Linux - General 1 08-16-2004 10:06 AM
/proc filesystem dawsonbdky Linux - General 1 08-13-2004 09:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration