Shulchan Aruch/Yoreh Deah/291
Seif 1: An individual’s mezuzah is [required to be] checked twice [every] seven years. But a public/community mezuzah is [only required to be] checked twice [every] fifty years.
Seif 2: [If] one rents a house from one’s friend, the renter/lessee must affix a mezuzah [to the house] and repair the place where it is affixed. (And even if the person rented the house under the [mistaken] assumption that it [already] had a mezuzah, it is not an invalid lease.)
And when the renter/lessee leaves [when the lease expires], she/he does not take [the mezuzah] in her/his hand [i.e., the lessee leaves behind the mezuzah]. (And if the lessee is stingy with regard to her/his finances, the second person [i.e., the lessor] is required to reimburse him/her [for the value of the mezuzah].)
And if one rented the house from an idolater, or rented the house to an idolater, one takes [the mezuzah] and leaves [with it when the lease expires].
Rama: And an idolater who asks that one give her/him a mezuzah [because he/she] wants to affix it to his/her doorway, it is forbidden to give a mezuzah to the idolater. But it seems to me that in a case where there is reason to be concerned that in that particular place there will be hostility [towards Jews if one does not give the mezuzah to the idol worshiper], and that the idol worshiper will treat Jews poorly because of this, it is permissible [to give a mezuzah to an idol worshipper].
Seif 3: All are obligated in [the performance of the mitzvah of] mezuzah, even women and slaves. And we teach children to perform [the mitzvah of] mezuzah for their doorways.