Google doesn't earn money from Android OS. Google makes money from google play store. And the infrastructure such as Firebase (database for android) and App engine. Also google earns money from the developer registration fee which is one time 25$. I paid that to gain access to host my app on google play under my company name. I may register personal account and that will also require 25$. Infrastructure platform for Android is not cheap and as most of the apps make use of the firebase or other database servers for better quality service, google ends up making a lot of money.
Linux is free. Nobody pays for Linux. It's in the license named as GNU General Public License. There are some kernel forks in it that have other licenses but all are free with different structure.
There are no licensing cost to it. You can create your own linux distribution or OS for free of cost. Linux kernel is contributed by programmers and developers for free. Only linux foundation members get paid for managing the patent issues, documentation and seminars or PR stuff. Otherwise Linux kernel is available as free of cost and anyone can fork from it. Depending on how the forks are making derivatives the license applies accordingly. License for Linux only matters if the company wishes to keep the additional modification hidden. Which in case of android or any other Linux derivative doesn't apply as there are not many OS that derives from Linux and remain hidden.
Lot of things on android platform are free in literally free sense. For example apps that we get packaged in the OS like calendar, FM radio, SMS app etc. All those are contributed by non paying developers. Just like Linux and BSD operating system, the money is made from the infrastructure access and hosting.