Insights in Rashi - Moshe and Yehoshua.
Mishpatim (Exodus 21-24 )
And Moshe stood up with Yehoshua, his servant, and Moshe ascended to the Mountain of God. (Shemot 24:13)
And Moshe stood up with Yehoshua: "I don't know what the function of Yehoshua is here: I say that he was the student accompanying his teacher until the place of the boundaries on the mountain, because he wasn't allowed to go further. And from there, Moshe ascended alone to the Mountain of God and Yehoshua set up his tent and stayed there for the whole forty days..." (Rashi, Shemot 24:13)
In the end of Mishpatim, Rashi reveals Yehoshua's great loyalty to his teacher, Moshe. He faithfully followed Moshe as far as he could, and when he could go no further, he isolated himself away from the nation in order to be as close to Moshe as possible. This dedication to his Rebbe and desire to spend every available moment in his company was the key to Yehoshua's greatness and eventual accession to the leadership of the Jewish nation.
The Rabbis enumerate many instances of Yehoshua showing his submission to his Rebbe. The Torah describes him as Moshe's attendant; (1) he would take towels to the bathhouse for him and would rise early every morning and select the largest of the manna and give it to Moshe.(2) In Torah learning he dedicated himself to understanding and emulating his teacher to the extent that the Jerusalem Talmud says that even in matters that he had not heard from Moshe, his own reasoning corresponded with what had been told to Moshe at Sinai.(3) Yehoshua was completely content with his role as second to Moshe, he did not feel as though it belittled his own standing, rather it elevated him to incredible heights.
Indeed the Midrash tells us that it was the merit of Yehoshua's submission to Moshe that caused him to become the leader of the Jewish nation: "God told Moshe, Yehoshua constantly served you and accorded you much honor. He came early to your house of assembly to arrange the benches and spread the mats. Since he served you with all his might, he is worthy of serving Israel." (4) Yehoshua happily accepted his role as 'number two' and consequently attained the ultimate position of leader of the Jewish nation.
One of the lessons to be derived from Yehoshua is the importance of clinging to Torah scholars. Yehoshua's example teaches us that it is not sufficient to merely ask the Rav a lot of questions rather one must cleave to him at every available moment, thereby using every moment as an opportunity to learn first-hand how a Torah scholar conducts himself.
1. Behaa'aloscha, 11:28.
2. Batei Midrashos, 234.
3. Yerushalmi, Peah, 1:1.
4. Bamidbar Rabbah, 11:28.