The Sun and sun-like stars commonly host the multi-MK corona and 10,000-K chromosphere. Understanding their heating mechanisms is of great importance in solar and stellar physics because these hot gases produce X-rays and extreme ultraviolet (UV) radiations that affect the erosion and chemical reactions of (exo)planetary atmospheres, which in turn can influence their climate and habitable conditions. In this presentation, we discuss two possible approaches to characterize and derive stellar magnetic and thermal conditions through Sun-as-a-star observations. First, by analyzing the sequences of solar images of sunspot transit events, we derived the means to understand the magnetic and thermal environments of starspots that cannot be spatially resolved. Specifically, we found that the surface magnetic flux can be estimated from the chromospheric light curves and that the thermal structure around the starspots can be inferred from the sub-MK UV light curves. Next, we examined the power-law relationships between the surface magnetic flux and the luminosities of various emission lines with the formation temperatures from the corona to the chromosphere, and found that the solar scaling laws can be extended to G-type dwarfs with ages from 50 Myr to 4.5 Gyr in any temperature ranges. This suggests that the heating of the atmospheres via magnetic fields is universal to the Sun and sun-like stars, regardless of age or activity.