macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

WiFi set up from terminal

Mon Apr 29, 2013 8:18 pm

Hello, can anyone here guide me through wifi configuration from the terminal? I don't have an
X session avail as accessing remotely.
Anyway, how would I do it via "Desktop" environment? I may be able to talk my wife through it ;)

Help appreciated.

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: WiFi set up from terminal

Tue Apr 30, 2013 12:06 pm

unashamed bump.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: WiFi set up from terminal

Tue Apr 30, 2013 12:44 pm

Your post seems inconsistent. My first reaction upon reading it was that you wanted to know how to get WiFi up and running via Linux commands (as opposed to clicking in a GUI). That, I can help you with (and will, should you further request it). But then you say something about "doing it from a Desktop enviroinment", which seems to contradict the previous assumption.

Please clarify.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: WiFi set up from terminal

Tue Apr 30, 2013 1:05 pm

Thanks for your reply. Sorry to be so confusing... Your first assumption is correct, I want to set up wifi
from the command line (as a first preference). I am only able to access to RasPi remotely. I gave the second option as a "last resort". My wife is on site with the RasPi and I 'may' have been able to
talk her through the desktop procedure.

Back to the first option please, Linux command line.
Thanks in anticipation.

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: WiFi set up from terminal

Tue Apr 30, 2013 2:25 pm

I would connected it to the TV/monitor and set it up with X. Once it's done, it's done - it's a one-off operation.
However the reason for that as my preference is that I have the option to do so - and the other thing is that I don't know HOW to do it from command line :roll:

Sorry that wasn't very helpful.

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: WiFi set up from terminal

Tue Apr 30, 2013 2:57 pm

You obviously haven’t read my post correctly, I am accessing the RasPi REMOTELY, ie, other
side of the world, kind of difficult for me to do via X. :lol:

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: WiFi set up from terminal

Tue Apr 30, 2013 3:03 pm

Not at all - I understand fully. Let me re-phrase it - get your wife to connect it up to the TV ;)

T.
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1665
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: WiFi set up from terminal

Tue Apr 30, 2013 3:09 pm

You can try this post;
http://www.raspberrypi.org/phpBB3/viewt ... 26&t=40164

You can also install a VNC server on the Pi and then use your SSH client to tunnel the connection.
That would give you desktop access too.

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: WiFi set up from terminal

Tue Apr 30, 2013 3:23 pm

Yes, I am aware of that, I don't want to do that, I prefer to use the command line. You learn more that way. I think i'll wait for the first person to reply to come back.
Thanks anyway.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: WiFi set up from terminal

Tue Apr 30, 2013 3:56 pm

macey wrote:Yes, I am aware of that, I don't want to do that, I prefer to use the command line. You learn more that way. I think i'll wait for the first person to reply to come back.
Thanks anyway.
Thanks. I'm glad you said that - that you really do want to learn stuff, not just "git'er done".

It's amazing how much, even on a board dedicated to an educational product (the Pi), there still seems to be a preponderance of that all-too-common-on-support-boards "git'er done" mentality.

But, just to be clear, if the goal is just to "git'er done", then, yes, talking your wife through using the GUI is probably the fastest way to get her surfing.

Anyway, here's how I do it (on a per-boot basis - i.e., in /etc/rc.local):

1) killall -v wpa_supplicant dhclient || :
2) ifconfig wlan0 up
3) wpa_supplicant -B -i wlan0 -c wpa_supplicant.conf
4) dhclient wlan0

where "wpa_supplicant.conf" is like:

network={
ssid="yourWifiNetwork"
psk="yourPassword"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}

Now, that's the easy part. The hard part is that if you do this, you will get messed up by the "built-in" networking. Because behind the scenes, the great and powerful Oz is running these same programs, trying to do everything for you. It's like having both an automatic and a standard transmission on the same car. Chaos ensues.

So, you need to turn off the built-in stuff, and that's not made easy for you. But again, it is a learning experience. I can't remember right now how I did it - it was something like "services networking disable" or something like that.

And then I found that once you've done that (and rebooted), you don't have the "lo" (loopback) device, since that is enabled by the "built-in" networking. So, I added:

ifconfig lo 127.0.0.1

to the end of /etc/rc.local.

P.S. Curiously, the loopback device is not really needed much anymore - except for one thing. X needs it for TCP/IP listening (which nobody really uses much anymore either). So, for the most part, you won't miss it. As it happens, I had been running for quite some time without it, until I was trying to get X to work with TCP/IP and kept banging my head against the wall wondering why it wasn't working - until I figured out that I didn't have the loopback device.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: WiFi set up from terminal

Tue Apr 30, 2013 4:04 pm

or you can put in these few lines into /etc/network/interfaces

Code: Select all

auto wlan0
iface wlan0 inet dhcp
wpa-ssid YOURSSIDHERE
wpa-psk YOURPASSPHRASE HERE
These lines are also listed in the post that davespice linked.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

Return to “Beginners”