on your ubuntu terminal type:
sudo nano
- it will open text editor- paste the code
press ctrl+x to save
type nameofthefile.sh and hit Enter
it will be saved in /home directory
to run it in the same terminal first type
chmod 774 nameofthefile.sh
to change permissionsthen type
sudo bash nameofthefile.sh
to run it