Gui is the general Chinese word for the spirit of a dead person, and it carries none of the specialised menace that English "ghost" implies on its own. In the classical framework set out across Confucian ritual texts and later folk religion, every person possesses a hun and a po, spiritual components that separate at death: the hun ideally ascends and can be reached through ancestral offerings, while the po tends toward the earth and, if neglected, becomes a gui. A properly memorialised ancestor is not a gui in practice, even though the character can apply to any of the dead, because regular offerings of food, incense and paper money keep the relationship stable and the spirit content.
The dangerous gui is specifically the one nobody feeds: a person who died badly, without descendants, without burial, or violently, so that no living family performs the rites that would settle it. Chinese religion therefore treats hostile spirits as a social failure as much as a supernatural one, and the remedy is characteristically bureaucratic rather than exorcistic, since unclaimed gui can be given offerings by temples or communities standing in for missing kin. This same logic scales up into the Ghost Festival, when the gates of the underworld open once a year and all wandering gui, not just one's own ancestors, receive food from the whole community.