The Shulchan Aruch · Yoreh De'ah
יורה דעה רמ״הYoreh De'ah 245
Siman 245 of 402 in Yoreh De'ah — 22 se'ifim
הלכות מלמדיםTeachers· siman 245
Se’if 1א׳
מִצְוַת עֲשֵׂה עַל הָאִישׁ לְלַמֵּד אֶת בְּנוֹ תּוֹרָה. וְאִם לֹא לִמְּדוֹ אָבִיו, חַיָּב לִלְמֹד לְעַצְמוֹ. וְע"ל סי' רמ"ו סָעִיף ו'.
The Laws of Teaching Children Torah. It is a positive commandment for a man to teach his son Torah. And if his father did not teach him, he is obligated to teach himself. And see Siman 246:6.
Se’if 2ב׳
הָיָה הוּא צָרִיךְ לִלְמֹד, וְיֵשׁ לוֹ בֶּן לְלַמֵּד, וְאֵין יָדוֹ מַשֶּׂגֶת לְהַסְפִּיק לִשְׁנֵיהֶם, אִם שְׁנֵיהֶם שָׁוִים הוּא קוֹדֵם לִבְנוֹ. וְאִם בְּנוֹ נָבוֹן וּמַשְׂכִּיל מַה שֶּׁיִּלְמַד יוֹתֵר מִמֶּנּוּ, בְּנוֹ קוֹדְמוֹ. וְאַף עַל פִּי כֵן לֹא יִבָּטֵל הוּא.
If he himself needs to learn, and he has a son to teach, and he does not have the means to provide for both of them, if they are equal [in intellect], he precedes his son. But if his son is perceptive and comprehends what he learns more than he [the father] does, his son precedes him. Nevertheless, he should not neglect [his own studies]
Se’if 3ג׳
כְּשֵׁם שֶׁמִּצְוָה לְלַמֵּד אֶת בְּנוֹ, כָּךְ מִצְוָה לְלַמֵּד אֶת בֶּן בְּנוֹ, שֶׁנֶּאֱמַר: וְהוֹדַעְתָּם לְבָנֶיךָ וְלִבְנֵי בָנֶיךָ (דְּבָרִים ד, ט). וְלֹא לְבֶן בְּנוֹ בִּלְבַד, אֶלָּא מִצְוָה עַל כָּל חָכָם מִיִּשְׂרָאֵל לְלַמֵּד לַתַּלְמִידִים, שֶׁגַּם הֵם נִקְרָאִים בָּנִים, אֶלָּא שֶׁמִּצְוָה לְהַקְדִּים בְּנוֹ לְבֶן בְּנוֹ, וּבֶן בְּנוֹ לְבֶן חֲבֵרוֹ.
Just as it is a mitzvah to teach one's son, so too it is a mitzvah to teach one's grandson, as it is stated: "And you shall make them known to your children and your children's children" (Devarim 4:9). And not only one's grandson, but it is a mitzvah upon every wise man in Israel to teach students, for they too are called "children." However, it is a mitzvah to give precedence to one's son over one's grandson, and one's grandson over the son of one's fellow.
Shulchan Aruch, Yoreh De'ah — Torat Emet 357 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0