Linux - NewbieThis 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!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Please excuse my ignorance as I'm rather new to Linux. After being frustrated with M$ for so long I made the decision to give the whole Linux thing a try. So far I'm loving just about everything about it and I'm learning quite a bit. My major headache so far is coming from, what else, wireless networking. I've pretty much given up on using it at home since I use WPA there and can't for the life of me get it to work with Linux. (using ndiswrapper with a broadcom chipset). I've made the attempt at using wpa_supplicant, followed multiple how-tos but just can't seem to make it work. Currently I'm attempting to write a shell script to set up my wireless configuration while at work. Everytime I reboot I need to run a few commands in the shell to get the connection up and running. I wrote a nice simple script (or so I thought) which is:
Now my problem is that I apparently need to run this with root privileges because I get this error when running it:
david@linux:~> mallnet
rm: remove write-protected regular file `/var/run/dhcpcd-wlan0.pid'? y
rm: cannot remove `/var/run/dhcpcd-wlan0.pid': Permission denied
/home/david/bin/mallnet: line 5: iwconfig: command not found
/home/david/bin/mallnet: line 6: iwconfig: command not found
/home/david/bin/mallnet: line 7: dhcpcd: command not found
I can go into the shell, su and type each line by itself, but being that I come from XP where it requires about 10 seconds to connect to any wireless network, I really would like to just get it working as a script. I know is must be something really simple I'm missing, but then again I've been using Linux for a total of about 2 days, so everything that should be simple isn't quite so.
You'll need to run this script as root, not your user account. Also, it's a good idea to put the full path of shell commands into scripts, in this case iwconfig is probably /sbin/iwconfig or /usr/sbin/iwconfig.
First add the parameter -f to rm so that it doesn't prompt you to delete the pid file.
Next, put your script somewhere global and do:
chmod +s mallnet
which will suid root it (i.e. nomatter who runs it, it will run as root. There are a few security implications, but nothing major). If you have an rc.local file (I use slack which is different to the other distros as it uses BSD rather than SysV init scripts) then add a line to run your script automatically.
Once again, please excuse my ignorance if I've done something incorrectly.
Created a new script in /usr/local/bin called mallnet, using same text from previous script except adding the -f after rm in the first line. While still root chmod +s mallnet. Switch to my user account and attempt to run script and get the above error.
The kernel will not honor the SETUID bit on shell scripts (SETUID shell scripts actually have major security issues, such as being vulnerable to PATH resets, etc.). Try running it as root and see if it doesn't work. You can also use sudo to run it with root priviliges.
Now I need to give "david" root privileges to run just that script. Added the following line to sudoers
%users david= NOPASSWD: /usr/local/bin/mallnet
and
alias mallnet='sudo /usr/local/bin/mallnet'
to my user .profile
Now I seem to have somehow taken a step backwards
david@linux:~> mallnet
rm: cannot remove `/var/run/dhcpcd-wlan0.pid': Permission denied
/usr/local/bin/mallnet: line 5: iwconfig: command not found
/usr/local/bin/mallnet: line 6: iwconfig: command not found
/usr/local/bin/mallnet: line 7: dhcpcd: command not found
david@linux:~>
If I can get this right I'll be happy for a while......until I try for WPA again....
OK, a different approach. Find the local startup script...on slackware it's called rc.local. Red Hat and the others use a different approach, but there's still a start up script for local settings somewhere. Find it and add the lines from your mallnet script to that. The start up script will run as root so there won't be the permissions problems.
Thanks much for the tip. After inserting my lines into the boot.local script I now have access on reboot. Perhaps I'll be back with more questions when I attempt WPA on my home network. Any tips or good tutorials you can suggest for WPA setup. I'm using Suse 9.2 with ndiswrapper on a Broadcom (oh joy) internal wireless card. Have wpa_supplicant installed but it remains a mystery how to get the darn thing to work properly.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.