Yes, a program can know who its parent is.
To illustrate, let's create two bash scripts. The first one reports its PID and starts the second script:
$ cat s1.sh
#!/bin/bash
echo s1=$$
bash s2.sh
The second script reports its process ID, the PID of its parent, and the command line used to run the parent:
$ cat s2.sh
#!/bin/bash
echo s2=$$ PPID=$PPID
echo "Parent command: $(ps -o cmd= -q $PPID)"
Now, let's run it:
$ bash s1.sh
s1=17955
s2=17956 PPID=17955
Parent command: bash s1.sh
As you can see the second script does, in fact, know the PID of its parent. Using ps, that PID reveals the command line used to invoke the parent.
For a discussion of PPID in more depth, see Stéphane Chazelas's answeranswer.