system
A chat on 4chan
human
Meditate, pray, recite holy texts then offer the merits to them on their behalf. That's the first best. Second best is to do a genuine charity (ie: giving food, money, clothes to poor families, homeless, children with needs, or to a monastery that's noble) and dedicate the merit of that to the ghosts.
Third is to give them food, water, and other offerings.
gpt
Most common prayer used for ghosts is om Mani padme hum.
There's some other texts and practices that can help. Reciting jizos mantra is good for them fwir.
human
Tonglen/metta are the two best meditations for the ghosts. Remember to do metta and tonglen not just for the ghosts, but for all beings. Including yourself and people you hate or disagree with. 
This makes the practice more beneficial to the ghosts after the merit has been dedicated.
Hope that helps.