To set up pinyin input, you’ll need to follow these instructions first: Input Chinese, Japanese and Korean in Ubuntu.
If you’re making your own study materials (which I’d recommend you do), being able to type Mandarin pinyin with tone marks is very helpful. Pīnyīn looks a lot nicer than pin1yin1, and conveys the tone more intuitively.
Once you’ve got SCIM installed, it’s pretty easy to enable input of pinyin with tone marks.
The input method you want is called “zh-pinyin”. Go to System → Preferences →SCIM Input Method Setup, and then the Global Settings tab. Scroll down to Chinese (Simplified) and expand it.
Click Apply (you may also need to restart SCIM) and then activate SCIM (ctrl + space). You can now select zh-pinyin from the input methods dropdown menu.
Typing pinyin with tonemarks
This is very intuitive. To get a tonemark, type the pinyin syllable you want, then just press the number of the tone. So for pīn, type “pin” then “1”. Easy! To get a neutral tone (ie no tonemark) just press the right arrow key.