In NetHack, some monsters have the ability to hide. Trappers, lurkers above, and various piercers can innately hide on the ceiling. Cave spiders and all snakes except water moccasins can hide under objects on the ground. Mimics can disguise as objects, which is related. All sea monsters can hide in water.
Moving next to a monster hidden in this manner grants them an opportunity to attack you unnoticed, and attempting to move onto the tile where they are produces "Wait! There's a foo hiding under <an item>!", wasting your movement time. This also goes for movement with the m command (sometimes except if you are warned of the creature).
If you know exactly where the hiding monster is and are already adjacent, you can simply use the F command to fight it. Otherwise, the monster will get a turn, and hence a chance to hit you, before you do. It is possible to hit hidden monsters with ranged weapons or thrown objects, making it fairly easy for wary players to detect them. Gold is good to throw because it is abundant, does not risk breaking pacifist conduct, and gets you credit in stores.
Searching is guaranteed to reveal their position, and causes them to stick to you if applicable.
If you are polymorphed into a monster capable of hiding, you can use the #monster command to hide under objects or on the ceiling. As of NetHack 3.6.4, if you are polymorphed into a monster capable of hiding on the ceiling, you can use > to unhide.