1. cd /proc/$$/root/bin
  2. cd /bin

After running ls command on both the directory, I found that content of both directories are same (which is nothing but list of commands).

Is there any specific reason for this having same command-list in both directory?

  • 5
    nitpick: directories hold files (including programs), not commands. Commands are the strings that you give to shell, which in turn runs the appropriate programs or builtin functions.
    – mike3996
    Mar 23 '16 at 14:13

/proc is a "virtual" filesystem exposing some kernel and process related details.

$$ is a shell variable giving the PID of the shell running it.

/proc/$$/root is a symbolic link to the root directory as seen by the current shell. This could change in case you are chrooting.

In short, the two look identical because they are the same directory. If you execute ls -ld /proc/$$/root you will see that it is a symbolic link to /, and therefore /proc/$$/root/bin and /bin are the same directory.


That's because they are, in fact, the same directories¹:

$ test /proc/$$/root/bin -ef /bin; echo $?

(The -ef test checks whether two paths refer to the same file object.)

The same holds true for /proc/$$/root and /, because

$ readlink /proc/$$/root

¹ unless you are in a chroot environment which may point /proc/$$/root to a different directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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