There are ibus and fcitx almost people used for chinese pinyin input method.
- ibus which I think more quick introduced first
You can avoid install ibus if there has been installed on ubuntusudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4
change to ibus input programim-config -s ibus
install google pinyinsudo apt-get install ibus-pinyin
Restart the computer and conduct the below commandsudo ibus-setup
setup window will occurs, then add the chinese-pinyin will be ok