  Recently, linear codes with a few weights were widely investigated due to
their applications in secret sharing schemes and authentication schemes. In
this letter, we present a class of $q$-ary linear codes derived from
irreducible cyclic codes with $q$ a prime power. We use Gauss sums to represent
its Hamming weights and obtain the bounds of its minimum Hamming distance. In
some cases, we explicitly determine its weight distributions which generalize
some known results. It is quite interesting that many new codes obtained in
this letter are optimal according to some bounds on linear codes.
