Visit Jeremy's Blog.
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 12-08-2005, 10:05 AM   #1
Registered: Dec 2005
Posts: 37

Rep: Reputation: 15
Starting scripts as non-root


I've installed madwifi and my wireless card works without flaws. I start the connection with:

wlanconfig ath0 create wlandev wifi0 wlanmode sta
ifconfig ath0 up
iwconfig ath0 key MY_KEY
iwconfig ath0 essid MY_NETWORK
dhclient ath0

I've put this in a script so that it starts when i enter KDE (put in the ~/.kde/Autostart folder), but it only works when I'm logged in as root. When i try to run the commands as a non-root user, my computer tells me:

wlanconfig: ioctl: Operation not permitted
./Script: line 3: ifconfig: command not found
./Script: line 4: iwconfig: command not found
./Script: line 5: iwconfig: command not found
./Script: line 6: dhclient: command not found

Q: Where can I place the script so that it runs without me having to log in as root and execute it? I tried to just place it in /etc/rc.d/ and added the line /etc/rc.d/Script to rc.local, but it doesn't work.

I'm running:
Slackware 10.1 (full install)
MadWifi (madwifi-ng-r1350.2005.1207)
NetGear wg511T

Thanks for your help
Old 12-08-2005, 10:10 AM   #2
Senior Member
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
You'd need to look at setting up sudo, a good article to read is . This allows you to specify certain scripts or applications that normal users can run, but with root permissions. As normal users can't access tools like ifconfig or iwconfig, this is why your script fails to run.

That said, adding it rc.local should enable it at boot - if you type "dmesg" from the command line and look at the last few lines, it should detail what is was trying to do and why the script wasn't able to execute at boot.
Old 12-08-2005, 02:29 PM   #3
Registered: Dec 2005
Posts: 37

Original Poster
Rep: Reputation: 15
SUDO question

Thanks, I think sudo is the answer to my problem, but I don't seem to get it to work. Here is my sudoers file:

# sudoers file.
# This file MUST be edited with the 'visudo' command as root.
# See the sudoers man page for the details on how to write a sudoers file.
# Host alias specification
# User alias specification
# Cmnd alias specification
alex darkstar=NOPASSWD:/sbin/ifconfig,/sbin/iwconfig,/sbin/dhclient,/usr/local/bin/wlanconfig
# Defaults specification
# Runas alias specification
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
%user localhost=/sbin/shutdown -h now

As I understand, this (should?) makes it possible for user alex to run ifconfig, iwconfig, dhclient and wlanconfig as root without having to use any password. The computer, however, tells me:

wlanconfig: ioctl: Invalid argument
sudo: ifconfig: command not found
sudo: iwconfig: command not found
sudo: iwconfig: command not found
sudo: dhclient: command not found

I've read the manpages but I'm having a hard time seeing what I've done wrong. I'm new to sudo (and Linux for that matter), so I'm probably missing out on something simple, because I assume it shouldn't have to take a guru to make a wireless networkcard available to other users than root?

Thankful for any help

Last edited by rabalder321; 12-08-2005 at 02:31 PM.
Old 12-08-2005, 03:13 PM   #4
Senior Member
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
You should have something like:
Cmnd_Alias NETWORK = /sbin/ifconfig,/sbin/iwconfig,/sbin/dhclient,/usr/local/bin/wlanconfig
And you would then call each command with "sudo iwconfig". Alternatively, and more ideally, you should simply give the path to your script such "Cmnd_Alias NETWORK = /path/to/" so that the whole script is ran with the right permissions as in "sudo /path/to/"
Old 12-09-2005, 09:08 AM   #5
Registered: Dec 2005
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks a lot, it's all solved now!


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
Starting scripts at startup in NIS clients thinkgeek Linux - Networking 1 07-07-2005 07:53 AM
X not starting on boot (init scripts) cootetom Mandriva 11 05-05-2004 09:37 AM
Some rc.d Scripts Not Starting granatica Linux - Software 4 03-17-2004 06:07 PM
Scripts for Starting Window Manager jasonmiu Red Hat 0 09-19-2003 02:03 PM
sysV vs bsd starting scripts sqn Linux From Scratch 3 06-16-2002 02:42 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:41 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