Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - News
User Name
Linux - News This forum is for original Linux News. If you'd like to write content for LQ, feel free to contact us.
All threads in the forum need to be approved before they will appear.


  Search this Thread
Old 06-25-2005, 12:45 PM   #1
Registered: Jun 2005
Distribution: OpenSUSE 10.3 , 11.2 , Solaris 10, Ubuntu 9.10
Posts: 84

Rep: Reputation: 16
Lightbulb System Information Made Easy : Contains of "/proc" folder in details

"Even LINUX Expert discovers new tricks!"

Dear Forum members ,

Have you ever wandered how the "KDE System Guard ", "top" etc. actually works ? How it gets all the details information ?
Have you ever wanted to create a your own one ?

Now you can do it. Because all the information resides in human readable format in "/proc" directory.
Try doing a "ls /proc" in shell. You will get the following files describes below and some folders. The "PROC" folder is created and modified in runtime by kernel or some system processes. It contains all the information needed to do administrative job. In Windows environment it is very difficult to get all information, but in Linux it's a breeze .

Below is the relavent information about it's files in short , informations regarding directories is given next to it :=>

1) Available files (may be changed ,depending upon Linux version and installed programs!)

file:/proc/cmdline == Kernel Command line (eg . "/rhgb", "quite" etc.
file:/proc/cpuinfo == used cpus and various info about them
file:/proc/crypto == current password encription (such as MD5)
file:/proc/devices == available character(eg terminal,sound etc.) and block device name and corresponding number
file:/proc/diskstats == status about all diskdevice including ramdrive (such as free space,etc.)
file:/proc/dma == dma status (such as cascade)
file:/proc/execdomains == don't know, maybe about kernel domain !
file:/proc/fb == maybe about any pending mails
file:/proc/filesystems == available filesystems (such as : ext3,vfat,etc.)
file:/proc/interrupts == available and usable interrupts and their number
file:/proc/iomem == kernel ram info (may be about available memory mapped io space)
file:/proc/ioports == available system io ports (such as timer,pci,vga+ , etc)
file:/proc/kcore == You can not access it as it is used by kernel itself
file:/proc/kmsg == Kernel Messages
file:/proc/loadavg == CPU Loads and uptime
file:/proc/meminfo == details about memory , including swap,cache,physical memory size and available free space
file:/proc/modules == loded kernel modules (such as snd,alsa,hw,gameport etc.)
file:/proc/mounts ==mounted partitions
file:/proc/partitions == Available Disk Partitions (eg. hda,hda1,...,hdb,.. etc.)
file:/proc/pci == pci devices and their corresponding Bus no.,devive no.,function no. ,irq no. etc.
file:/proc/slabinfo ==
file:/proc/stat == cpu usage info , Includes per cpu load (eg. cpu0,cpu1,...) , context switches , uptime etc.
file:/proc/swaps == Swap partition drive name and size etc.
file:/proc/uptime == Uptime (times elapsed since boot) for individule cpus
file:/proc/version == Linux Kernel version and compiler used to build it
file:/proc/vmstat == Details Virtual memory Info ,including page faults,range,etc.

2) Available directories (it will certainly be deferrent in your pc!)

The directories with all number such as 1, 4567,2385,112,40,41 etc. are actually PID of the currently Running processes.
Start the default process viewer (in KDE you can try key combination of CTRL+ESC) , see the PID tag list and compare it with the directory listing of the "/proc" directory . You can certainly find similarity in between them. And YES those are the actually PID of those running processes! e.gThe folder having name 1 represents "init" process .

in my pc it is like this :==>

1 2366 2621 3451 3691 3844 9 ide pci
1139 2397 2693 3456 3693 39 acpi interrupts scsi
114 2439 27 3553 3699 3955 asound iomem self
192 2450 2712 3581 37 3997 buddyinfo ioports slabinfo
193 2463 2731 3614 3701 3998 bus irq stat
195 2486 2744 3615 3702 4 cmdline kcore swaps
196 2508 2755 3658 3705 40 cpuinfo kmsg sys
2 2527 28 3661 3706 4084 crypto loadavg sysrq-trigger
209 2537 2893 3663 3712 4089 devices locks sysvipc
2128 2548 3 3666 3713 41 diskstats mdstat tty
2132 2578 3019 3668 38 4192 dma meminfo uptime
2143 2579 3020 3678 3809 4193 dri misc version
2154 2591 3021 3680 3810 4254 driver modules vmstat
2174 26 3022 3682 3811 5 execdomains mounts
2208 2603 3023 3686 3812 6 fb mtrr
2325 2617 3024 3688 3813 7 filesystems net
2355 2619 3025 3689 3814 8 fs partitions

Enter a directory ,let it be "1" , so issue "cd 1", you will be now in folder 1.
view it's contains "ls" :=>

attr cmdline environ fd mem root statm task
auxv cwd exe maps mounts stat status wchan

Explanation of individuals
attr == its a folder containing attributes of all child and parent processes
cmdline == it contains the COMMAND LINE used to create the process , so you can get NAME of the process from here
environ == ENVIRONMENT variable passed to it
fd == its a folder containing file descriptor (opened file handle ?)
mem == memory info ?
root == its a folder link to root directory
statm == memory status ?
task == its a folder containing task number ? (same as it's PID)
auxv == ??
cwd == current working directory
exe == MEMORY IMAGE of the Process . SO YOU CAN DUMP IT EASILY IN RUNTIME , use it for debugging purpose!
maps == ??
mounts == currently mounted devices(mount it used to join different filesystem to root filesystem)
stat == status about the process containg fields such as NICE value,PID,VMsize,Process name etc. (*** Good for making own process information program as it contains all necessary fields****)
status == some of the info from "stat" file but in easily understandable format!
wchan == currently running thread ?

[ LEGENDS : "?" => doubtful ,check it in the internet, "??" => not known to me! ]

Lengthy isn't it ? but it will be comfortable when you get used to it. Keep it's copy locally.

Note to programmers

Now you know the secret of those programs . Why don't you try it ?
Let me know what you have discovered , email me at :

Read data over and over and you will get the recent status , Linux will update it regularly.(so you don't have to be bothered with updation of "/proc" data.) You just have to update the GUI or text interface of your program according to the data provided.

******* Don't keep the files opened for longer as Linux writes to it at regular interval , may cause hang. Close the file as soon as you read it's contains *******


Please pardon my mistake if it is done as I am not a "LINUX GURU" .



Keep Discovering
Old 12-05-2005, 08:50 PM   #2
LQ Newbie
Registered: Dec 2005
Posts: 2

Rep: Reputation: 0
thats some useful information
Old 12-06-2005, 11:24 AM   #3
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,451
Blog Entries: 4

Rep: Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915
In 2.6 kernels, there is an additional pseudo-filesystem named /sys, which works in a similar way.

All of these filesystems are called pseudo-filesystems because they do not, in fact, correspond to any physical device. They are implemented solely in the kernel. And they are probably the most elegant, simple ... "kewel" ... way of handling the otherwise-difficult task of presenting system information that I have ever seen in any operating-system. All sorts of commands, like ps, lspci, and so on, no longer have to be "privileged" to do what they do: they simply browse the /proc directory and pretty-print what they see.

You might note that /proc/kcore might not exist. In 2.6 kernels, at least, it is optional. And, since it gives read/write access to kernel core, it is often omitted for security reasons.

Great post!
Old 01-02-2006, 03:40 PM   #4
Senior Member
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
Don't forget "man proc"
Old 01-17-2006, 05:16 PM   #5
LQ Newbie
Registered: Jan 2006
Location: Estonia
Posts: 22

Rep: Reputation: 15
Thanks! Just what I needed.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
what is "FRAG" in "/proc/net/sockstat" ? dileepkk Linux - Networking 1 06-21-2011 11:16 AM
"rm -rf /tmp", now Evolution shows "(no folder displayed" Ed-MtnBiker Linux - Software 7 04-10-2006 04:05 PM
Writing to "/dev/usb/hiddev*" and to "/proc/bus/usb/00B/00S" throw an arror EI stpg Programming 0 07-14-2004 05:44 AM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM
RH "null" beta system freezes right after printing "INIT" markus1982 Linux - Hardware 0 09-09-2002 03:31 PM > Forums > Linux Forums > Linux - News

All times are GMT -5. The time now is 10:35 AM.

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