Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
# cat /proc/version
Linux version 2.6.18-308.8.2.el5.028stab101.1 (root@rhel5-build-x64) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Sun Jun 24 20:25:35 MSD 2012
# ls -l /proc/version
-r--r--r-- 1 root root 0 Aug 22 10:07 /proc/version

The file size is reported as 0, but it has contents. How does this work?

Is it because /proc is some kind of virtual file system?

Which command could show the exact size of files in /proc?

share|improve this question

migrated from Aug 22 '12 at 6:41

This question came from our site for professional and enthusiast programmers.

this question is not suitable to be there, it's not a shopping or buying recommendation one:( – hugemeow Aug 22 '12 at 2:38
As I said, it's an operating system question (how to do something in the OS), and not a code-related question. See the FAQ, as I suggested before. – Ken White Aug 22 '12 at 2:42
but it's a linux related question, you know linux is a bit different from others, like windows, there are lots of topics in linux, but has nothing to do with digital equipment and shopping recommendation, also it have nothing to do with mobile phones, so it will be a fault to move this topic to superuser – hugemeow Aug 22 '12 at 2:46
For the last time! It's not a programming question. Superuser is for operating system questions, not just for shopping o0r mp3 questions. If you really insist, I can downvote this for being a poor programming question as well as vote to close it as off-topic. I think you misunderstand - users decide what's on-topic here and what isn't, and I've cast my vote as it not being appropriate. You're not going to convince me otherwise, so you may as well stop trying to do so. IMO, it's off-topic here. You obviously don't agree, since you posted it here in the first place. Discussion over. :-) – Ken White Aug 22 '12 at 3:04
Ken, procfs is a core part of the Linux ABI, and understanding how it works is an important part of linux programming. The question is simple, but not an inappropriate one to be asked by a beginning programmer. This absurdist flame war, on the other hand, is a disgrace and you should be ashamed of yourself. – Andy Ross Aug 22 '12 at 4:02
up vote 7 down vote accepted

It's because you're in the proc filesystem. See more info on what procfs is.

/proc/version, containing the Linux kernel version, distribution number, gcc version number (used to build the kernel) and any other pertinent information relating to the version of the kernel currently running

Those aren't real files. It's a convenient way to show process information as a file hierachy.


i know it's unreal, but what i should do if i want to know its size?

You're not getting it from ls, but you can try using wc:

# wc -c /proc/version
138 /proc/version
share|improve this answer
i know it's unreal, but what i should do if i want to know its size? – hugemeow Aug 22 '12 at 2:19
@hugemeow I've edited my answer – Jon Lin Aug 22 '12 at 2:21
i want a list which can tell me the size of files, not just a single one:( – hugemeow Aug 22 '12 at 2:34
@hugemeow then use find: find /proc/ -maxdepth 1 -type f -exec wc -c {} + – Jon Lin Aug 22 '12 at 2:39
@hugemeow write a script and call it a, that's real short. – Jon Lin Aug 22 '12 at 3:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .