Let be the finite field with elements, where p is an odd prime and m is a positive integer. For a positive integer t, let and let be the trace function from onto . In this paper, let we define a p-ary linear code by We shall present the complete weight enumerators of the linear codes and give several classes of linear codes with a few weights. This paper generalizes the results of Yang and Yao (Des Codes Cryptogr, 2016).