Most countries have established some sort of Rescue Coordination Centre responsible for search and rescue operations in case an aircraft or ship goes missing. The RCC typically has direct access to various SAR resources such as helicopters. They can also call in local emergency teams (police, firefighting, ambulances etc.)
How exactly the RCC is notified of ...
Modern airliners use EGPWS (Enhanced Ground Proximity Warning System) with two sources of information for triggering warnings: the radio altimeter and a global terrain database. See e.g. the Boeing 737:
Ground Proximity Alerts
The GPWS provides alerts for potentially hazardous flight conditions involving
imminent impact with the ground.