Does the dead recognize and listen to the visitor of his grave?
When a person who is alive visits the grave (i.e. go for Ziyarat) of an acquaintance (such as a relative, friend or acquaintance), according to Ahadith it is evident that the latter recognizes his visitor. In one Hadith it has been said (meaning), “When so happens that a Muslim walks past an acquaintance’s grave and conveys him Salaam, Allah Taala sends back the Ruh (soul) of the deceased into his body. Even he replies to the Salam conveyed to him.”This proves that the deceased recognizes the visitor.
In several narrations of Bukhari and Muslim the following is reported: According to the instructions of Rasulullah ﷺ, the dead bodies of the slain kafirs in the Badr Jihad had been dumped into a pit. Afterward, Rasulullah ﷺ once stood beside that pit and called out each kafir by name and inquired (meaning), “Had you got your Lord’s promises fulfilled? I have got mine all right.” To his surprise, Sayiduna Umar (R) (who was present there) asked (meaning), “O Rasulullah! You are addressing such people whose body had already got rotten (?) Rasulullah ﷺ replied (meaning), “By Allah, Who had sent me as the truthful Prophet, even you are not listening to me more than they are; however, they cannot reply (whereas you can).”
From: ‘Ruh’ of Shaikh Ibnul Qaiyim Jawziyah (R)