I need to write a single script in which I have to execute a certain set of commands as oracle user, then become root user and execute a few commands and and then back to oracle user. All of this has to be done in a single script...how to do this?To be more specific, I am basically automating OTD(Oracle Traffic Director) installation and configuration for which I have been asked to write a shell script. All the steps in its installation are done as oracle user, but these two commands:chown root portbindchmod 4750 portbind have to be executed after becoming a root user, the further steps of automation have to be done as oracle user again. So I need a way to switch users(root and oracle) in my script. 
I need to write a single script in which I have to execute a certain set of commands as oracle user and some as root,how to do it?
sudo
Execute the script as root and for the commands that you need to be executed as another user, use the -u switch of sudo. Consult the manual page of sudo with man sudo.# sudo -u user echo testtest