Skip to content

Did you know?

Files in /proc show a size of 0, but they still have content.

The kernel creates the text when you read the file. Try cat /proc/uptime.

Explained

/proc is a virtual file system. Nothing in it is stored on disk; the kernel generates each file’s content at the moment you read it. Because the size isn’t known in advance, ls reports 0 bytes:

ls -l /proc/uptime
cat /proc/uptime
-r--r--r-- 1 root root 0 Nov 16 09:20 /proc/uptime
183462.51 1402981.33

The first number is the time since boot in seconds; the second is the total idle time of all CPU cores. Other useful files:

  • /proc/cpuinfo and /proc/meminfo: CPU and memory details
  • /proc/loadavg: the load averages that uptime shows
  • /proc/<PID>/: everything about one process, such as cmdline, environ and its open files in fd/
  • /proc/sys/: kernel settings, the ones sysctl changes

Because of the zero size, don’t trust tools that look at the size before reading. cat, grep and less work fine.

Learn more

← All tech tips · Suggest a fix

Back to top