ls -rlth /proc/stat
-r--r--r-- 1 root root 0 Feb 21 04:25 /proc/stat

Although if we cat it, its got enough contents.


proc is a virtual file system mapping file names to internal linux structures/variables; so it is normal /proc/stat having 0 bytes.

From wikipedia: procfs

The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing methods or direct access to kernel memory. Typically, it is mapped to a mount point named /proc at boot time. The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime (sysctl).

From TLDP Linux Filesystem Hierarchy: /proc

The most distinctive thing about files in this directory is the fact that all of them have a file size of 0, with the exception of kcore, mtrr and self.

Note: Actually only mtrr and self are 0 size in my servers - kcore is the memory that you are able to address, i.e. kernel virtual memory addresses hence the 128TB. Also relevant for this discussion, is /proc/kcore not being implemented in MIPS and ARM architectures.


That's because it is a virtual file that has no predefined known size, the actual size, i.e. the amount of data returned will vary depending on when you read it.

Some /proc files might have a non null size because it is known in advance.

          This  file  represents the physical memory of the system and is stored in the ELF core file for-
          mat.  With this pseudo-file, and an unstripped kernel (/usr/src/linux/vmlinux) binary,  GDB  can
          be used to examine the current state of any kernel data structures.

          The total length of the file is the size of physical memory (RAM) plus 4KB.

However, given the fact I haven't 128 TB of RAM on my machine, the reported value and the size that might be read do not match the documentation:

$ ls -lh /proc/kcore
-r--------. 1 root root 128T Feb 23 16:10 /proc/kcore
  • 1
    And some have a non-null size that doesn't correspond to the number of bytes that you can read from them (like /proc/bus/pci/*/*). There are a lot more of those in /sys. – Stéphane Chazelas Feb 23 '16 at 14:58
  • 1
    kcore is the memory that you are able to address, i.e. kernel virtual memory addresses hence the 128TB – Rui F Ribeiro Feb 23 '16 at 15:18
  • @RuiFRibeiro I do not question that, just the documentation that wrongly states the displayed size should be "size of RAM + 4KB" – jlliagre Feb 23 '16 at 15:20
  • @jlliagre and in one of my old 32 bits-server with 521MB, kcore has 1GB. – Rui F Ribeiro Feb 23 '16 at 15:45
  • 2
    @RuiFRibeiro That's what I suspected, the documentation lags or doesn't match the implementation. A common issue with Linux. – jlliagre Feb 23 '16 at 16:16

/proc is a special file system. It is not something that you store files in. It is a virtual filesystem, I know it is not the right analogy but consider it something like device driver in your /dev directory. What you write to the files in /dev gets passed on to the system in some way. Likewise, when you read from a file, it pulls those values from the system. Hence, since there is no actual stored information in these files, the size shows as zero.

Not the answer you're looking for? Browse other questions tagged or ask your own question.