$$
is a special bash variable (special parameter $
with a preceding expansion mark $
) that gets expanded to the pid of the shell
.
/proc/self
is a real symbolic link to the /proc/ subdirectory of the process that is currently making the call
.
When you do ls /proc/$$
the shell expands it to ls /proc/pid-of-bash
and that is what you see, the contents of the shell process.
But when you do ls /proc/self
you see the contents of the short lived ls
process. If you write code which uses /proc/self
that code will see its own pid, namely the process making the system call with /proc/self
as part of the pathname in one of its arguments.
The $$
is not limited to this usage, you can write echo $$ to see the bash pid; you can use it to kill yourself, etc.