We are in chapter 4 of Maseches Avos, mishnah 20 (and according to certain divisions we are still within mishnah 15). The words of this mishnah are those of Rabbi Masya ben Charash.
Rabbi Masya ben Charash and his beis midrash in Rome:
Rabbi Masya ben Charash was a contemporary of Rabbi Akiva and lived during the period of the Hadrianic decrees. After the war ended, from the year 135 onward, when many of the leaders of the generation were forced into hiding - such as Rabban Shimon ben Gamliel and Rabbi Yehudah - he fled for his life and moved to the city of Rome. There he established a beis midrash, and he and his community had an important influence.
This may come as a surprise: Rome, after all, was the terrible nation that destroyed the Beis HaMikdash, and a second time - in crushing the Bar Kochba revolt - devastated and ruined the Land of Israel even more severely. Yet the story is more complex than that. Apart from those terrible events, and many other terrible events as well, the Romans were generally tolerant toward the Jews and even supportive of them throughout the empire; and for a considerable part of the Second Temple period - aside from its end - most of the Jews in the Roman Empire lived with extraordinary freedoms.
This is not the place to elaborate, but already in the year 139 BCE, in the middle of the Chashmonaim dynasty and in the very best times of the Second Temple period, Jewish communities flourished in the city of Rome - to such an extent that they were eventually expelled from it because they had succeeded too well. In the year 63 BCE, with the invasion of Pompey and the beginning of Roman rule over Judea, Jewish slaves were brought there, but voluntary immigrants also made their home in Rome - tens of thousands of Jews who lived there in prosperity.
In the year 14 CE, when Tiberius rose to power, more than fifty thousand Jews lived in the city of Rome itself - not in the whole empire but in the city - in thriving communities. Tiberius expelled them and they returned; afterward Claudius expelled them and they returned. The Jews attracted converts in large numbers, wielded great influence, and flourished in Rome and its surroundings and throughout the empire.
Rabbi Masya ben Charash, then, found refuge from the decrees in Judea of the mid second century precisely in Rome, and established his beis midrash there. It is worth noting that contact between the Land of Israel and Rome in those days was limited, but it certainly existed.
"Hevei makdim bishlom kol adam":
The first of the two things Rabbi Masya says is "hevei makdim bishlom kol adam" - be the first to greet every person, including even a stranger, a person who is not Jewish whom you meet in the street. A person should be the first one to extend a greeting, and this is a very important point.
It is commonly thought that the prototype for this conduct was Rabbi Yochanan ben Zakkai, the leader of the generation after the destruction of the Second Temple, who lived by it. But the Gemara itself presents it as a requirement incumbent upon every single person (Berachos 17): "A person should always... be the first to greet his brothers and his relatives and every person, and even a non-Jew in the marketplace":
"im echav v'im kerovav" - his family members and his relatives.
"v'im kol adam" - every human being.
"va'afilu im nochri bashuk" - even strangers and non-Jews whom one meets in the street.
And the purpose: "so that he will be beloved above and pleasing below" - that he be beloved in the upper worlds and in the lower worlds alike, "and accepted by his fellow creatures" - that people accept him and love him.
And of Rabban Yochanan ben Zakkai they said: "no one ever greeted him first, not even a non-Jew in the marketplace." The greatest man of his generation was so careful in this that no one ever managed to greet him first. And even if we do not always merit to be the first, it is fitting to say hello with a pleasant face to every person we meet.
Saying hello costs nothing, and this is something many people need to work on: a smile on the face and a warm reception of others. It benefits the one who says it and the one who hears it alike, and it costs nothing - a win for all sides. The very fact that the Mishnah found it necessary to command this teaches that it is not a person's natural inclination: there is a hesitation about taking the first step and opening a conversation - about welcoming the one who comes through the community's gates, about approaching the rabbi, the student, the newcomer in the shul. Perhaps he does not want to talk? Of course he does.
I saw something lovely in a shul in Chicago: at the kiddush they set out many cups, and among them one stack of red cups, and next to it a large sign: "If you are new here and you want people to say hello to you, take a red cup so we will know." It is a clear signal and an excellent system, but in truth it should never have been needed at all. It is incumbent upon each person to make a special effort to greet people, even strangers who pass by in the street, and especially on Shabbos and especially a fellow Jew. Be the first to say hello; and if not the first - be the second.
"Hevei zanav la'arayos v'al tehi rosh lashualim":
The wording must be looked at precisely: the Mishnah does not say that it is preferable to be a tail to lions rather than a head to foxes; rather it commands and says: "Hevei zanav la'arayos v'al tehi rosh lashualim" - be a tail to lions and do not be a head to foxes.
The 'lions' in the metaphor are, apparently, Torah scholars - in several places in the words of Chazal Torah scholars are called lions. Accordingly, the simple meaning is: make every effort to attach yourself to the rabbis, to the great ones and to elevated people as best you can, and be part of groups of people who are doing the right thing, people you can look up to. Their good influence will work upon you.
By contrast, do not be part of the 'foxes' - the crafty and the cunning, the low and the useless - even if you could stand there at the head.
And the reason for the command: this conduct is not a person's nature. Our nature is to want recognition and a feeling of importance; and therefore, when a group of people who are lesser than us crowns us as their head and gives us recognition, we are drawn after it. But this is a mistake, for the tail of the lion is still part of the lion.
Every person should try as best he can to be surrounded by the finest people available to him. One who looks around the room and thinks he is the smartest person there or the best of them - that is a sign that he is in the wrong room. So make the effort to be counted among the lions and among the good people and to attach yourself to them, to be part of their company; and if that means being the tail, you are still part of the lion, and all the merit stands to your credit.
In summary: in this Mishnah Rabbi Masya ben Charash, who found refuge from Hadrian's decrees in his beis midrash in Rome, teaches us two fundamentals in a person's conduct: "Hevei makdim bishlom kol adam" - to take the initiative and be the first to greet every human being, even a non-Jew in the marketplace, in the way of Rabban Yochanan ben Zakkai, whom no one ever greeted first; and "Hevei zanav la'arayos v'al tehi rosh lashualim" - to be surrounded by great and good people and to attach yourself to them, and not to seek authority and recognition in a company of lesser people.