Since the paper by Hammons e.a. [1], various authors have shown an enormous interest in linear codes over the ring ℤ4. A special weight function on ℤ4 was introduced and by means of the so called Gray map ϕ : ℤ4→ℤ2 2 a relation was established between linear codes over ℤ4 and certain interesting non-linear binary codes of even length. Here, we shall generalize these notions to codes over ℤ p2 where p is an arbitrary prime. To this end, a new weight function will be proposed for ℤ p2 . Further, properties of linear codes over ℤ p2 will be discussed and the mapping ϕ will be generalized to an isometry between ℤ p2 and ℤ p p , resp. between ℤ p2 n and ℤ p pn . Some properties of Galois rings over ℤ q will be described and two dual families of linear codes of length n = p m − 1, gcd(m, p) = 1, over ℤ q will be constructed. Taking q = p 2, their images under the new mapping can be viewed as a generalization of the binary Kerdock and the Preparata code, although they miss some of their nice combinatorial properties.