Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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
$ ls -og /proc/self /proc/self/fd
lrwxrwxrwx 1 64 Jun 18 11:12 /proc/self -> 32157

total 0
lrwx------ 1 64 Jun 22  2012 0 -> /dev/tty1
lrwx------ 1 64 Jun 22  2012 1 -> /dev/tty1
lrwx------ 1 64 Jun 22  2012 2 -> /dev/tty1
lr-x------ 1 64 Jun 22  2012 3 -> /proc/32157/fd

What is the file descriptor 3 assigned by default?

share|improve this question
up vote 22 down vote accepted

Nothing: there are three standard file descriptions, STDIN, STDOUT, and STDERR. They are assigned to 0, 1, and 2 respectively.

What you are seeing there is an artifact of the way ls(1) works: in order to read the content of the /proc/self/fd directory and display it, it needs to open that directory.

That means it gets a file handle, typically the first available ... thus, 3.

If you were to run, say, cat on a separate console and inspect /proc/${pid}/fd for it you would find that only the first three were assigned.

share|improve this answer
Ah, that explains the result, including the fact that 3 points to /proc/32157/fd as well. (Why did I miss that?) Thank you! – musiphil Jun 23 '12 at 0:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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