Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-09-2008, 08:06 PM   #1
Registered: Jul 2005
Posts: 41

Rep: Reputation: 15
bash shell script "sudo -

Hi there I got a question about the bash shell script and sudo.

Normally I would google for help, but then I dont know what am i supposed to search for.

e.g. i am under root user
sudo -u oracle sqlplus user/pass <createuser.sql

sudo -u oracle sqlplus user/pass <dosomething.sql

mkdir ./temp

my understanding is the sudo -u user let us execute a command on a specific user.

For my above scenario,

is there a way to modify my bash file so that upon the oracle user finishing its "sqlplus user/pass <createuser.sql" statement,

my bash file will continue to execute?

Old 05-09-2008, 08:17 PM   #2
Senior Member
Registered: Feb 2007
Location: My HDD...
Distribution: WinXP for designing, Linux for life.
Posts: 2,329
Blog Entries: 1

Rep: Reputation: 47
I'm assuming you aren't using some type of Ubuntu...

If you are running a shell script as the root user you will not need to put "sudo" in the script. Ubuntu disables the root account by default, restricting major changes to the local user's password.

The command "su" will prompt for the root password, and will allow you to do *most things. The command "su -" will actually switch you to the root account. And, assuming you have more than one user account, the command "su - whateverusername" will "log you in" (in the given shell) as that user.
Old 05-09-2008, 10:42 PM   #3
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey there,

Also make sure that (even though it's not necessary in certain circumstances) you make the sudo rule NOPASSWD: so that if, say, the oracle user has it in their .profile, it won't hang waiting on an interactive password entry!

Best wishes,



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
Shell script sudo without password prompt under Darwin? lhouk Other *NIX 3 02-08-2008 12:16 PM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 08:42 AM
ubuntu - running sudo shell script from php mitilma Linux - Security 3 06-14-2007 02:52 AM
allow sudo for www user to run root shell script cccc *BSD 12 07-23-2005 04:48 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:34 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration