Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-28-2008, 01:44 PM   #1
Registered: Jan 2004
Distribution: OpenSUSE 42.1 Server
Posts: 124

Rep: Reputation: 15
How do I use sudo in a script without asking for password?

I've written a small script that creates a network bridge for a virtual machine (vbox), but each line requires root access, ie sudo, I've added my user name to the sudoers file using visudo:

user ALL=(ALL) ALL

and I added my user group also:

%group ALL=(ALL) ALL

rebooted, and still, each line in the script shows a permission denied:


# Check if interface exists, if so delete it

if [ -z "vbox0" ]; then
VBoxDeleteIF vbox0

# Create virtual connection br0

brctl addbr br0

# Clear eth0 setting

ifconfig eth0

# Create bridge

brctl addif br0 eth0

# Change etho setting to br0

dhclient br0

# Create virtual vbox host

VBoxAddIF vbox0 <user> br0
I even set the execute bit for the script.

I would like to run the script without asking for a password for the script and for each line.

When I either power down or reboot, the br0 connection is lost and I have to manually remove vbox0 and re-create br0, is there a way to make br0 permanent? or have the system run the above script at start up, I'm using Ubuntu (Hardy).

Last edited by Usalabs; 08-28-2008 at 01:59 PM.
Old 08-28-2008, 01:59 PM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
It's in the man page but it would look something like this:



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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
No password for sudo? orange400 Linux - Software 9 03-18-2012 10:08 AM
sudo password...? yubimusubi Linux - General 15 09-04-2009 12:08 AM
Shell script sudo without password prompt under Darwin? lhouk Other *NIX 3 02-08-2008 11:16 AM
Running a script as root with sudo without entering the user password kloss Linux - General 8 10-10-2005 11:39 AM
make sudo ask for a password andy753421 Linux - Security 1 01-13-2005 07:32 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:19 AM.

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