Note: this first step is only necessary if you are using MobileTerminal. If you logged in via SSH as root, you do not need to do this step, so skip to Step 2.
Run "su root" and provide the root password. The default password as provided by Apple is "alpine".
Here I also run "cd" only to shorten the otherwise very long prompt.
iPhone:~ mobile$ su root
Password:
iPhone:/var/mobile root# cd
iPhone:~ root#
2: Change the root Password
Run "passwd" and type in your new password twice. Please note that your keypresses will not be displayed on the terminal screen (for security).