Muggles' Guide to Harry Potter/Magic/Ghost

Overview
Ghosts are the disembodied souls of wizards and witches who have died (as described by Professor Snape, a ghost "is the imprint of a departed soul left upon the earth"). There are a large number of them in Hogwarts; they are able to speak with the living, but being incorporeal are unable to have any significant effect on matter.

Six ghosts are specifically named in the books: the four House ghosts (Nearly Headless Nick of Gryffindor House, the Fat Friar of Hufflepuff House, the Grey Lady of Ravenclaw House, the Bloody Baron of Slytherin House); Professor Binns, the History of Magic teacher; and Moaning Myrtle. Peeves the poltergeist is not a ghost, but a Spirit of Chaos, who has never been alive, according to the author.

Extended Description
In Harry Potter and the Order of the Phoenix, Harry, distraught over his godfather Sirius Black' death, corners ghost Nearly Headless Nick, hoping to learn what happened to Sirius after he died. Nick tells him, "Wizards can leave their imprint on the earth, to walk palely where their living selves once trod," but it takes special preparation, and it is a half existence, neither living nor dead. Nick chose that route because he feared death, but he believes that Sirius would not have done so.

Analysis
Throughout the books, ghosts are rather an aloof presence, intimating that death is not final; as Professor Dumbledore says in Harry Potter and the Philosopher's Stone, to one who has lived a full life, "death is but the next great adventure."

Ghosts are unusual magical creatures. In some ways, they are not creatures at all, but rather characters just like all the other living people in the books. But they are not quite the same, of course. Physically, they are semi-transparent, non-corporeal beings. Mentally, they enter a state somewhere between living and dead.

Ghosts can pass through solid objects: for instance, Professor Binns passes through the blackboard to enter his classroom, and though Harry is holding a door for him to enter a classroom, Nick instead passes through the adjacent wall. Ghosts interact with the living as well, just as Professor Binns interacts with his students. It seems that a ghost's sensibilities are somewhat altered after death, such as their perception of music — an orchestra of thirty musical saws would probably be bizarre and dreadful to the living. Professor Binns never seems able to completely sense his students' presence or emotions. Also, ghosts seem to remain tied to a place, some more than others. Professor Binns may be tied to the classroom where he taught while living, as Myrtle seems tied to the girls' bathroom she was killed in. The tie may be to something significant, a piece of unfinished business rather than a place. Myrtle, for instance, says she was prevented from haunting Olive Hornby, a girl who she believed had been tormenting her in life, and returned to Hogwarts by the Ministry. One presumes that the Ministry managed to magically change what Myrtle was centered on from her unfinished business, to the place of her death. Many of the other ghosts also seem to be anchored to Hogwarts despite having died at some remove, some in Albania.

While ghosts as a rule have no effect on the physical world — people walk right through them, for example — there are some exceptions. Professor Binns can use materials in his classroom to teach, and Moaning Myrtle seems able to spray water around, and turn on all the bathroom faucets when she is particularly upset.

Of all the ghosts at Hogwarts, by far the largest role is played by Moaning Myrtle. She is instrumental in Harry discovering the Chamber of Secrets in Harry Potter and the Chamber of Secrets, and assists Harry with the second task in Harry Potter and the Goblet of Fire. She also becomes a confidante to Draco Malfoy in Harry Potter and the Half-Blood Prince, when he seeks solace over having to perform a deadly task.

Nearly Headless Nick's role is largely instructional, explaining many aspects about the school and its history to Harry, Ron, and Hermione. He spends some time discussing the nature of death with Harry, as mentioned above. The author has said in an interview that the series became rather more centered around the mystery of death after her mother passed away; it is possible that some of Nick's speech here may echo the author's internal thoughts on the subject.

The Grey Lady assists Harry in locating the final Horcrux in Harry Potter and the Deathly Hallows.

Shades
In several books, these "spirit echoes" or "shadows" are conjured forth by one means or another. As these have no permanent existence, reverting when the spell recalling them is ended, they are not properly ghosts at all. It is perplexing that there is no term for these appearances. It is certainly true that their appearance is always due to extremely rare magic: the Priori Incantatem effect, at the end of Harry Potter and the Goblet of Fire, which shows us the shades belonging to Cedric Diggory, the muggle Frank Bryce, Bertha Jorkins, and Harry's mother and father that were retained within Voldemort's wand; and, in Harry Potter and the Deathly Hallows, the Resurrection Stone, which summons the shades of James and Lily Potter, Remus Lupin, and Sirius Black. In the Muggles' Guide, as the author has not suggested a term for them, we use "shades" to refer to these recalled essences or echoes of the departed.

Horcrux
Not all Horcruxes manifest as figures or ghost-like beings, but we note that in specific circumstances they can do so. A "ghostly" figure appears in Harry Potter and the Chamber of Secrets. Again, this is not properly a ghost, as the associated human, Tom Riddle, is nominally still alive. This Tom Riddle, however, explains that he is a "memory" which has been given being and life by Ginny Weasley, whose life force is being fatally drained to resurrect the memory into a living form. More detail is learned about this appearance later in the series, first when Professor Slughorn, in his memories, is seen to describe Horcruxes to Riddle, and later when Hermione tells Harry what she has learned about Horcruxes from the books she extracted from Dumbledore's study. While a Horcrux, trying to defend itself, projects simulacra of Harry and Hermione in Harry Potter and the Deathly Hallows, we believe the projected images have little to do with the associated soul.

Waystation
A third place where those who have died are seen, this one appearing in Harry Potter and the Deathly Hallows, appears to Harry as a waystation that is a surprisingly clean and empty simulacrum of King's Cross Station. Here, he meets what might be Dumbledore's shade, who tells Harry many things that were previously unknown to us and to Harry. Dumbledore closes this meeting by saying how it had all happened in Harry's mind, but that did not make it any the less real. We have reason to believe that this is Dumbledore's true spirit, as it reveals information that only the living Dumbledore would have known; it also knows about events occurring since Dumbledore's death. We have learned that people can leave fragments of themselves behind, as in the Wizarding Portraits, which continue to react as their models had, and are apparently able to have original thoughts; and of course, ghosts are similarly constituted though without needing a portrait behind them. While it was possible that Dumbledore left a fragment of himself behind to educate Harry, given his dislike for breaking souls apart, it is more likely that he simply chose to have his soul remain in the waystation and await Harry's arrival. The series remains mute on how Dumbledore was able to divine these aspects of life after death; perhaps his having studied the Elder Wand gave him some insight.

Unlike ghosts, people in the Waystation are apparently solid; for instance, Harry finds that he can touch Dumbledore.

Greater Picture
One concern with ghosts and similar manifestations actually involves something Hermione mentions in Harry Potter and the Deathly Hallows. Hermione asserts that the soul, by its nature, is very nearly unbreakable; it takes an extreme bit of psychic damage to shear some of it off. However, it appears that the artifacts left behind, portraits, ghosts, shades retained by the wands used to kill people, and Dumbledore's presence in the Waystation, all seem to be somehow imbued with that essence of personality we call a soul. Hermione says that dying does not damage the soul; how do these personality bits get separated? Or do the souls never proceed to their final reward until every last photograph and portrait of them is destroyed? It seems improbable that a connection remains; why would someone who has gone On care at all about what is still happening here? Additionally, none of the ten or so shades that we speak to seem to be able to say anything about what has happened to them since their deaths.

We can speculate that Dumbledore's comment after the duel in the Cemetery, "not ghosts, but a kind of spirit echo," is also what powers the portraits, photos, and the Waystation. We would speculate that this "spirit echo," rather than being in any way part of the soul, is more a magically-enhanced visualization of the effects that the person has had on the world, amplified by means of the portrait, or by local events and surroundings. Quite possibly, the Waystation simply provided a theatre for the spirit echo contained partially in Dumbledore's portrait and largely within Harry to speak directly to Harry. It is interesting that the echo of Dumbledore's spirit seems to have also retained some of his intellect... As for the Resurrection Stone, the situation there is cloudy as well. Can it actually call back the spirits of the dead? Or does it retrieve the spirit echoes out of the memories of the wielder? We suspect that the latter is more likely, as none of the four retrieved by the Stone evinced any real knowledge of anything that Harry didn't already know.

This actually also sheds some light on Nearly Headless Nick's comments regarding how ghosts are created. Hermione comments that it takes something akin to the act of murdering another to tear the soul, whereupon the separated (or nearly separated) soul fragment can be encased in an object outside the body. It is possible that the necessary precondition to create a ghost is some form of spell like the one that creates a Horcrux, one that makes the soul more fragile and easy to break, such that a piece of it shears off at the person's death and remains on earth, loosely bound to a place or a bit of unfinished business, perhaps. This of course explains neither the situation of Professor Binns nor of Moaning Myrtle; Binns by repute simply didn't notice that he had died, and Myrtle was presumably too young and inexperienced to have performed the necessary preparations. It is possible that their becoming ghosts was due to some unfinished business that they had on Earth, which had the necessary effect of making their souls brittle enough to fracture at their deaths, but this is never explained in the series.