The Prophet ﷺ said, "The young should greet the old, the one passing by should greet the one sitting, and the smaller group should greet the larger group."
عن النبي ﷺ قال: يسلم الصغير على الكبير، والمار على القاعد، والقليل على الكثير.
Bukhari related it in the chapter on seeking permission (6231), from Muhammad bin Muqatil Abu Hasan, who said, Abdullah informed us, Mamar informed us, from Hammam bin Munabbih, from Abu Hurairah, and he mentioned it.