Holy Kaba
وَقَالَ رَبُّكُمُ ادْعُونِي أَسْتَجِبْ لَكُمْ إِنَّ الَّذِينَ يَسْتَكْبِرُونَ عَنْ عِبَادَتِي سَيَدْخُلُونَ جَهَنَّمَ دَاخِرِينَ

Madina Mosque

What Benefits the Deceased:

1- Giving charity on their behalf
2- Beneficial knowledge that they have left behind
3- A righteous child who prays for them
Abu Huraira (may Allah Almighty be pleased with him) said: “The Prophet ﷺ said: When a person dies, his deeds come to an end except for three things: ongoing charity, beneficial knowledge from which people benefit, or a righteous child who prays for him.” - (Jami’ al-Tirmidhi, Hadith No. 1376)
Giving Charity on Behalf of the Deceased:

From Islamic writings, it is indicated that the deceased benefits from charity given by a living person on their behalf and from the supplications made for them.
If the person giving charity is sincere in offering it in the name of the deceased and prays for them, the deceased benefits from it, and the one who gives charity and prays for the deceased also receives mercy and reward from Allah Almighty.
This is sufficient for him that Allah Almighty knows his sincerity and good deeds, and Allah Almighty grants reward to both sides.
As for whether the deceased recognizes the one who performs good deeds in their name, there is no evidence in the Shariah about it.
This is an unseen matter that cannot be known except through revelation from Allah Almighty to the Prophet ﷺ.
Giving charity on behalf of the deceased benefits the deceased, and its reward reaches them according to the consensus of Muslims.
Likewise, the person who gives charity also receives an equal reward.
In the authentic Hadith (No. 1004) narrated by Imam Muslim from Aisha (may Allah Almighty be pleased with her):
A man came to the Prophet ﷺ and said: “O Messenger of Allah Almighty ﷺ, my mother died suddenly, and she did not leave any will. I think that if she could have spoken, she would have given charity. If I give charity on her behalf now, will she receive the reward?” The Prophet ﷺ said: “Yes.”
An-Nawawi (may Allah Almighty have mercy on him) said: This Hadith shows that it is permissible and recommended to give charity on behalf of the deceased, as its reward reaches and benefits them, and it also benefits the one who gives it.
All Muslims have agreed upon this.
Charity can be spent on all kinds of good deeds and given to the needy.
Continuous Charity (Sadaqah Jariyah):

Continuous charity is a type of charity that a person establishes during their lifetime, and its benefit continues to reach them after their death.
Sadaqah Jariyah is a kind of endowment (waqf), such as spending in the path of Allah Almighty, building mosques, planting trees, digging wells, printing and distributing copies of the Noble Qur’an, building bridges, or producing and sharing beneficial knowledge resources for people.
Abu Huraira (may Allah Almighty be pleased with him) reported that the Prophet ﷺ said: “Among the good deeds that continue to reach a believer after his death are: knowledge that he taught and spread, a righteous child he leaves behind, a copy of the Qur’an he leaves as inheritance, a mosque he built, a house for travelers he established, a river he made to flow, or charity he gave while healthy in his lifetime — the reward of all this continues to reach him after his death.” - (Ibn Majah 242)
Ibn Umar (may Allah Almighty be pleased with him) reported that Umar ibn al-Khattab (may Allah Almighty be pleased with him) received a piece of land in Khaybar.
He went to the Prophet ﷺ for advice and said: “O Messenger of Allah Almighty ﷺ, I have obtained land in Khaybar, and I have never possessed anything more valuable than this. What do you command me regarding it?”
The Prophet ﷺ said: “If you wish, you may retain the property and give its produce as charity.”
So he gave it as charity on the condition that it would not be sold, gifted, or inherited.
He dedicated it to the poor, relatives, for freeing slaves, in the path of Allah Almighty, and for guests.
The one who manages it may eat from it in a reasonable manner or feed others, but not with the intention of accumulating wealth.”
The narrator (Ibn Awn) said: When I mentioned this Hadith to Ibn Sirin, he said: “The caretaker should not have the intention of collecting wealth from it.”
Performing Hajj on Behalf of the Deceased:

Ibn Abbas (may Allah Almighty be pleased with him) reported that a man came to the Prophet ﷺ and said:
“My sister vowed to perform Hajj, but she died.”
The Prophet ﷺ said: “If she had a debt, would you pay it off?” He said: “Yes.”
The Prophet ﷺ said: “Then pay off Allah Almighty’s debt, for Allah Almighty is more deserving that His debts be paid.”
(Bukhari 6699)