There is a red wire in the ceiling junction box. What does it do? Where would I hook the ground wiring from the fan

exhaust-fanlight-fixture

I am installing a vent fan in my basement bathroom. I am ready to wire it in, but I do not know what this red wire is for:

enter image description here

https://imgur.com/a/uSnRLuv

I also am not sure what the green ground wire in the fan is supposed to be attached to. I saw on some other posts here that you shouldn't wire the green ground to the white because you can shock yourself when you turn on the switch. That was in reference to a ceiling fan, so I would imagine an exhaust fan would be the same.

I appreciate any clarification :).

Edit: added some more pictures for clarification.

Best Answer

Grounds are super simple. They are all green, green/yellow or bare. They should all be connected to each other and to nothing else. Ever. EVER.

This is one of the few really hard-and-fast rules in electrical, and it applies everywhere in the world except some old Soviet installations.

If you have connected all the grounds that are present, that is all you can do.

If a site doesn't have any grounds, you can ignore it, or if code requires, you can retrofit a ground wire. This process has rules which are, again, unique to grounds (far more permissive, actually).