-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
564 lines (373 loc) · 36.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A fast way to setup Raspberry Pi with Raspbian">
<meta name="author" content="Krisjanis Rijnieks">
<title>Raspberry Pi ASAP Setup Guide</title>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/main.css" rel="stylesheet" media="all">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Choose your OS</a>
</div>
<div class="collapse navbar-collapse">
<ul id="os-nav" class="nav navbar-nav">
<li class="mac-nav" ><a href="#">Mac</a></li>
<li class="win-nav active"><a href="#">Win</a></li>
<li class="linux-nav" ><a href="#">Linux</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
<ul class="dropdown-menu" id="affix"><!-- autopopulis --></ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<h1>Raspberry Pi ASAP Setup Guide</h1>
<p class="lead">A fast way to setup Raspberry Pi with Raspbian. This guide is a combination of information found on the internet and experience. Feel free to contribute via <a href="https://github.com/kr15h/RPi-Setup">GitHub</a>.</p>
<!--_______________ SECTION 1 _______________-->
<h2>1. Prepare yourself</h2>
<h3>Hardware</h3>
<ul id="hardware-list">
<li><b>Raspberry Pi model B.</b> <span class="lesser">We need an ethernet port, and the model A doesn't have one.</span></li>
<li><b>A computer.</b> <span class="lesser">Linux, Mac and Windows are all fine.</span></li>
<li><b>High speed SD card.</b> <span class="lesser">This is were we will install the Operating system for the Pi. Try to find a proper SD card for the job. It should be at least with 4 GB capacity. Class 4 to 10 have been working allright for me so far. It is better to choose one with a higher class number. There is a list of SD cards that have been tested with the Raspberry Pi <a href="http://elinux.org/RPi_SD_cards">here</a>.</span></li>
<li><b>SD card port or external reader.</b> <span class="lesser">You need to be able to read / write on the SD card with your computer.</span></li>
<li><b>Power adapter for Raspberry Pi.</b> <span class="lesser">5V, 1–2A, most phone chargers with a <i>micro USB type B</i> plug are fine.</span></li>
<li><b>Network cable.</b> <span class="lesser">Cat 6 or 5 ethernet cable, basically cables you have at home should be fine.</span></li>
<li><b>Ethernet port or USB adapter.</b> <span class="lesser">You need to be able to connect your laptop to the raspberry Pi via ethernet.</span></li>
</ul>
<h3>Software</h3>
<ul>
<li>
<h4>SSH client</h4>
<p>We will be using SSH a lot to communicate with the Pi form our laptop. SSH (Secure SHell) is a secure network protocol that allows to control other computers over network. <span class="mac linux">There is no problem with a SSH client on Mac or Linux - Terminal can handle SSH without any issues.</span><span class="win">If you are using Windows, download <a href="http://www.putty.org">Putty</a> for using it as your SSH client. <a href="http://mobaxterm.mobatek.net" target="_blank">MobaXterm</a> is also a good choice.</span></p>
</li>
<li>
<h4>SCP client</h4>
<p>We will need to upload and download files to and from the Raspberry Pi. For this, we will use SCP (Secure CoPy or Secure Copy Protocol) which is built on top of the SSH protocol and allows secure transfer of files. Download <a href="https://filezilla-project.org">FileZilla</a>. It works on Mac, Linux and Windows. <span class="win">You might consider <a href="http://winscp.net">WinSCP</a> as your weapon of choice if you are using Windows.</span></p>
</li>
<li>
<h4>Program to format the SD card</h4>
<p><span class="mac win">Download <a href="https://www.sdcard.org/downloads/formatter_4/">SDFormatter</a>. </span><span class="mac">You can use Mac Disk Utility, but SDFormatter is the recomended way.</span></p>
<span class="linux">Use <a href="http://gparted.org">GParted</a> to format your SD card to FAT32 file system.</span></p>
</li>
<li class="win">
<h4>Program to burn disk images</h4>
<p>To be able to write the Raspbian image to your SD card, download the <a href="http://sourceforge.net/projects/win32diskimager/" target="_blank">Win32 Disk Imager</a>.</p>
</li>
</ul>
<h3>Know-how</h3>
<ul>
<li>
<h4>Shell / command-line interpreter</h4>
<p>Basic knowledge of shell and shell scripting will be useful as we will be using the shell more than once. You can find a short list of most used shell commands on the Raspberry Pi <a href="http://kr15h.github.io/rpi-console-intro/" target="_blank">here</a>.</p>
</li>
<li>
<h4>Nano</h4>
<p>In a shell, to edit a file you need to use command line text-editing tools like <a href="http://www.tuxradar.com/content/text-editing-nano-made-easy">nano</a>.</p>
</li>
</ul>
<h3>Internet connection</h3>
Yep ... you will need it for setting-up everything, and installing software on your Pi once it is ready.
<!--_______________ SECTION 2 _______________-->
<h2>2. Installing Raspbian</h2>
<p>Raspbian is the operating system that we are going to install on the Raspberry Pi. You can download the most recent version <a href="http://downloads.raspberrypi.org/raspbian_latest">here</a> and unarchive it. The archive contains only one file - a full disk image of the Raspbian system.</p>
<h3>Formatting the SD card</h3>
<p>Before installing Raspbian, you must prepare your SD card by formatting it to the FAT32 file system. Some may say that it is useless as we will rewrite the whole file system in the next steps, but it is recomended to do it if your SD card will be used for the first time.</p>
<p class="mac win">Format the SD card to FAT32 file system using <a href="https://www.sdcard.org/downloads/formatter_4/">SDFormatter</a><span class="mac"> or Mac Disk Utility</span>.</p>
<p class="linux">Use GParted to format your SD card to FAT32 file system.</p>
<h3>Determining which device is my SD card</h3>
<div class="mac">
<p>First, eject the SD card.</p>
<p>Then, open your Terminal, and run <code>diskutil list</code> to see what devices are connected to your computer. The output in the Terminal window will look similar to the following:</p>
<pre>/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *256.1 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 255.2 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3</pre>
<p>Next - insert your SD card and run the <code>diskutil list</code> command again. You should get output similar to this:</p>
<pre>/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *256.1 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 255.2 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
<b>/dev/disk1</b>
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *3.9 GB disk1
1: DOS_FAT_32 EMPTY 3.9 GB disk1s1
</pre>
<p>As you see, there is a new device - <code>/dev/disk1</code>. On your computer, the device <code><ID></code> might be different (e.g. if you have more devices connected). <b>Try to find the ID that was not there before you inserted the SD card</b>.</p>
<h3>Burning Raspbian on the SD card</h3>
<p>In your Terminal, navigate to the directory where your Raspbian image was extracted. Mine was extracted in my home directory <code>/Users/me/</code>, so I need to run <code>cd /Users/me/</code> in the Terminal.
<p>Let's check that the image is there by running <code>ls</code>. A list of all files and sub-folders in the current directory should be printed, and you should see the extracted Raspbian image in the list. For example, mine is called <code>2014-01-07-wheezy-raspbian.img</code>. This is our <code><image></code> - we will use later in code.</p>
<p>Now let's burn this. Unmount the SD card by running the <code>diskutil unmount /dev/<ID></code> command. Of course, replace <code><ID></code> with the device ID you found in the previous step.</p>
<p>Wait till the disk is unmounted and then continue with the most important part - overwritting the contents of the SD card with the image.</p>
<blockquote class="alert-danger"><p><b>WARNING:</b> be very careful with this as you can accidentaly damage your computer's system drive if you enter the wrong device ID.</p></blockquote>
<pre>sudo dd if=<image> of=/dev/<ID> bs=1m</pre>
<p><code>if</code> is the input, <code>of</code> is the output and <code>bs</code> is the size of chunk of data that is being written to the output. Replace <code><image></code> by the name of your image file, and <code><ID></code> by the device ID of your SD card. For example, with the ID I found in previous step and the image file I have dowloaded, the command looks like the following :
<code>sudo dd if=2014-01-07-wheezy-raspbian.img of=/dev/disk1 bs=1m</code>.
But be careful, as - once again - <b class="text-danger">your device ID and image file might be different from the one here</b>.</p>
<p>Once you have double checked the ID, and image file name, execute the command. This process will take some time. So go make a coffee. And a sandwich. Don't worry if it seems to be idle. It isn't.</p>
<p>Wait till the Terminal has returned to it's normal state. You can tell that by being able to issue simple commands like <code>ls</code> and <code>cd</code>.</p>
</div><!-- /.mac -->
<div class="win">
<p>First, eject your SD card from the card reader if it is there. Open the My Computer section/directory so you can see all the storage devices connected to your computer. You should see one or more devices with letters C, D, E...</p>
<p>Insert your SD card into the SD card reader of your computer. A new device should appear. Windows also takes care of automatically assigning a drive letter for it. Memorize that letter because we are going to need it in the next step.</p>
<h3>Burning the Raspbian image</h3>
<p>On Windows you need a new program for almost every new task you want to do. It is true in this case as well. To burn the Raspbian disk image to the SD card, we have to download a program called <a href="http://sourceforge.net/projects/win32diskimager/">Win32 Disk Imager</a>. It's main purpose is just that: to burn disk image files to actual disks, USB sticks, flash drives and SD cards.</p>
<p>Download and install <a href="http://sourceforge.net/projects/win32diskimager/">Win32 Disk Imager</a>. Open it and choose the previously downloaded Raspbian image file (<code>2014-01-07-wheezy-raspbian.img</code>) as the input and the disk that represents your SD card. Press Burn and wait till the process finishes.</p>
</div><!-- /.win -->
<div class="linux">
<p>Linux instructions comming soon...</p>
</div><!-- /.linux -->
<p>Don't eject the SD card yet.</p>
<!--_______________ SECTION 3 _______________-->
<h2>3. Launching the Pi</h2>
<h3>Assigning IP addresses</h3>
<p>In order to connect for the first time, we need to give the Pi and our laptop static IP addresses that are in the same network.</p>
<p>To do that, insert the SD card in the reader, and with the file browser of your operating system browse the contents of the card. There should be a file named <code>cmdline.txt</code>. This file contains options that are passed to the Linux kernel as it boots up. Open the file in your favorite text editor. We need to add the following at the end of the existing content:</p>
<pre>ip=192.168.1.200::192.168.1.1:255.255.255.0:rpi:eth0:off</pre>
<p>The <code>cmdline.txt</code> file should look like this now:</p>
<pre>dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait ip=192.168.1.200::192.168.1.1:255.255.255.0:rpi:eth0:off</pre>
<p>Notice that there should be just a space (' ') between the existing instructions and the line just added. Save and close the file. Eject the SD card before removal.</p>
<p>We will be able to access the Pi through network with the IP address <code>192.168.1.200</code>.</p>
<p>Now let's assign our laptop a static IP.</p>
<div class="mac">
<p><span class="mac">In Mac, open network preferences, choose "ethernet", and in the "Configure IPv4" field, choose "Manually".</span>
</div>
<div class="win">
<p>Go to Network Settings and edit the TCP/IP part, set the IP address to "manual".</p>
</div>
<div class="linux">
<p>Open the network manager, select your Ethernet connection and choose "static".</p>
</div>
<p>Set the IP address to <code>192.168.1.201</code>, netmask to <code>255.255.255.0</code> and the gateway (router) address to <code>192.168.1.1</code>. You might need to disconnect from any wireless networks to make this work.</p></p>
<h3>Booting up - the first time</h3>
<p>Connect your Raspberry Pi to the computer with an ethernet cable, eject the SD card from your computer, and put it in the Pi, <b>then</b> plug-in the Pi's power adapter.</p>
<p>First, let's test that we can reach the Pi with the IP address we gave it.</p>
<div class="mac linux">
<p>For this, we will use the command <code>ping</code>. Run <code>ping 192.168.1.200</code> in the Terminal. There should be response:</p>
<pre>64 bytes from 192.168.1.200: icmp_seq=3 ttl=64 time=52.941 ms</pre>
<p>If the Raspberry Pi is not reachable:</p>
<pre>Request timeout for icmp_seq 0</pre>
</div>
<div class="win">
<p>For this, we will use the command <code>ping</code>. Run <code>ping 192.168.1.200</code> in the Command Prompt. To open the Command Prompt, go to Start and type cmd in the input text field and press enter. A window with black background and white text will open. There should be response:</p>
<pre>64 bytes from 192.168.1.200: icmp_seq=3 ttl=64 time=52.941 ms</pre>
<p>If the Raspberry Pi is not reachable:</p>
<pre>Request timeout for icmp_seq 0</pre>
</div>
<p>It means that for some reason, the Pi cannot be reached. In that case, double check your network parameters. You might also have to wait as the Pi takes about 20 seconds to boot.</p>
<p class="mac linux">Now that we made sure the Pi can be reached, let's connect to it. Run <code>ssh [email protected]</code> in the Terminal. Enter <code>raspberry</code> once prompted for a password.</p>
<p class="win">Use MobaXterm or Putty to connect to the Raspberry Pi by using IP address <code>192.168.1.200</code>, username <code>pi</code> and password <code>raspberry</code>.</p>
<p>The SSH connection just opens a remote shell on the Raspberry Pi. Basically, you can run commands, just like in your own computer's terminal, but they are executed on the Raspberry Pi.</p>
<!--_______________ SECTION 4 _______________-->
<h2>4. Sharing net with the Pi</h2>
<p>Now that your Pi is connected, we can safely share our laptop's Internet connection with it. Having an Internet connection will allow you to install new software on your Pi. For this step, don't disconnect from your Pi before being told to do so.</p>
<p>How to share the Internet connection is different with each operating system, but the baseline is the same.</p>
<p>Firstly, you must configure your laptop to share its Internet connection with the port to which the Pi is connected. The way your computer achieves this is by creating a separate network which has an Internet access.</p>
<p>Secondly, we will connect the Pi to that network, by assigning it a static IP address. Therefore, we also need to discover what is the address of that network.</p>
<h3>Enabling Internet Sharing</h3>
<div class="mac">
<p>Go to <b>System Preferences</b>, click on <b>Sharing</b>. Select the <b>Internet Sharing</b> checkbox and choose <b>Wi-Fi</b> form the <b>Share your connection from</b> dropdown. Check the <b>Ethernet</b> checkbox in the <b>To computers using</b> field.</p>
<p>Now your Mac computer automatically assigns an IP address to whatever is connected to the computer's ethernet port unless a static IP address on the connected device is set.</p>
<p>With our Pi we will need to do just that - set a static IP address, but to do that we need to know a bit more about the network that the Mac computer is setting up to share the internet connection.</p>
</div>
<div class="linux">
<p>First go to <b>system settings</b> then <b>Network</b>. In order to be able to modify the options for the Ethernet port, you need it to be active. So for example, connect your Raspberry Pi to the port, and power it up. Then, open the <b>wired</b> tab, click on <b>options</b>, then <b>IPv4 settings</b> and change the <b>Method</b> to <b>"Shared to other computers"</b>, then save the changes. That's it! Your Internet is shared.</p>
</div>
<div class="win">
<p>Click the <b>Start</b> button. Click the <b>Control Panel</b> item. In the search box type <code>adapter</code> and then, under <b>Network and Sharing Center</b>, click <b>View network connections</b>.</p>
<p>Choose the connection that you want to share, right-click it and click <b>Properties</b>.</p>
<p>Click <b>Sharing</b> tab and select the <b>Allow other network users to connect through this computer’s Internet connection</b> check box. Also, select in the drop down menu the connection to which you want to give Internet, basically the port to which your Pi is connected.</p>
<p>When you click on "Apply", you should see a message box giving you the address of the network on which the Internet is shared. Write that address down carefully.</p>
</div>
<p>Finally, shutdown the Pi by running <code>sudo shutdown -h now</code> in the Pi's terminal.</p>
<h3 class="mac linux">Determining internet sharing subnet settings</h3>
<div class="mac">
<p>Open Terminal and run <code>ifconfig</code>. A list of enabled network devices and their properties should fill the screen. Search for the one that has <code>bridge</code> in front. For some Mac's the connection is called something like <code>en0</code>.</p>
<pre>bridge100: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=23<RXCSUM,TXCSUM,TSO4>
ether 02:25:4b:3d:a7:64
inet <b>192.168.2.1</b> netmask <b>0xffffff00</b> broadcast 192.168.2.255
...</pre>
<p>We need to keep in mind the values that come after the <code>inet</code> keyword. <code>192.168.2.1</code> is the router (gateway) address and in this case it's your Mac. <code>0xffffff00</code> is the netmask that usually is expressed in numbers like this: <code>255.255.255.0</code>. To make things easier, <a href="http://www.pawprint.net/designresources/netmask-converter.php">here</a> is a table with the most common hex values for netmasks.</p>
<p>If our gateway address is <code>192.168.2.1</code>, our static IP address can vary between <code>192.168.2.2</code> to <code>192.168.2.254</code>. If your gateway address is different, leave the first 3 numbers the same and add the last one in the range from 2 to 254.</p>
</div>
<div class="linux">
<p>Open your terminal and run <code>ifconfig</code>. It will print a list of your network interfaces, including the Ethernet port on which Internet sharing is set-up. The IP address of that interface is the gateway address. This is what I get when executing the command :</p>
<pre>
<b>eth0</b> Link encap:Ethernet HWaddr 90:f6:21:7d:7a:66
inet addr:<b>10.42.0.1</b> Bcast:10.42.0.255 Mask:255.255.255.0
inet6 addr: fe80::92e6:baff:fe7d:be66/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3107 errors:0 dropped:0 overruns:0 frame:0
TX packets:4570 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:383440 (383.4 KB) TX bytes:662042 (662.0 KB)
Interrupt:43 Base address:0x6000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:7198 errors:0 dropped:0 overruns:0 frame:0
TX packets:7198 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:771195 (771.1 KB) TX bytes:771195 (771.1 KB)
wlan0 Link encap:Ethernet HWaddr 0a:99:d3:b5:1b:5b
inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::225:d3ff:febd:1b5b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:84839 errors:0 dropped:0 overruns:0 frame:0
TX packets:36230 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:45789161 (45.7 MB) TX bytes:8132670 (8.1 MB)
</pre>
<p>In my case it is easy to find the right interface, as there is only 2 physical interfaces and loopback. You can forget about loopback, this is not the interface you are looking for. In my case, interfaces are named conveniently so that it is easy to find which one is the wifi (<b>wlan0</b>), which one is the Ethernet port (<b>eth0</b>).</p>
<p>If on the other hand you cannot figure out by their name, you can run the command <code>sudo lshw -class network</code>. This will give you more detailed information about all the interfaces and help you to find the id of your Wifi and Ethernet interfaces.</p>
<p>When you have figured out which is your ethernet port, the address you are looking for is the numbers just after <b>inet addr:</b> as emphasized in the example output above.</p>
</div>
<h3>Connecting with a new static IP</h3>
<p>Now that you have discovered the address of the network to which Internet is shared, it is time to give your Pi a new static IP. Unplug your Pi, remove the SD card and in <code>cmdline.txt</code> replace the previous static IP and gateway IP by the ones you discovered in the previous step.</p>
<p>When this is done, put back the card in the Pi, power it up, and connect to it using its new address</p>
<p>Once connected, try to download a web page using the command <code>wget</code>. For example <code>wget www.cc4av.info</code> . If everything goes well, you should get an answer like the following :</p>
<pre>...lots of text...
Saving to: `index.html'
[ <=> ] 16,025 --.-K/s in 0.06s
2014-03-23 09:59:37 (263 KB/s) - `index.html' saved [16025]
</pre>
<p>If this failed, you might need to change your Pi's DNS settings. For this edit the file <code>etc/resolv.conf</code>. It should contain one line <code>nameserver 192.168.0.1</code>. Simply replace <code>192.168.0.1</code> by <code>8.8.8.8</code>. Then save the file and run <code>sudo reboot</code> to reboot the Pi. Then try again to download a web page.</p>
<h3>Connecting the Pi to a router</h3>
<p><b>If you've tried everything and cannot share Internet with your Pi</b>, but you have the possibility to connect the Pi to the router, <b>and you can connect to the admin interface of the router</b> there is still hope.</p>
<p>First you will need to restore the defaults. Remove all the network configuration that you might have added in <code>cmdlint.txt</code> or in <code>/etc/network/interfaces</code>.</p>
<p>Then connect your Pi to the router with an Ethernet wire. If everything works fine, the router should now assign an IP address to your Pi automatically. The only issue is that you don't know what that IP address is! By chance, in most of the routers, you can see a list of connected devices and their IP addresses by connecting to the admin interface of the router. So let's do this.</p>
<p>First, you need to discover the IP address of your router. It is normally your own IP address, but replacing the last number by <code>1</code>. For example if your IP address is <code>192.168.1.123</code>, your router's IP address is <code>192.168.1.1</code>. Then, open a web browser and type the IP address of the router in the address bar. You should then be prompted for a password and user name. If you don't know what they are, ask the administrator of the network. If it is your own router and you never changed the password, there should be an indication of what is the default password in your router's user manual.</b>
<p>Once you are connected to your router, dig in the menu, looking for the list of connected clients. Interfaces for all vendors are completely different. So the only advice I can give you is to look for a <b>DHCP</b> menu. When you have found the address of your Pi, you can just connect to it through SSH. The Pi should now have Internet connection.</p>
<p>If the local network of the router is not big (you have your and maybe one more device connected), it is possible to define a static IP address for your Pi right away. You just need to check your computer IP address, gateway and netmask and replace the last number of the IP address with a number between 2 and 255. Assign the IP address by editing the <code>cmdline.txt</code> file on the boot partition of your Raspberry Pi SD card.</p>
<!--_______________ SECTION 5 _______________-->
<h2>5. Configuring the Pi further</h2>
<h3>Network settings</h3>
<p>Ok, let's change the real network settings of the Raspberry Pi system the way it should be done normally with a Linux computer.</p>
<p>To do that open the <code>/etc/network/interfaces</code> file in an text editor like the commandline nano. Type <code>sudo nano /etc/network/interfaces</code> in to the <span class="mac linux">Terminal</span><span class="win">Putty</span> window after you have successfully connected to the Pi via SSH.</p>
<p><code>sudo</code> means that you are executing a command as administrator (or "root"), so basically you have every right. Be careful though, as it also means you can potentially harm your system.</p>
<p>Add the following content there:</p>
<div class="mac">
<pre>auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.2.200
netmask 255.255.255.0
gateway 192.168.2.1</pre>
</div>
<div class="win">
<pre>auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1</pre>
</div>
<div class="linux">
<pre>auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1</pre>
</div>
<p>Save the file and exit.</p>
<p>Now we have to remove the extra line from <code>cmdline.txt</code> that we added earlier. To do that, open the file in nano by running <code>sudo nano /boot/cmdline.txt</code> in <span class="mac linux">Terminal</span><span class="win">Putty</span>.</p>
<p>Delete the <code class="mac">ip=192.168.2.200::192.168.2.1:255.255.255.0:rpi:eth0:off</code><code class="win">ip=192.168.1.200::192.168.1.1:255.255.255.0:rpi:eth0:off</code><code class="linux">ip=192.168.1.200::192.168.1.1:255.255.255.0:rpi:eth0:off</code> part, then save the file and exit.</p>
<p>Now, let's reboot our Pi by using the <code>sudo reboot</code> command.</p>
<p>If all is well, in approximately 15 to 30 seconds you will be able to connect to the Pi via SSH by using IP address <code class="mac">192.168.2.200</code><code class="win">192.168.1.200</code><code class="linux">192.168.1.200</code> (if you have not changed it for something else), username <code>pi</code> and password <code>raspberry</code>.</p>
<h3>Expanding filesystem</h3>
<p>If your whole installation is on the SD card, the easiest way to go is to use the <code>raspi-config</code> tool. Run <code>sudo raspi-config</code> in the Raspberry Pi console to open the tool's interface.</p>
<p>Select the first menu item <b>1 Expand Filesystem</b> and press enter. You will have to reboot the Pi after this step.</p>
<h3>Configure keyboard</h3>
<p>It is useful to configure the layout of your keyboard as for many following tasks you will need to type specific symbols that are usually hard to find on the keyboard if the layout is not the way it is on your main computer. Type the following in the Pi terminal to access keyboard configuration:</p>
<pre>sudo raspi-config</pre>
<p>Go to <b>4 Internationalization Options</b>. From there choose <b>I3 Change Keyboard Layout</b> and hit enter.</p>
<h3>Set up timezone</h3>
<p>Assigning the right timezone might be also usefull, especially for debugging. There might be situations where knowing what happened at what time can be critical. So execute <code>sudo raspi-config</code> again and go to <b>4 Internationalization Options</b>, then <b>I2 Change Timezone</b>.</p>
<h3>Auto Login</h3>
<p>To make your Pi log in automatically, run the following line in the shell:</p>
<pre>sudo nano /etc/inittab</pre>
<p>Comment (by using #) the line starting the terminal tty1 ("<code>1:2345:respawn:/sbin/getty 115200 tty1</code>"), and just bellow it add:</p>
<pre>1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1</pre>
<blockquote class="alert-info"><p><b>TIP:</b> Use keyboard arrow keys to navigate the text file. You won't see scrollbars in this kind of text editors and adjusting the cursor position with mouse won't do any good.</p></blockquote>
<p>Close the file by pressing <kbd>Ctrl + X</kbd>. Nano will ask if you want to save the file: press <kbd>Y</kbd> to say yes. Next, Nano will ask where to save the file: just press <kbd>Enter</kbd> to overwrite the existing file.</p>
<h3>Preventing the screen from going blank</h3>
<p>If you are using your Pi through SSH without an actual keyboard connected, the screen might go to sleep after some time as your Pi does not detect any activity. To prevent that, edit the <code>rc.local</code> file by opening it in the nano editor: <code>sudo nano /etc/rc.local</code>. Press <kbd>Enter</kbd> to execute the command.</p>
<p>Add the following line just before the <code>exit 0</code> line:</p>
<pre>sh -c 'setterm -blank 0 -powersave off -powerdown 0 < /dev/console > /dev/console 2>&1'</pre>
<p>Save the file and exit (<kbd>Ctrl + X</kbd>, <kbd>Y</kbd> and <kbd>Enter</kbd>). Reboot your Pi: <code>sudo reboot</code>, press <kbd>Enter</kbd> to execute the command. Now the screen will stay awake after the Pi reboots.</p>
<h3>Startup scripts</h3>
<h4>Starting a program on boot</h4>
<p>On the Pi go to the <code>/home/pi</code> directory by typing the following in the terminal:</p>
<pre>cd /home/pi</pre>
<p>Press <kbd>Enter</kbd>. We are going to create a text file (a script) that will contain instructions for the Pi - what to do when it boot's up. To create the file, type <code>touch startup.sh</code> in the Pi Terminal and press <kbd>Enter</kbd>.</p>
<p>Next, we are going to make it executable (launchable). Write <code>chmod a+x startup.sh</code> in the Pi Terminal and press <kbd>Enter</kbd> again.</p>
<p>Then open <code>.bashrc</code> by typing <code>sudo nano ~/.bashrc</code> in the Pi Terminal and pressing <kbd>Enter</kbd>.</p>
<p>Use arrow keys to navigate, <b>add</b> the following line at the end of the file:</p>
<pre>~/startup.sh</pre>
<p>Save the file by pressing <kbd>Ctrl + X</kbd>, <kbd>Y</kbd> and <kbd>Enter</kbd> and exit.</p>
<p>I think it is a good idea not to run everything when you log in via SSH next time. Edit the <code>startup.sh</code> file to distinguish between direct login and SSH access. Open the file in text editor:</p>
<pre>sudo nano ~/startup.sh</pre>
<p>Don'f forget to press <kbd>Enter</kbd>. Replace the contents of the file with the following:</p>
<pre>#!/bin/bash
echo "Checking SSH connection...";
if [ -z "$SSH_CONNECTION" ]; then
echo "No SSH connection, launching scripts.";
# Your scripts here
else
echo "SSH connection, nothing to be launched.";
fi</pre>
<p>You can add your own scripts just after the <code># Your scripts here</code> line. When you are done, save the file and exit by pressing <kbd>Ctrl + X</kbd>, <kbd>Y</kbd> and <kbd>Enter</kbd>.</p>
<h3>Starting graphical user interface</h3>
<p>Yes, there is a possibility to use the Raspberry Pi as a regular desktop computer with keyboard and mouse, open windows and browse web-pages as normal people do. Sometimes it might help you get your text-editing or file-moving tasks done faster.</p>
<p>If you are using your Pi directly - without SSH connection, with a screen, mouse and keyboard connected, you can issue the <code>startx</code> command in the Pi shell to start the desktop mode. It is possible to configure your Pi to enter this mode automatically by using the <code>sudo raspi-config</code> tool. Choose the <b>3 Enable Boot to Desktop/Scratch</b> option.</p>
<!--_______________ SECTION 6 _______________-->
<h2>6. Useful tips</h2>
<h3>Getting a GUI for Pi programs</h3>
<p>Even when connecting through SSH, it is still possible to get graphical user interface (also called "GUI") for many programs. This is achieved by using a technique known as "X forwarding". The program runs on the Pi, but forwards its graphical output to your own laptop. On your laptop you need to have a server that interprets those commands.</p>
<div class="linux mac">
<p class="linux">On Linux, X is the normal way to display GUIs. Therefore you have nothing extra to install.</p>
<p class="mac">First, you should install <a href="http://xquartz.macosforge.org/landing/">XQuartz</a>, which is a X11 server for mac OS.</p>
<p>Connect to your Pi through SSH, but add the <code>-X</code> option. For example <code>ssh -X [email protected]</code></p>
</div>
<div class="win">
<p>There are many programs that allow you to connect through SSH with X forwarding. We recommend you to use <a href="http://mobaxterm.mobatek.net/">MobaXterm</a>. It is a good all-in-one solution for working through SSH. You can connect, save sessions, transfer files very easily, and also enable X forwarding to get GUI of programs running on the Pi.</p>
<p>To connect, click on "session", then go to "SSH" and type the IP address of your Pi. That's all there is to it. X forwarding should be enabled by default.</p>
</div>
<p>Once you have successfuly opened a connection, you can test that X forwarding works by opening a program that has a GUI on your Pi. For example, try to open "leafpad" by running <code>leafpad</code> in the terminal. Leafpad is a simple text editor, and if everything works fine, you should see it open on your laptop.</p>
</div><!-- /.container -->
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/jquery.client.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>