The #sit extended command makes your character sit down; this can have different effects (and messages) depending on what you're sitting on.
If you are hiding on the ceiling, sitting will cause you to stop hiding.
If there are items on the space, you will sit on those, or coil around gold if your are polymorphed into any kind of dragon. This has no effect, so in order to sit on something else, you must remove items from the ground first. You also can't sit if you are riding, engulfed, held by or stuck to a monster, levitating, tethered to a buried iron ball or buried in the ground.
Sitting on a trap while you're trapped in it abuses wisdom, and for some traps, makes you stuck in it longer. Sitting in a spiked pit does 1 point of damage as well, with a 50% chance if you have half physical damage, and abuses strength. Sitting on a trap while not trapped in it may activate the trap.
Probably the most used feature is sitting on a throne. See that article for more information on what happens.
You can also lay eggs that are guaranteed to hatch into baby versions of your polymorphed self by sitting, if you are a female oviparous monster and there are no other objects on the square you are on. This will consume 80 nutrition, as much as eating an egg gives in NetHack. An exception are winged gargoyles - most eggs will hatch plain gargoyles.
NetHack has a bug that lets you #sit in places you cannot reach. For example, a gnome dies in a pit and you want to loot the gnome, but you escape when you try to enter the pit. Trying to #sit gives you a message about the gnome corpse being uncomfortable to sit on and you won't fall in the pit. Since NetHack 3.6.0, you can enter the pit with the > command.
You can repeatedly #sit on a magic trap to boost your charisma or uncurse items. Beware of other possible magic trap effects.
If you have just passed through a two-way magic portal, so that you are on a portal square when you arrive, you can #sit to activate the portal and return immediately. This can be useful if some particularly nasty monsters are around and you do not want to spend even two turns near them (as will often happen in SLASH'EM's Chaotic Quest). Be sure to engrave Elbereth on the portal (preferably permanently) to prevent monsters from following, unless you intend for things to follow you.