An undisturbed photon will always move in a straight line. But if something gets in its way, the photon will either be scattered or absorbed and re-emitted. Each fate can result in the photon being cast in a different direction with a different energy. Given the density of matter in the Sun, the photon’s average straight-line trip in the Sun lasts for less than one thirty-billionth of a second (a thirtieth of a nanosecond)—just long enough for the photon to travel about one centimeter before interacting with a free electron or an atom.

With 70 billion centimeters from the Sun’s center to its surface, the total linear distance traveled would span about 5,000 light-years. At the speed of light, a photon would, of course, take 5,000 years to journey that far.

However, if a photon had a clear path from the Sun’s center to its surface, its journey would instead last all of 2.3 seconds.

Death by Black Hole and Other Cosmic Quandaries by Neil deGrasse Tyson