In most cases involving "ghosts," they are actually lost souls/spirits. Sometimes due to a sudden or confusing death the soul/spirit does not know how to proceed with the death process and hangs around their familiar earthly world. Sometimes they are carrying anger from when alive and cause mischief as a "ghost". Fortunately these spirits don't have much energy to affect the physical world and cause much trouble.
After a person dies, the soul/spirit normally leaves the Earth plane by "going through the tunnel to the light." They usually also do a life review before taken to the pure spirit level. However, some souls/spirits get stuck in the death process and do not, or cannot, go to the light. For some reason they stay and hang around the Earth plane. While hanging around the Earth plane in their "ghost" form they are normally very unhappy about their disorienting situation of being without a body and not seen by alive people.
I only very briefly outline the steps here for the soul/spirit journey in order to emphasize how important it is to understand the death process before we need to use it. I invite you to read more about this extremely important and fascinating subject of the death process in books on the subject. For now, I offer two cases I had involving spirits stuck on the Earth plane as "ghosts". Read the first case about a family of "ghosts".