We propose a private information retrieval (PIR) protocol for distributed storage systems (DSSs) with noncolluding nodes where data is stored using an arbitrary linear code. An expression for the PIR rate, i.e., the ratio of the amount of retrieved stored data per unit of downloaded data, is derived, and a necessary and a sufficient condition for codes to achieve the PIR capacity are given. The necessary condition is based on the generalized Hamming weights of the storage code, while the sufficient condition is based on code automorphisms. We show that cyclic codes and Reed-Muller codes satisfy the sufficient condition and are thus PIR capacity-achieving.