Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-27-2016, 04:48 PM   #1
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
Paradox? Files in /proc are mostly ZERO bytes....

Many files in /proc are ZERO bytes....
/proc $ ls -al | tail
dr-xr-xr-x 2 root root 0 Mar 27 14:41 sysvipc
-r--r--r-- 1 root root 0 Mar 27 14:41 timer_list
-rw-r--r-- 1 root root 0 Mar 27 14:41 timer_stats
dr-xr-xr-x 4 root root 0 Mar 27 14:41 tty
-r--r--r-- 1 root root 0 Mar 27 14:41 uptime
-r--r--r-- 1 root root 0 Mar 27 14:41 version
-r--r--r-- 1 root root 0 Mar 27 14:41 version_signature
-r-------- 1 root root 0 Mar 27 14:41 vmallocinfo
-r--r--r-- 1 root root 0 Mar 27 14:41 vmstat
-r--r--r-- 1 root root 0 Mar 27 14:41 zoneinfo

/proc $ file uptime
uptime: empty

/proc $ cat uptime
743868.34 1109580.45
So you see uptime is not really empty.
How do you make a file listed as empty (0 bytes) while it actually has content (in RAM)?

Why is it listed as empty for these many files in /proc (a pseudo filesystem) ?

Some files listed with zero bytes have huge amount of data also....

Last edited by fanoflq; 03-27-2016 at 04:51 PM.
Old 03-27-2016, 05:10 PM   #2
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Old 03-27-2016, 05:27 PM   #3
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Answer to self:

They have zero bytes because they do not exists yet. They only produce data when they are viewed.

And ......

I notice here is uptime:
/proc $ whereis uptime
uptime: /usr/bin/uptime /usr/bin/X11/uptime /usr/share/man/man1/uptime.1.gz
For each file in /proc there is a corresponding process running, correct?

When I do
/proc $ ps -ax | grep uptime
21939 pts/2 S+ 0:00 grep --colour=auto uptime

uptime does not exists!
But if you list uptime in /proc, say every 1+ minutes, its timestamp changes.....
So it must be running butnot show up in ps -ax .

Last edited by fanoflq; 03-27-2016 at 05:36 PM.
Old 03-27-2016, 07:33 PM   #4
Registered: Mar 2015
Distribution: Ubuntu
Posts: 37

Rep: Reputation: Disabled
I definitely recommend reading the info on the link Teufel already posted. From scanning it there appears to be some good insights there... And if you still have questions searching Google (or you fave search site) for general descriptions/intros to the "/proc" filesystem is probably your best bet.

Why should you read docs about "/proc" instead of just asking specific questions? Because it's not really a filesystem and learning specific details until it all makes sense will take orders of magnitude more than getting a general sense of how it works first.

Here are a couple foundational facts that (I think) highlight how different it is from a real filesystem.

- There are no "/proc" files with "current" information on things like TCP connections, the current load average, etc... waiting for you to "read" them.

- Parts of it, meaning everything under "/proc/sys" is really just used as a mechanism for setting (and getting) configuration flags/values in the kernel.

- When you "read" from file in "/proc" the kernel figures out what content is appropriate for that request at exactly that moment and generates is on the fly. That information is never retained anywhere by the kernel.

- Ultimately "/proc" is really a crude, old, wildly inconsistent access method to a database of kernel information. Even so it's incredibly useful. The clumsiness and inconsistency is mostly related to the fact that it's been around for ages and has grown organically.

And for anyone that's interested, I have been working on a Python project to provide a more programmatically friendly way to pull data from the "/proc" filesystem. You can find it here,
1 members found this post helpful.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need explanation of /proc/net/dev bytes counters waddles Linux - Networking 6 04-21-2013 02:20 AM
Cannot read beyond the first 2^63 bytes in /proc/<pid>/mem yeye_olive Programming 5 05-17-2009 05:06 AM
Cannot view files over 250 bytes finaidques Linux - Server 2 10-10-2007 09:41 PM
files reduced to 0 bytes ghep Linux - Hardware 2 07-05-2007 01:34 PM
Samba truncating files to 0 bytes KimVette Linux - Networking 6 01-30-2005 07:42 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:34 PM.

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